Skip to content

Fix handling of unrecognized naming style values#27331

Merged
sharwell merged 7 commits intodotnet:masterfrom
sharwell:editorconfig-empty-lists
Jun 19, 2018
Merged

Fix handling of unrecognized naming style values#27331
sharwell merged 7 commits intodotnet:masterfrom
sharwell:editorconfig-empty-lists

Conversation

@sharwell
Copy link
Copy Markdown
Contributor

@sharwell sharwell commented Jun 1, 2018

Screenshots

Baseline (15.8 Preview 2)

image

image

Baseline (current master branch e3dcf8c)

image

image

After second commit

image

image

After third commit

image

image

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.

@sharwell sharwell added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jun 1, 2018
@sharwell sharwell requested a review from a team as a code owner June 1, 2018 14:55
@sharwell sharwell force-pushed the editorconfig-empty-lists branch from 64c8cd1 to 96975e1 Compare June 1, 2018 14:58
@sharwell sharwell force-pushed the editorconfig-empty-lists branch from 96975e1 to b0147a1 Compare June 1, 2018 18:16
@sharwell sharwell removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jun 1, 2018
@sharwell sharwell added this to the 15.8 milestone Jun 1, 2018
case SymbolKind.TypeParameter:
continue;

case SymbolKind.Method when ((IMethodSymbol)currentSymbol).MethodKind == MethodKind.LocalFunction:
Copy link
Copy Markdown
Contributor

@Neme12 Neme12 Jun 1, 2018

Choose a reason for hiding this comment

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

What about parameters of lambdas & anonymous methods?
They should be local, so this is likely missing another case for MethodKind.AnonymousFunction.

Copy link
Copy Markdown
Contributor Author

@sharwell sharwell Jun 1, 2018

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

➡️ Fixed in 40ded3c

@jcouv jcouv added the Area-IDE label Jun 1, 2018
[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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Contributor Author

@sharwell sharwell Jun 2, 2018

Choose a reason for hiding this comment

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

with this many inlineData, how one debug it?

You can right click the specific case in Test Explorer and Debug Selected Tests.

Copy link
Copy Markdown
Contributor

@dpoeschl dpoeschl left a comment

Choose a reason for hiding this comment

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

Nice test coverage. 😄

{
switch (symbolOrTypeKind)
{
case TypeKind typeKind:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like your indentation settings might be off (I think it's usually one deeper)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same comment as #26589 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll update as a separate PR so we don't have to retest this one for just indentation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

➡️ 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[] { })]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice!

[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[] { })]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice again!

@sharwell sharwell changed the base branch from master to dev15.8-preview3 June 6, 2018 20:27
@sharwell sharwell changed the base branch from dev15.8-preview3 to master June 15, 2018 21:12
@jinujoseph
Copy link
Copy Markdown
Contributor

Approved to merge for 15.8.Preview4 (Once tests are green)

@sharwell
Copy link
Copy Markdown
Contributor Author

Both integration test failures are the issue from #27933

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

8 participants