-
Notifications
You must be signed in to change notification settings - Fork 480
Closed
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzersCategory-GlobalizationConcept-Continuous Improvementhelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting
Milestone
Description
NOTE: We ideally don't recommend comparing method names to identify if the expected method is being called. Instead you should fetch the expected method symbol on the guidType named type symbol in the compilation start action and directly compare invocationOperation.TargetMethod and that well-known method symbol. However, I see that this analyzer already follows the pattern similar to the one you followed here, so I won't block your PR on this:
roslyn-analyzers/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Runtime/SpecifyIFormatProvider.cs
Lines 267 to 275 in a4ffd4f
| private static bool IsValidToStringCall(IInvocationOperation invocationOperation, ImmutableHashSet<INamedTypeSymbol> invariantToStringTypes, | |
| INamedTypeSymbol? dateTimeType, INamedTypeSymbol? dateTimeOffsetType, INamedTypeSymbol? timeSpanType) | |
| { | |
| var targetMethod = invocationOperation.TargetMethod; | |
| if (targetMethod.Name != "ToString") | |
| { | |
| return false; | |
| } |
I'll open a tracking issue to clean this up in a follow-up PR.
Originally posted by @mavasani in #6000 (comment)
Metadata
Metadata
Assignees
Labels
Area-Microsoft.CodeAnalysis.NetAnalyzersCategory-GlobalizationConcept-Continuous Improvementhelp wantedThe issue is up-for-grabs, and can be claimed by commentingThe issue is up-for-grabs, and can be claimed by commenting