Open marcospgp opened 2 years ago
This error is coming from Roslynator which is en external component you must have installed, not part of this extension, which looks like is broken here.
Find the file ~/.omnisharp/omnisharp.json and remove all references to Roslynator from there.
@filipw Thanks for addressing this! I have not found a .omnisharp.json
file in the .omnisharp
folder though - the folder appears to be empty 😢
Edit: Oh, is this the configuration file for omnisharp? I have one in the project root which looks like this:
{
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"LocationPaths": [
"./nuget-manually-downloaded-packages/microsoft.codeanalysis.netanalyzers.6.0.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/microsoft.unity.analyzers.1.12.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/roslynator.analyzers.3.2.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/roslynator.formatting.analyzers.1.2.1/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/stylecop.analyzers.1.1.118/analyzers/dotnet/cs"
]
}
}
Removing all of the entries in LocationPaths
fixed the issue, but I do want to keep using these analyzers 😕
Was there an update to how Omnisharp handles Roslynator analyzers?
Edit 2: I confirmed that the issue only occurs when any of the two Roslynator entries are present:
"./nuget-manually-downloaded-packages/roslynator.analyzers.3.2.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/roslynator.formatting.analyzers.1.2.1/analyzers/dotnet/cs",
I tried updating them to the latest version, resulting in this new .omnisharp.json
file:
{
"RoslynExtensionsOptions": {
"EnableAnalyzersSupport": true,
"LocationPaths": [
"./nuget-manually-downloaded-packages/microsoft.codeanalysis.netanalyzers.6.0.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/microsoft.unity.analyzers.1.12.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/roslynator.analyzers.4.1.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/roslynator.formatting.analyzers.4.1.0/analyzers/dotnet/cs",
"./nuget-manually-downloaded-packages/stylecop.analyzers.1.1.118/analyzers/dotnet/cs"
]
}
}
But the issue still occurs:
System.TypeLoadException: Could not load type of field 'Roslynator.Host.Mef.MefHostServices:_compositionContext' (2) due to: Could not load file or assembly 'System.Composition.Runtime, Version=1.0.31.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
Edit 3: This seems to be the same issue as https://github.com/OmniSharp/omnisharp-vscode/issues/5147. I have use global mono set to always
and use modern net set to false
.
The final answer on that issue does not seem correct:
I believe the Roslynator extension manipulates omnisharp.json on install to inject its assemblies into the OminSharp extensions to be loaded, and even when you remove Roslynator, the file would stay modified. But yeah this is external dependency issue in this case.
If this were a Roslynator issue, it wouldn't show up for me as I am using a fixed version of the analyzers, which I only now updated manually. The analyzers worked before and did not change, so this means something else must have changed - likely Omnisharp, unless it could be a Unity VSCode package change?
Edit 4: Managed to trace the issue down to the update of VSCode's C# extension from 1.24.1 to 1.24.2. Rolling back to 1.24.1 fixes the issue, while updating to 1.24.2 reintroduces it. This update is where Omnisharp was updated from 1.38.1 to 1.38.2.
Issue Description
I'm using VSCode with Unity. Everything had been working properly for a long time, but today getting back to the project Omnisharp is not starting correctly. I believe a recent update to VSCode, Unity's VSCode package, or Omnisharp itself may be the culprit.
I have tried downgrading Unity's VSCode package, doing a clean install of VSCode (including deleting
.vscode
folder), and a clean install of Mono, to no avail.I am grateful for any help in figuring this out!
Steps to Reproduce
Open VSCode
Expected Behavior
Omnisharp starts
Actual Behavior
Omnisharp no starts
Logs
OmniSharp log
C# log
(Empty)
Environment information
VSCode version: 1.66.1 C# Extension: 1.24.3
Mono Information
OmniSharp using global mono :6.12.0Dotnet Information
.NET SDK (reflecting any global.json): Version: 6.0.201 Commit: ef40e6aa06 Runtime Environment: OS Name: Mac OS X OS Version: 12.1 OS Platform: Darwin RID: osx.12-x64 Base Path: /usr/local/share/dotnet/sdk/6.0.201/ Host (useful for support): Version: 6.0.3 Commit: c24d9a9c91 .NET SDKs installed: 5.0.302 [/usr/local/share/dotnet/sdk] 6.0.201 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |csharp|ms-dotnettools|1.24.3|;