After a bit of struggle, I understood that for the compilation of custom code, there is a big difference between references to “Runtime assemblies” and “Reference assemblies” ( https://learn.microsoft.com/en-us/dotnet/standard/assembly/reference-assemblies ).
So, just a small question: do you automatically add any references to framework dlls to a RoslynSolution? Or is the RoslynSolution really blank, and even the most basic assemblies (which contain e.g. “System.Object”) have to be added by myself?
Yes, we do add default references in the
RoslynSolution.WithDefaultAssemblies method. This method is called automatically when the default Roslyn project is initialized after the first document is added to the solution (e.g. when the first file in the editor is parsed).
The set of default assemblies added depends on whether the host application is running under .NET Framework or .NET Core.
Thanks, digging through your code, you seem to use reference assemblies already (DotNetCoreDefaultAssembliesProvider.GetDefaultAssemblies and ApiAssembliesResolver.TryResolveApiAssemblyPath with default parameter “useRuntimeAssemblies”).
So, it seems my comprehension of the “reference assemblies” problem was correct, as you do something similar to my approach