public async Task TestUpdateCSharpLanguageVersionAsync() { using var ws = new AdhocWorkspace(); var projid = ws.AddProject("TestProject", LanguageNames.CSharp).Id; var docid1 = ws.AddDocument(projid, "A.cs", SourceText.From("public class A { }")).Id; var docid2 = ws.AddDocument(projid, "B.cs", SourceText.From("public class B { }")).Id; var pws = new WorkspaceWithPartialSemantics(ws.CurrentSolution); var proj = pws.CurrentSolution.GetProject(projid); var comp = await proj.GetCompilationAsync(); // change language version var parseOptions = proj.ParseOptions as CS.CSharpParseOptions; pws.SetParseOptions(projid, parseOptions.WithLanguageVersion(CS.LanguageVersion.CSharp3)); // get partial semantics doc var frozen = pws.CurrentSolution.GetDocument(docid1).WithFrozenPartialSemantics(CancellationToken.None); }
public async Task TestUpdateCSharpLanguageVersionAsync() { using (var ws = new AdhocWorkspace()) { var projid = ws.AddProject("TestProject", LanguageNames.CSharp).Id; var docid1 = ws.AddDocument(projid, "A.cs", SourceText.From("public class A { }")).Id; var docid2 = ws.AddDocument(projid, "B.cs", SourceText.From("public class B { }")).Id; var pws = new WorkspaceWithPartialSemantics(ws.CurrentSolution); var proj = pws.CurrentSolution.GetProject(projid); var comp = await proj.GetCompilationAsync(); // change language version var parseOptions = proj.ParseOptions as CS.CSharpParseOptions; pws.SetParseOptions(projid, parseOptions.WithLanguageVersion(CS.LanguageVersion.CSharp3)); // get partial semantics doc var frozen = await pws.CurrentSolution.GetDocument(docid1).WithFrozenPartialSemanticsAsync(CancellationToken.None); } }