Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CA2023: Adds validation against invalid braces in logger message templates) #7286

Merged
merged 28 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
508a65a
Stabilize package versions (#7002)
ViktorHofer Oct 25, 2023
dcb58dd
Revert "Stabilize package versions (#7002)" (#7003)
ViktorHofer Oct 25, 2023
116b8c4
Adds validation against invalid bracket pairs
Kritner Apr 10, 2024
562618c
Fix extra break flagged by CI
Kritner Apr 10, 2024
9adceb5
Remove one branch to be fully covered
Kritner Apr 10, 2024
1d8357f
Adds secondary occurrence of CA2017 around mismatched braces
Kritner Apr 10, 2024
386fe96
Adds new messages to base resource file
Kritner Apr 10, 2024
26f1e68
Ran resource generation
Kritner Apr 10, 2024
3b6394c
Fix tests, use `WorkItem` attribute
Kritner Apr 11, 2024
13af907
documentation updates for CA2017
Kritner Apr 11, 2024
11b6ce1
Revert "documentation updates for CA2017"
Kritner Apr 11, 2024
b3443e3
Trying something else with CA2017 regarding localization
Kritner Apr 11, 2024
211c166
Finish rebase
Kritner Apr 11, 2024
7333c4d
Take into account escaped braces
Kritner Apr 14, 2024
eab2278
Use CA2023 instead of an overloaded CA2017
Kritner Apr 15, 2024
073302f
Revert "Ran resource generation"
Kritner Apr 15, 2024
a3cda94
Revert "Adds new messages to base resource file"
Kritner Apr 15, 2024
cfc96f4
Adds new CA2023 information to resources
Kritner Apr 15, 2024
880a5d3
Reverts "new" translation indicators back to their previously "transl…
Kritner Apr 15, 2024
59f5fb8
Missed a few files from last commit
Kritner Apr 15, 2024
6d04bad
More covering tests, comment tweaking
Kritner Apr 15, 2024
7a46e9f
Merge branch 'main' into fix/7285_ca2017
Kritner Apr 18, 2024
beadcb6
Merge branch 'main' into fix/7285_ca2017
Kritner Aug 13, 2024
ce9f33e
Remove additional space between sentences, `error` -> `warning`
Kritner Aug 13, 2024
bee9c98
fix(LoggerMessageDefineAnalyzer): BuildError -> BuildWarning
Kritner Aug 13, 2024
695ed5f
Optimized impl from @tarekgh
Kritner Aug 13, 2024
069303b
linting and another missed `error` -> `warning`
Kritner Aug 13, 2024
d962a08
Additional covering tests
Kritner Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CA1515 | Maintainability | Disabled | MakeTypesInternal, [Documentation](https:/
CA1871 | Performance | Info | DoNotPassNonNullableValueToArgumentNullExceptionThrowIfNull, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1871)
CA1872 | Performance | Info | PreferConvertToHexStringOverBitConverterAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1872)
CA2022 | Reliability | Warning | AvoidUnreliableStreamReadAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2022)
CA2023 | Reliability | Warning | LoggerMessageDefineAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2023)
CA2262 | Usage | Info | ProvideHttpClientHandlerMaxResponseHeaderLengthValueCorrectly, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2262)
CA2263 | Usage | Info | PreferGenericOverloadsAnalyzer, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2263)
CA2264 | Usage | Warning | DoNotPassNonNullableValueToArgumentNullExceptionThrowIfNull, [Documentation](https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2264)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@
<data name="LoggerMessageDiagnosticFormatParameterCountMismatchDescription" xml:space="preserve">
<value>Number of parameters supplied in the logging message template do not match the number of named placeholders.</value>
</data>
<data name="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle" xml:space="preserve">
<value>Invalid braces in message template</value>
</data>
<data name="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage" xml:space="preserve">
<value>The braces present in the message template are invalid</value>
</data>
<data name="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription" xml:space="preserve">
<value>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</value>
</data>
<data name="LoggerMessageDiagnosticUseCompiledLogMessagesTitle" xml:space="preserve">
<value>Use the LoggerMessage delegates</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Neshoda počtu parametrů.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Pojmenované zástupné symboly v šabloně zprávy protokolování by neměly obsahovat jenom číselné znaky.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Konflikt bei der Parameteranzahl</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Benannte Platzhalter in der Vorlage für Protokollierungsnachrichten dürfen nicht nur aus numerischen Zeichen bestehen.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">El recuento de parámetros no coincide</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Los marcadores de posición con nombre de la plantilla de mensaje de registro no deben estar formados solo por caracteres numéricos.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Nombre de paramètres incorrects.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Les espaces réservés nommés dans le modèle de message de journalisation ne doivent pas être composés uniquement de caractères numériques.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Numero di parametri non corrispondente</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">I segnaposto denominati nel modello di messaggio di registrazione non devono contenere solo caratteri numerici.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">パラメーター カウントが不一致</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">ログ メッセージ テンプレートの名前付きプレースホルダーは、数字のみで構成することはできません。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">매개 변수의 개수가 일치하지 않음</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">로깅 메시지 템플릿의 명명된 자리 표시자는 숫자로만 구성되어서는 안 됩니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Niezgodność liczby parametrów</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Nazwane symbole zastępcze w szablonie wiadomości rejestrowania nie powinny składać się tylko z samych cyfr.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Incompatibilidade de contagem de parâmetros</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Espaços reservados nomeados no modelo de mensagem de log não devem ser compostos apenas de caracteres numéricos.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Несоответствие количества параметров</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Именованные заполнители в шаблоне сообщения о ведении журнала не должны состоять только из цифр.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@
<target state="translated">Parametre sayısı uyuşmazlığı</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchDescription">
<source>The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</source>
<target state="new">The braces present in the message template are invalid. Ensure any braces in the message template are valid opening/closing braces, or are escaped.</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchMessage">
<source>The braces present in the message template are invalid</source>
<target state="new">The braces present in the message template are invalid</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticMessageTemplateBracesMismatchTitle">
<source>Invalid braces in message template</source>
<target state="new">Invalid braces in message template</target>
<note />
</trans-unit>
<trans-unit id="LoggerMessageDiagnosticNumericsInFormatStringDescription">
<source>Named placeholders in the logging message template should not be comprised of only numeric characters.</source>
<target state="translated">Günlük ileti şablonundaki adlandırılmış yer tutucular, yalnızca sayısal karakterlerden oluşmamalıdır</target>
Expand Down
Loading