Skip to content

Buildalyzer seems to be using C# 11 instead of 7.3 on some machines even for a .NET 4.8 project. #277

Open
@jons-bakerhill

Description

I'm using Buildalyzer to get project for Rosyln analysis to use for code generation. On my machine things generate as expected but on some of our other developers machines Guid is being flag as "isReferenceType" which breaks the code generation. I've spent a decent bit of time digging and it appears that somehow on their machines the resulting compilation LanguageVersion is set to CSharp11 while on mine it is CSharp7_3. I suspect the handling of types (in particular nullable reference types) changed in Rosyln across those versions.

I found WithParseOptions(new CSharpParseOptions(LanguageVersion.CSharp7_3)) but haven't figured out a straightforward (or working) way to set it in the code flow below.

            ICollection<Task<Project>> projectAnalyzers = new List<Task<Project>>();
            var workspace = manager.GetWorkspace();

            foreach (var projectPath in projectPaths)
            {
                projectAnalyzers.Add(Task.Run(() => manager.GetProject(projectPath).AddToWorkspace(workspace)));
            }

            Task.WaitAll(projectAnalyzers.ToArray());

            // Make sure to load the "highest" project, in this case the API which depends on all the 
            // other relevant projects
            var project = workspace.CurrentSolution.Projects.First(x => x.Name.Contains("ProjectWithTargetFramework 4.8"));

            Console.WriteLine("Building/Compiling projects");
            var compilation = await project.GetCompilationAsync();

Metadata

Assignees

No one assigned

    Labels

    Feedback NeededFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions