Skip to content

Commit

Permalink
Merge pull request #1103 from filipw/feature/script-SupersedeLowerVer…
Browse files Browse the repository at this point in the history
…sions

Feature/script supersede lower versions
  • Loading branch information
filipw authored Feb 13, 2018
2 parents 11e72a5 + 985ac92 commit 26c5dce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog
All changes to the project will be documented in this file.

## [1.29.1] - Not Yet Released
## [1.30.0] - not yet released
* Ensure that the lower assembly versions are always superseded in C# scripts (PR: [#1103](https://github.com/OmniSharp/omnisharp-roslyn/pull/1103))
* Fixed duplicate diagnostics in C# ([omnisharp-vscode#1830](https://github.com/OmniSharp/omnisharp-vscode/issues/1830), PR: [#1107](https://github.com/OmniSharp/omnisharp-roslyn/pull/1107))

## [1.29.0] - 2018-1-29
Expand Down
6 changes: 6 additions & 0 deletions src/OmniSharp.Script/ScriptHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ScriptHelper
{
private const string BinderFlagsType = "Microsoft.CodeAnalysis.CSharp.BinderFlags";
private const string TopLevelBinderFlagsProperty = "TopLevelBinderFlags";
private const string ReferencesSupersedeLowerVersionsProperty = "ReferencesSupersedeLowerVersions_internal_protected_set";
private const string IgnoreCorLibraryDuplicatedTypesField = "IgnoreCorLibraryDuplicatedTypes";
private const string RuntimeMetadataReferenceResolverType = "Microsoft.CodeAnalysis.Scripting.Hosting.RuntimeMetadataReferenceResolver";
private const string ResolverField = "_resolver";
Expand Down Expand Up @@ -73,6 +74,11 @@ private CSharpCompilationOptions CreateCompilationOptions()
topLevelBinderFlagsProperty?.SetValue(compilationOptions, ignoreCorLibraryDuplicatedTypesValue);
}

// in scripts, the option to supersede lower versions is ALWAYS enabled
// see: https://github.com/dotnet/roslyn/blob/version-2.6.0-beta3/src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs#L199
var referencesSupersedeLowerVersionsProperty = typeof(CompilationOptions).GetProperty(ReferencesSupersedeLowerVersionsProperty, BindingFlags.Instance | BindingFlags.NonPublic);
referencesSupersedeLowerVersionsProperty?.SetValue(compilationOptions, true);

return compilationOptions;
}

Expand Down

0 comments on commit 26c5dce

Please sign in to comment.