dotnet/roslyn

IDE0049 should use dotnet_style_predefined_type_for_locals_parameters_members for parameter types in XMLDoc references

Offen

#57.764 geöffnet am 15.11.2021

 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (4.257 Forks)batch import
Area-IDEBugFeature - IDE0049help wanted

Repository-Metriken

Stars
 (20.414 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)

Beschreibung

Version Used: VS 2019 16.11.6 .Net Core 3.1/C# 8 Microsoft (R) Visual C# Compiler Version 3.11.0-4.21403.6 (ae1fff34)

Steps to Reproduce:

  1. Set the two settings for predefined types in .editorconfig differently:
    dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
    dotnet_style_predefined_type_for_member_access = false:suggestion
    
  2. Write a reference in XML documentation to a method with a parameter of a built-in type ():
    ///<see cref="Console.WriteLine(string)"/>
    

Expected Behavior: No suggestion

Actual Behavior: IDE0049 sugggesting to change the parameter type string to String. In my eyes this is wrong, references should use the same style as the declarations.

Additional Information

  1. WriteLine(string) is also what Intellisense inserts as autocomplete.
  2. In references to members of built-in types like int/Int32.MaxValue using the framework type is suggested as expected.
  3. After a quick look at the source I guess the problem is this line or when the implementations of CanSimplifyTypeNameExpression() set inDeclaration: https://github.com/Youssef1313/roslyn/blob/a1290467d7da6510da33a16b2f1b59260794c816/src/Features/Core/Portable/SimplifyTypeNames/SimplifyTypeNamesDiagnosticAnalyzerBase.cs#L163-L165

Contributor Guide