Open Mrnikbobjeff opened 4 years ago
This should be in dotnet/roslyn-analyzers.
The implicit conversion from string
to System.Xml.Linq.XName
would trigger that analyzer. The conversion returns a reference type but caches the instance so that later conversions with the same input need not allocate. I suppose this would have to be documented as a valid reason to suppress the warning.
At least some such allocations are already in this analyzer, https://github.com/microsoft/RoslynClrHeapAllocationAnalyzer and probably others in roslyn-analyzers repo.
This should be in dotnet/roslyn-analyzers.
@jeffhandley where would you suggest we track new analyzer suggestions?
where would you suggest we track new analyzer suggestions?
Strawman:
Either
Or
I think we're currently on the latter path.
@mavasani or @stephentoub can you help transfer this, looks like I don't have write permissions.
@genlu @sharwell seems related to performance sensitive analyzers?
The guidelines for implicit conversion operators state that a user defined implicit conversion operator should not allocate on the heap. An analyzer could be used to detect cases where the conversion operator returns a reference type, suggesting the change to explicit to not conflict with the guideline.