Fix handling of unrecognized naming style values#27331
Fix handling of unrecognized naming style values#27331sharwell merged 7 commits intodotnet:masterfrom
Conversation
64c8cd1 to
96975e1
Compare
96975e1 to
b0147a1
Compare
| case SymbolKind.TypeParameter: | ||
| continue; | ||
|
|
||
| case SymbolKind.Method when ((IMethodSymbol)currentSymbol).MethodKind == MethodKind.LocalFunction: |
There was a problem hiding this comment.
What about parameters of lambdas & anonymous methods?
They should be local, so this is likely missing another case for MethodKind.AnonymousFunction.
There was a problem hiding this comment.
I added the following tests to TestPascalCaseSymbol_ExpectedSymbolAndAccessibility and fixed the condition here.
[InlineData("void Outer() { void Inner(int [|m|]) {} }", "void Outer() { void Inner(int M) {} }", SymbolKind.Parameter, Accessibility.NotApplicable)]
[InlineData("void Outer() { System.Action<int> action = [|m|] => {} }", "void Outer() { System.Action<int> action = M => {} }", SymbolKind.Parameter, Accessibility.NotApplicable)]
[InlineData("void Outer() { System.Action<int> action = ([|m|]) => {} }", "void Outer() { System.Action<int> action = (M) => {} }", SymbolKind.Parameter, Accessibility.NotApplicable)]
[InlineData("void Outer() { System.Action<int> action = (int [|m|]) => {} }", "void Outer() { System.Action<int> action = (int M) => {} }", SymbolKind.Parameter, Accessibility.NotApplicable)]
[InlineData("void Outer() { System.Action<int> action = delegate (int [|m|]) {} }", "void Outer() { System.Action<int> action = delegate (int M) {} }", SymbolKind.Parameter, Accessibility.NotApplicable)]I'll wait to see if there are other tests I need to add before pushing this update.
| [WorkItem(20907, "https://github.com/dotnet/roslyn/issues/20907")] | ||
| public async Task TestPascalCaseSymbol_ExpectedSymbolAndAccessibility(string camelCaseSymbol, string pascalCaseSymbol, object symbolKind, Accessibility accessibility) | ||
| { | ||
| var alternateSymbolKind = TypeKind.Class.Equals(symbolKind) ? TypeKind.Interface : TypeKind.Class; |
There was a problem hiding this comment.
I am fine with this InlineData. but with this many inlineData, how one debug it? should one go through every inlinedata until right inline data is finally used for the test?
seems it is just different way to do stuff than our usual test just calling VerifyXXXX(code, epected result);
There was a problem hiding this comment.
with this many inlineData, how one debug it?
You can right click the specific case in Test Explorer and Debug Selected Tests.
| { | ||
| switch (symbolOrTypeKind) | ||
| { | ||
| case TypeKind typeKind: |
There was a problem hiding this comment.
Looks like your indentation settings might be off (I think it's usually one deeper)
There was a problem hiding this comment.
I'll update as a separate PR so we don't have to retest this one for just indentation.
There was a problem hiding this comment.
➡️ Had to rerun tests for retargeting, so fixed in 32e150c
| [InlineData(null, new object[] { SymbolKind.Namespace, TypeKind.Class, TypeKind.Struct, TypeKind.Interface, TypeKind.Enum, SymbolKind.Property, MethodKind.Ordinary, MethodKind.LocalFunction, SymbolKind.Field, SymbolKind.Event, TypeKind.Delegate, SymbolKind.Parameter, SymbolKind.TypeParameter, SymbolKind.Local })] | ||
| [InlineData("property,method,invalid", new object[] { SymbolKind.Property, MethodKind.Ordinary })] | ||
| [InlineData("invalid", new object[] { })] | ||
| [InlineData("", new object[] { })] |
| [InlineData(null, new[] { Accessibility.NotApplicable, Accessibility.Public, Accessibility.Internal, Accessibility.Private, Accessibility.Protected, Accessibility.ProtectedAndInternal, Accessibility.ProtectedOrInternal })] | ||
| [InlineData("internal,protected,invalid", new[] { Accessibility.Internal, Accessibility.Protected })] | ||
| [InlineData("invalid", new Accessibility[] { })] | ||
| [InlineData("", new Accessibility[] { })] |
|
Approved to merge for 15.8.Preview4 (Once tests are green) |
|
Both integration test failures are the issue from #27933 |
Screenshots
Baseline (15.8 Preview 2)
Baseline (current master branch e3dcf8c)
After second commit
After third commit
Customer scenario
A user attempts to create a naming rule in .editorconfig for a symbol type added in a recent release of Roslyn. Old versions treat the rule as apply to all symbols when it should apply to no symbols. A similar situation applies for accessibilities.
In addition, some of our documented member kinds (namespace and type_parameter) do not work as documented.
Bugs this fixes
#18121
#20907
#23336
#23709
#24248
Workarounds, if any
Don't use the new feature.
Risk
This change is relatively low risk for Preview 3. It builds on other new feature work in Preview 3, and helps ensure that a consistent experience is provided for the new feature now and in future releases.
Performance impact
Low. Existing working patterns were used for the new analysis.
Is this a regression from a previous update?
No.
Root cause analysis
This is a supporting change for feature work already in Preview 3. It was intended for inclusion in the "mop-up" on Monday, but infrastructure and test problems delayed the work. Now that we see the tests working again with this pull request we are ready to submit it.
How was the bug found?
Customer and internal customer reported.
Test documentation updated?
No, but many new tests are added.