Tudvari
Tudvari

Reputation: 2905

Can't exclude folders for VS Code OmniSharp's Code Analyser

I use VS Code with Unity and I'm trying to ignore the code analysis of third party code bases.

I've read OmniSharp's github page, and tried excluding those folders but I failed to do so. What I did was:

I've created an omnisharp.json file where the .csproj files are, with this content:

{
    "fileOptions": {
        "excludeSearchPatterns": [
            "Assets/ThirdPartyFolder/**/*"
        ]
    }
}

I've also tried using systemExcludeSearchPatterns instead of excludeSearchPatterns but to no avail.

(And also tried adding the "/**/*" path for fun, but still everything was analyzed. :\ )

I always restarted OmniSharp after changing the json file:

enter image description here

But the "want-to-be-excluded folders" are still analyzed.

Like after I added "Assets/AltUnityTester/**/*":

enter image description here

Upvotes: 4

Views: 1581

Answers (1)

bene
bene

Reputation: 21

Create .editorconfig file in your project root folder with the following content:

root = true

[Assets/Assetstore/**.cs]
generated_code = true
dotnet_analyzer_diagnostic.severity = none

[Assets/Plugins/**.cs]
generated_code = true
dotnet_analyzer_diagnostic.severity = none

My omnisharp.json located in the project root folder:

{
    "RoslynExtensionsOptions": {
        "EnableEditorConfigSupport": true,
        "EnableAnalyzersSupport": true,
        "LocationPaths": [
            "./NuGet/microsoft.unity.analyzers.1.12.0"
        ]
    }
}

This solution works for me. See Enabling Unity warnings.

C# for Visual Studio Code: v1.24.1

Upvotes: 2

Related Questions