Skip to content

Commit

Permalink
Merge pull request #1621 from filipw/bugfix/suppressions
Browse files Browse the repository at this point in the history
fixed default diagnostic suppressions for script project system
  • Loading branch information
filipw authored Oct 8, 2019
2 parents b010270 + 4d2ba41 commit 1027f85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/OmniSharp.Roslyn/Utilities/CompilationOptionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,21 @@ public static ImmutableDictionary<string, ReportDiagnostic> GetDefaultSuppressed

return suppressedDiagnostics.ToImmutableDictionary();
}

public static ImmutableDictionary<string, ReportDiagnostic> GetDefaultSuppressedDiagnosticOptions(Dictionary<string, ReportDiagnostic> otherDiagnostics)
{
if (otherDiagnostics == null || !otherDiagnostics.Any()) return GetDefaultSuppressedDiagnosticOptions();

var combinedDiagnostics = GetDefaultSuppressedDiagnosticOptions();
foreach (var diagnostic in otherDiagnostics)
{
if (!combinedDiagnostics.ContainsKey(diagnostic.Key))
{
combinedDiagnostics.Add(diagnostic.Key, diagnostic.Value);
}
}

return combinedDiagnostics.ToImmutableDictionary();
}
}
}
9 changes: 3 additions & 6 deletions src/OmniSharp.Script/ScriptProjectProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ private CSharpCompilationOptions CreateCompilationOptions()
.WithMetadataReferenceResolver(CreateMetadataReferenceResolver())
.WithSourceReferenceResolver(ScriptSourceResolver.Default)
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
.WithSpecificDiagnosticOptions(CompilationOptionsHelper.GetDefaultSuppressedDiagnosticOptions());

if (_scriptOptions.IsNugetEnabled())
{
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(_scriptOptions.NullableDiagnostics);
}
.WithSpecificDiagnosticOptions(!_scriptOptions.IsNugetEnabled()
? CompilationOptionsHelper.GetDefaultSuppressedDiagnosticOptions()
: CompilationOptionsHelper.GetDefaultSuppressedDiagnosticOptions(_scriptOptions.NullableDiagnostics)); // for .NET Core 3.0 dotnet-script use extra nullable diagnostics

var topLevelBinderFlagsProperty = typeof(CSharpCompilationOptions).GetProperty(TopLevelBinderFlagsProperty, BindingFlags.Instance | BindingFlags.NonPublic);
var binderFlagsType = typeof(CSharpCompilationOptions).GetTypeInfo().Assembly.GetType(BinderFlagsType);
Expand Down

0 comments on commit 1027f85

Please sign in to comment.