Skip to content

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

Merged
CyrusNajmabadi merged 11 commits intodotnet:mainfrom
CyrusNajmabadi:removeUnboundConstructors
May 7, 2021
Merged

IDE shoudl not attempt to replicate the compiler to generate diagnostics inside lambdas for constructors.#53234
CyrusNajmabadi merged 11 commits intodotnet:mainfrom
CyrusNajmabadi:removeUnboundConstructors

Conversation

@CyrusNajmabadi
Copy link
Contributor

@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
@ghost ghost added the Area-IDE label May 6, 2021
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
Contributor 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

}", testHost);
}

[WorkItem(1239, @"https://github.com/dotnet/roslyn/issues/1239")]
Copy link
Contributor 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
Contributor 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
Contributor 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
Contributor 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
Contributor 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 :)

@CyrusNajmabadi CyrusNajmabadi requested a review from akhera99 May 7, 2021 01:53
public const string InvokeDelegateWithConditionalAccessId = "IDE1005";
public const string NamingRuleId = "IDE1006";
public const string UnboundIdentifierId = "IDE1007";
public const string UnboundConstructorId = "IDE1008";
Copy link
Contributor 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