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

Update messages for symbol comparison diagnostic and codefix #5535

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@
<value>Symbols should be compared for equality, not identity. Use an overload accepting an 'IEqualityComparer' and pass 'SymbolEqualityComparer'.</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing description (not touched in this PR) doesn't make much sense to me for the same reasoning in #5535 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equality kind of stretches into inclusion/exclusion of nullable here. Shorthand to say "Should compare for equality" makes some sense to me, but I definitely see where the ", not identity" can be misleading.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equality kind of stretches into inclusion/exclusion of nullable here

That's exactly it. this is what should be indicated by the diagnostic.

Probably:

  • Title: Make your symbol comparison intent explicit
  • Message: Specify whether you want to include nullability when comparing symbols
  • Description: When comparing symbols, explicitly specify a 'SymbolEqualityComparer' to indicate whether you want to include nullability in comparison

(I know my wording isn't very good, but something along those lines?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

  • Title: Symbol comparison should use 'SymbolEqualityComparer'
  • Message: Use a 'SymbolEqualityComparer' to specify whether to include nullability when comparing symbols
  • Description: When comparing symbols, it's good practice to specify whether symbols with different nullability should be considered equal. Use a 'SymbolEqualityComparer' to specify in this comparison whether to include nullability as part of the equality check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That way the title tells you what we expect, the message and description both elaborate on the why

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback :) I'll see if I can get that in this afternoon

</data>
<data name="CompareSymbolsCorrectlyMessage" xml:space="preserve">
<value>Compare symbols correctly</value>
<value>Use 'SymbolEqualityComparer' when comparing symbols</value>
</data>
<data name="CompareSymbolsCorrectlyTitle" xml:space="preserve">
<value>Compare symbols correctly</value>
<value>Symbols should be compared for equality</value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this is misleading. A code violating this rule is already comparing for equality. e,g symbolA.Equals(symbolB), and this is completely equivalent to symbolA.Equals(symbolB, SymbolEqualityComparer.Default).

The thing is mostly about the "intent" when there are nullable differences.

</data>
<data name="CompareSymbolsCorrectlyCodeFix" xml:space="preserve">
<value>Compare symbols correctly</value>
<value>Use a 'SymbolEqualityComparer' for symbol comparison</value>
</data>
<data name="ConfigureGeneratedCodeAnalysisMessage" xml:space="preserve">
<value>Configure generated code analysis</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Porovnat symboly správně</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Porovnat symboly správně</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Porovnat symboly správně</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Porovnat symboly správně</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Porovnat symboly správně</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Porovnat symboly správně</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Symbole ordnungsgemäß vergleichen</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Symbole ordnungsgemäß vergleichen</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Symbole ordnungsgemäß vergleichen</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Symbole ordnungsgemäß vergleichen</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Symbole ordnungsgemäß vergleichen</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Symbole ordnungsgemäß vergleichen</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Comparar los símbolos correctamente</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Comparar los símbolos correctamente</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Comparar los símbolos correctamente</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Comparar los símbolos correctamente</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Comparar los símbolos correctamente</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Comparar los símbolos correctamente</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Comparer les symboles correctement</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Comparer les symboles correctement</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Comparer les symboles correctement</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Comparer les symboles correctement</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Comparer les symboles correctement</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Comparer les symboles correctement</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Confrontare i simboli nel modo corretto</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Confrontare i simboli nel modo corretto</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Confrontare i simboli nel modo corretto</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Confrontare i simboli nel modo corretto</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Confrontare i simboli nel modo corretto</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Confrontare i simboli nel modo corretto</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">シンボルを正しく比較する</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">シンボルを正しく比較する</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">シンボルを正しく比較する</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">シンボルを正しく比較する</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">シンボルを正しく比較する</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">シンボルを正しく比較する</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">기호를 올바르게 비교</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">기호를 올바르게 비교</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">기호를 올바르게 비교</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">기호를 올바르게 비교</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">기호를 올바르게 비교</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">기호를 올바르게 비교</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down Expand Up @@ -692,4 +692,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Porównaj symbole poprawnie</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Porównaj symbole poprawnie</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Porównaj symbole poprawnie</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Porównaj symbole poprawnie</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Porównaj symbole poprawnie</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Porównaj symbole poprawnie</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Comparar símbolos corretamente</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Comparar símbolos corretamente</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Comparar símbolos corretamente</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Comparar símbolos corretamente</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Comparar símbolos corretamente</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Comparar símbolos corretamente</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Сравнивайте символы правильно</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Сравнивайте символы правильно</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Сравнивайте символы правильно</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Сравнивайте символы правильно</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Сравнивайте символы правильно</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Сравнивайте символы правильно</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down Expand Up @@ -692,4 +692,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">Simgeleri doğru karşılaştır</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">Simgeleri doğru karşılaştır</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">Simgeleri doğru karşılaştır</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">Simgeleri doğru karşılaştır</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">Simgeleri doğru karşılaştır</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">Simgeleri doğru karşılaştır</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyCodeFix">
<source>Compare symbols correctly</source>
<target state="translated">正确比较符号</target>
<source>Use a 'SymbolEqualityComparer' for symbol comparison</source>
<target state="needs-review-translation">正确比较符号</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyDescription">
Expand All @@ -33,13 +33,13 @@
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyMessage">
<source>Compare symbols correctly</source>
<target state="translated">正确比较符号</target>
<source>Use 'SymbolEqualityComparer' when comparing symbols</source>
<target state="needs-review-translation">正确比较符号</target>
<note />
</trans-unit>
<trans-unit id="CompareSymbolsCorrectlyTitle">
<source>Compare symbols correctly</source>
<target state="translated">正确比较符号</target>
<source>Symbols should be compared for equality</source>
<target state="needs-review-translation">正确比较符号</target>
<note />
</trans-unit>
<trans-unit id="ConfigureGeneratedCodeAnalysisFix">
Expand Down
Loading