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

Features in .csproj are ignored. #72

Closed
SudoEPM opened this issue Aug 18, 2018 · 1 comment
Closed

Features in .csproj are ignored. #72

SudoEPM opened this issue Aug 18, 2018 · 1 comment

Comments

@SudoEPM
Copy link

SudoEPM commented Aug 18, 2018

I am trying to use the "Flow-Analysis" which should be added to a .csproj like this

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <Features>Flow-Analysis</Features>
  </PropertyGroup>

However when I try to use your library like this:

AnalyzerManager manager = new AnalyzerManager();
 ProjectAnalyzer analyzer = manager.GetProject(@"path/to/my/project.csproj");
AdhocWorkspace workspace = analyzer.GetWorkspace();
var project = workspace.CurrentSolution.Projects.First();
System.Console.WriteLine(project.ParseOptions.Features.Count);

The output will be 0, the feature is not added to my project.

Some features like the ControlFlowGraph need those to be used

Ex: http://source.roslyn.io/#Microsoft.CodeAnalysis/Operations/ControlFlowGraph.cs line 74

if (!operation.Syntax.SyntaxTree.Options.Features.ContainsKey("flow-analysis"))
{
    throw new InvalidOperationException(CodeAnalysisResources.FlowAnalysisFeatureDisabled);
}
@daveaglick
Copy link
Collaborator

I just published Buildalyzer 2.0 which runs MSBuild out-of-process (as opposed to the old way of running it via MSBuild APIs). In general, if you can build it Buildalyzer should now be able to build it. Given how drastically different this new technique is, I'm closing all existing bug reports.

Please try the new version and if you're still having problems, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants