From 2c5cf568dbf57c7a56a6d137d362f0035b879852 Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Mon, 13 Mar 2017 15:57:32 -0700 Subject: [PATCH] Fix spacing, static reference on instance instead of type, throw if no IParseOptionsService --- src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs | 6 +++--- src/Compilers/Core/Portable/Compilation/Compilation.cs | 2 -- src/Compilers/VisualBasic/Portable/LanguageVersion.vb | 2 -- .../VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb | 6 +++--- .../ProjectSystem/VisualStudioWorkspaceImpl.cs | 5 +---- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs index a2e3734143f81..f7387c4b2a074 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs @@ -9220,9 +9220,9 @@ static void Main() Diagnostic(ErrorCode.ERR_InvalidMemberDecl, "}").WithArguments("}").WithLocation(8, 36) ); - Assert.Equal("7", comp.GetRequiredLanguageVersion(comp.GetDiagnostics()[0])); - Assert.Null(comp.GetRequiredLanguageVersion(comp.GetDiagnostics()[2])); - Assert.Throws(() => comp.GetRequiredLanguageVersion(null)); + Assert.Equal("7", Compilation.GetRequiredLanguageVersion(comp.GetDiagnostics()[0])); + Assert.Null(Compilation.GetRequiredLanguageVersion(comp.GetDiagnostics()[2])); + Assert.Throws(() => Compilation.GetRequiredLanguageVersion(null)); } [Fact] diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index 0e3ee40654f02..c270b6573f891 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -2832,7 +2832,5 @@ public static string GetRequiredLanguageVersion(Diagnostic diagnostic) return foundVersion; } - - } } \ No newline at end of file diff --git a/src/Compilers/VisualBasic/Portable/LanguageVersion.vb b/src/Compilers/VisualBasic/Portable/LanguageVersion.vb index 64e6a42862715..8fcfc4f1848e7 100644 --- a/src/Compilers/VisualBasic/Portable/LanguageVersion.vb +++ b/src/Compilers/VisualBasic/Portable/LanguageVersion.vb @@ -79,7 +79,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ''' Public Function ToDisplayString(version As LanguageVersion) As String - Select Case version Case LanguageVersion.VisualBasic9 Return "9" @@ -102,7 +101,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Select End Function - ''' ''' Parse a LanguageVersion from a string input, as the command-line compiler does. ''' diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb index a9f1978ba8f58..e88b9998af2a1 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenTuples.vb @@ -13608,9 +13608,9 @@ BC30086: 'Else' must be preceded by a matching 'If' or 'ElseIf'. ~~~~ ) Dim x = comp.GetDiagnostics() - Assert.Equal("15", comp.GetRequiredLanguageVersion(comp.GetDiagnostics()(0))) - Assert.Null(comp.GetRequiredLanguageVersion(comp.GetDiagnostics()(2))) - Assert.Throws(Of ArgumentNullException)(Sub() comp.GetRequiredLanguageVersion(Nothing)) + Assert.Equal("15", Compilation.GetRequiredLanguageVersion(comp.GetDiagnostics()(0))) + Assert.Null(Compilation.GetRequiredLanguageVersion(comp.GetDiagnostics()(2))) + Assert.Throws(Of ArgumentNullException)(Sub() Compilation.GetRequiredLanguageVersion(Nothing)) End Sub diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs index 54736c8382e5a..b01e8e4986660 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs @@ -300,10 +300,7 @@ protected override void ApplyParseOptionsChanged(ProjectId projectId, ParseOptio } var parseOptionsService = CurrentSolution.GetProject(projectId).LanguageServices.GetService(); - if (parseOptionsService == null) - { - return; - } + Contract.ThrowIfNull(parseOptionsService, nameof(parseOptionsService)); string newVersion = parseOptionsService.GetLanguageVersion(options);