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

method AnalyzerResultExtension.AddToWorkspace doesn't check for duplicate projects in solution #156

Open
ltcmelo opened this issue Dec 2, 2020 · 4 comments
Labels
⚠ Bug Something isn't working as expected

Comments

@ltcmelo
Copy link
Contributor

ltcmelo commented Dec 2, 2020

Consider the following snippet.

analyzerResult = projAnalyzer.Build();
…
analyzerResult.AddToWorkspace(workspace, true);

Now, assume that the project to which the object projAnalyzer is associated with has structure such as that of this project — from a Roslyn issue.

Then, the addition to the workspace triggers an InvalidOperationException. I imagine that Buildalyzer should check the presence of the project before adding it (due to transitive references).

@daveaglick
Copy link
Collaborator

I'm having a little trouble understanding the issue here. Can you provide any more details about the InvalidOperationException generated in this case? Is it coming from Buildalyzer directly (and if so, where?) or from Roslyn?

What would really help is a reproducible Solution and Project file(s) so I can see exactly what's going on.

@ltcmelo
Copy link
Contributor Author

ltcmelo commented Dec 20, 2020

The InvalidOperationException is generated from MSBuild API, but it does so because Buildalyzer adds duplicate Projects to a Solution/Workspace.

You can reproduce this issue by creating .csproj files that map the organization I mentioned here, requesting their corresponding ProjectAnalyzers to build and passing true as the option to (automatically) include project references.

@daveaglick
Copy link
Collaborator

I just did some related work on transitive references in Roslyn workspaces in #181 which should hopefully help with the scenario here, but I still can't reproduce anything like the InvalidOperationException you describe. Any chance you could work up a small reproducible project with the latest version that exhibits this problem? This might be a good starting point: https://github.com/slang25/BuildalyzerBugRepro

@ltcmelo
Copy link
Contributor Author

ltcmelo commented Aug 17, 2021

Any chance you could work up a small reproducible project with the latest version that exhibits this problem?

@daveaglick the project I describe here reproduces the issue I mention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠ Bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants