Closed svick closed 3 years ago
What an interesting side effect of local functions! I guess because they're "lifted" into separate methods? In any case, I've hit the merge button and am planning a release within the next day or two once I clear the remaining PR backlog. Thanks for the contribution, and sorry for the delay!
I guess because they're "lifted" into separate methods?
Yes, exactly. Using regular methods would achieve the same effect, but I thought local functions were more appropriate here.
I want to use Buildalyzer.Workspaces, but without referencing Microsoft.CodeAnalysis.VisualBasic.Workspaces (because I have a custom build of Microsoft.CodeAnalysis.CSharp.Worspaces). When I try to do that, I get the following exception:
This happens because of the following code in
CreateCompilationOptions
(and similar, but longer code inCreateParseOptions
):https://github.com/daveaglick/Buildalyzer/blob/da88770a2952f7894c05cd0866ef9d766f78aaea/src/Buildalyzer.Workspaces/AnalyzerResultExtensions.cs#L192-L200
This means that JIT compiling the method requires a reference to Microsoft.CodeAnalysis.VisualBasic, even if I only ever want to create C# options.
Extracting the language-specific code into a local function seems to fix this issue.