Skip to content

Commit 30b97e2

Browse files
CopilotEvangelink
andauthored
Validate crash dump sub-options require a main option (#8452)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
1 parent 23d8e16 commit 30b97e2

16 files changed

Lines changed: 136 additions & 2 deletions

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.cs‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,23 @@ public Task<ValidationResult> ValidateOptionArgumentsAsync(CommandLineOption com
4646
}
4747

4848
public Task<ValidationResult> ValidateCommandLineOptionsAsync(ICommandLineOptions commandLineOptions)
49-
=> commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashReportOptionName)
50-
&& RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
49+
=> IsCrashDumpMainOptionMissing(commandLineOptions)
50+
? ValidationResult.InvalidTask(CrashDumpResources.MissingCrashDumpMainOption)
51+
: IsCrashReportUnsupportedOnCurrentPlatform(commandLineOptions)
5152
? ValidationResult.InvalidTask(CrashDumpResources.CrashReportNotSupportedOnWindowsErrorMessage)
5253
: ValidationResult.ValidTask;
54+
55+
private static bool IsCrashReportUnsupportedOnCurrentPlatform(ICommandLineOptions commandLineOptions)
56+
=> commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashReportOptionName) &&
57+
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
58+
59+
private static bool IsCrashDumpMainOptionMissing(ICommandLineOptions commandLineOptions)
60+
{
61+
bool hasCrashDumpSubOption = commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashDumpFileNameOptionName) ||
62+
commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashDumpTypeOptionName);
63+
bool hasCrashDumpMainOption = commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashDumpOptionName) ||
64+
commandLineOptions.IsOptionSet(CrashDumpCommandLineOptions.CrashReportOptionName);
65+
66+
return hasCrashDumpSubOption && !hasCrashDumpMainOption;
67+
}
5368
}

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/CrashDumpResources.resx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
<data name="CrashDumpInvalidEnvironmentVariableValueErrorMessage" xml:space="preserve">
142142
<value>Environment variable '{0}' should have been set to '{1}' but value is '{2}'</value>
143143
</data>
144+
<data name="MissingCrashDumpMainOption" xml:space="preserve">
145+
<value>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</value>
146+
</data>
144147
<data name="CrashDumpNotSupportedInNonNetCoreErrorMessage" xml:space="preserve">
145148
<value>Crash dump feature is only available in .NET (Core)</value>
146149
</data>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.cs.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Další informace najdete na https://learn.microsoft.com/dotnet/core/diagnostics
111111
<target state="translated">[Pouze Linux/macOS] Při chybovém ukončení testovacího procesu vygeneruje zprávu o chybovém ukončení ve formátu JSON. Pokud chcete vygenerovat také soubor výpisu paměti, zkombinujte s parametrem --crashdump. Pokud se používá samostatně, vyžaduje .NET 7+; při kombinaci s parametrem --crashdump vyžaduje .NET 6+. Tento požadavek na modul runtime není nástrojem vynucován: v případě nepodporovaných modulů runtime nebude vygenerována žádná zpráva o chybovém ukončení. Nepodporuje se ve Windows kvůli omezení modulu runtime .NET (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">Žádosti typu {0} nejsou podporovány.</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.de.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Weitere Informationen finden Sie unter https://learn.microsoft.com/dotnet/core/d
111111
<target state="translated">[Nur Linux/macOS] Generieren Sie einen JSON-Absturzbericht, wenn der Testprozess abstürzt. Kombinieren Sie dies mit „--crashdump“, um auch eine Absturzabbilddatei zu generieren. Erfordert .NET 7 und höher, wenn es allein verwendet wird; .NET 6+ in Kombination mit „--crashdump“. Diese Runtimeanforderung wird vom Tool nicht erzwungen: Bei nicht unterstützten Runtimes wird kein Absturzbericht ausgegeben. Wird unter Windows aufgrund einer .NET-Runtimeeinschränkung nicht unterstützt (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">Anforderungen vom Typ "{0}" werden nicht unterstützt</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.es.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Para obtener más información, visite https://learn.microsoft.com/dotnet/core/d
111111
<target state="translated">[Solo Linux/macOS] Genere un informe de bloqueo JSON cuando el proceso de prueba se bloquee. Combine con "--crashdump" para generar también un archivo de volcado. Requiere .NET 7+ cuando se usa solo; .NET 6+ cuando se combina con "--crashdump". La herramienta no aplica este requisito de tiempo de ejecución: en los entornos de ejecución no admitidos, no se emitirá ningún informe de bloqueo. No se admite en Windows debido a una limitación del entorno de ejecución de .NET (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">No se admiten solicitudes de tipo '{0}'</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.fr.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Pour plus d’informations, visitez https://learn.microsoft.com/dotnet/core/diag
111111
<target state="translated">[Linux/macOS uniquement] Générez un rapport d’incident JSON lorsque le processus de test se bloque. Combinez-le avec « --crashdump » pour générer également un fichier de vidage. Nécessite .NET 7+ lorsqu’il est utilisé seul ; .NET 6+ lorsqu’il est combiné avec « --crashdump ». L’outil n’applique pas cette exigence de runtime : aucun rapport d’incident ne sera généré sur les runtimes non pris en charge. Non pris en charge sur Windows en raison d’une limitation du runtime .NET (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">Les demandes de type «{0}» ne sont pas prises en charge</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.it.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Per altre informazioni, visitare https://learn.microsoft.com/dotnet/core/diagnos
111111
<target state="translated">[Solo Linux/macOS] Generare un report di arresto anomalo JSON quando il processo di test si arresta in modo anomalo. Combinare con ''--crashdump'' per generare anche un file di dump. Richiede .NET 7+ se usato da solo; .NET 6+ in combinazione con ''--crashdump''. Questo requisito di runtime non viene applicato dallo strumento: nei runtime non supportati non verrà generato alcun rapporto di arresto anomalo. Non supportato in Windows a causa di una limitazione del runtime .NET (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">Le richieste di tipo '{0}' non sono supportate</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ja.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ For more information visit https://learn.microsoft.com/dotnet/core/diagnostics/c
111111
<target state="translated">[Linux/macOS のみ] テスト プロセスがクラッシュしたときに JSON クラッシュ レポートを生成します。'--crashdump' と組み合わせて、ダンプ ファイルも生成できます。単独で使用する場合は .NET 7 以降、'--crashdump' と組み合わせる場合は .NET 6 以降が必要です。このランタイム要件はツールでは強制されません。サポートされていないランタイムではクラッシュ レポートは出力されません。.NET ランタイムの制限により、Windows ではサポートされません (dotnet/runtime#80191)。</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">型 '{0}' の要求はサポートされていません</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.ko.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ For more information visit https://learn.microsoft.com/dotnet/core/diagnostics/c
111111
<target state="translated">[Linux/macOS만 해당] 테스트 프로세스가 충돌할 때 JSON 크래시 보고서를 생성합니다. '--crashdump'와 함께 사용하면 덤프 파일도 생성합니다. 단독으로 사용할 때는 .NET 7+가 필요합니다. '--crashdump'와 함께 사용할 때는 .NET 6+가 필요합니다. 이 런타임 요구 사항은 도구에서 강제하지 않습니다. 지원되지 않는 런타임에서는 크래시 보고서가 생성되지 않습니다. .NET 런타임 제한(dotnet/runtime#80191)으로 인해 Windows에서는 지원되지 않습니다.</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">'{0}' 유형의 요청은 지원되지 않습니다.</target>

‎src/Platform/Microsoft.Testing.Extensions.CrashDump/Resources/xlf/CrashDumpResources.pl.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ Aby uzyskać więcej informacji, odwiedź stronę https://learn.microsoft.com/do
111111
<target state="translated">[Tylko Linux/macOS] Generuj raport JSON o awarii, gdy proces testowy ulegnie awarii. Połącz to z elementem „--crashdump”, aby też wygenerować plik zrzutu. Gdy używasz tego samodzielnie, wymaga to platformy .NET 7+; gdy używasz razem z elementem „--crashdump” — platformy .NET 6+. To wymaganie dotyczące środowiska uruchomieniowego nie jest wymuszane przez narzędzie: w nieobsługiwanych środowiskach uruchomieniowych nie będzie emitowany żaden raport o awarii. Nieobsługiwane w systemie Windows z powodu ograniczenia środowiska uruchomieniowego platformy .NET (dotnet/runtime#80191).</target>
112112
<note />
113113
</trans-unit>
114+
<trans-unit id="MissingCrashDumpMainOption">
115+
<source>You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</source>
116+
<target state="new">You specified one or more crash dump parameters but did not enable crash dumps. Add --crashdump or --crash-report to the command line.</target>
117+
<note />
118+
</trans-unit>
114119
<trans-unit id="UnsupportedRequestTypeErrorMessage">
115120
<source>Requests of type '{0}' is not supported</source>
116121
<target state="translated">Żądania typu „{0}” nie są obsługiwane</target>

0 commit comments

Comments
 (0)