Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE shoudl not attempt to replicate the compiler to generate diagnostics inside lambdas for constructors. #53234

Merged
merged 11 commits into from
May 7, 2021

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 6, 2021

Fixes #38822

Opening this to see what fails, adn thus what we can file semantic-model issues on.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 6, 2021 20:34
Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

The analyzer can be removed as a whole if #32628 is done. See #32629.

@CyrusNajmabadi CyrusNajmabadi changed the title Remove code that shouldn't exist. IDE shoudl not attempt to replicate the compiler to generate diagnostics inside lambdas. May 6, 2021
@CyrusNajmabadi CyrusNajmabadi changed the title IDE shoudl not attempt to replicate the compiler to generate diagnostics inside lambdas. IDE shoudl not attempt to replicate the compiler to generate diagnostics inside lambdas for constructors. May 6, 2021
@CyrusNajmabadi
Copy link
Member Author

The analyzer can be removed as a whole if #32628 is done. See #32629.

We still need the compiler to report errors for incomplete members: #7536

@@ -6124,5 +6124,82 @@ public class Goo
}
}", testHost);
}

[WorkItem(1239, @"https://github.com/dotnet/roslyn/issues/1239")]
Copy link
Member Author

Choose a reason for hiding this comment

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

these tests moved. teh standard analyzer supports these once neal did his work to still bind lambdas with syntax errors in them.

}
}");
}

[WorkItem(829970, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/829970")]
[Fact]
public async Task TestUnknownIdentifierGenericName()
Copy link
Member Author

Choose a reason for hiding this comment

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

we still need these tests for incomplete members until compiler fixes: #7536

}

internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpUnboundIdentifiersDiagnosticAnalyzer(), new GenerateConstructorCodeFixProvider());
Copy link
Member Author

Choose a reason for hiding this comment

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

same as above. these are not supported by the normal analzyer/fixprovider


protected override DiagnosticDescriptor DiagnosticDescriptor2 => GetDiagnosticDescriptor(IDEDiagnosticIds.UnboundConstructorId, _constructorOverloadResolutionFailureMessageFormat);

protected override bool ConstructorDoesNotExist(SyntaxNode node, SymbolInfo info, SemanticModel model)
Copy link
Member Author

Choose a reason for hiding this comment

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

this is horrible. we were effectively adding a pass saying: "oh... compiler didn't report diagnostics. so let's just try to simulate the rules of the language to report the diagnostics we think tehy should be reporting". We should never ever ever ever ever ever ever do this.

Copy link
Member

@akhera99 akhera99 May 6, 2021

Choose a reason for hiding this comment

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

I agree, I see that #32628 is still open. Is the intention to just remove this analyzer and file additional bugs at the compiler level to appropriately report these diagnostics? Either way, I think it makes more sense to remove this analyzer and not introduce bugs in the users code then to keep it in and catch a niche case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is the intention to just remove this analyzer and file additional bugs at the compiler level to appropriately report these diagnostics?

Yes :)

@@ -168,7 +168,6 @@ internal static class IDEDiagnosticIds
public const string InvokeDelegateWithConditionalAccessId = "IDE1005";
public const string NamingRuleId = "IDE1006";
public const string UnboundIdentifierId = "IDE1007";
public const string UnboundConstructorId = "IDE1008";
Copy link
Member Author

Choose a reason for hiding this comment

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

UnboundIdentifierId still needs to go too, but that's harder and we need compiler support here for that.

@CyrusNajmabadi CyrusNajmabadi merged commit 2802e9a into dotnet:main May 7, 2021
@ghost ghost added this to the Next milestone May 7, 2021
@CyrusNajmabadi CyrusNajmabadi deleted the removeUnboundConstructors branch May 7, 2021 18:04
@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE1008 when constructor called without optional parameters inside incomplete lambda
5 participants