diff --git a/src/Compilers/VisualBasic/Portable/PredefinedPreprocessorSymbols.vb b/src/Compilers/VisualBasic/Portable/PredefinedPreprocessorSymbols.vb index 802b0d2f80b4af7a193065c1538c43096c92fc21..db4fa549a2d2d65ccf02d6f123312629ee833b79 100644 --- a/src/Compilers/VisualBasic/Portable/PredefinedPreprocessorSymbols.vb +++ b/src/Compilers/VisualBasic/Portable/PredefinedPreprocessorSymbols.vb @@ -1,11 +1,16 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. Imports System.Collections.Immutable +Imports System.Globalization Namespace Microsoft.CodeAnalysis.VisualBasic Public Module PredefinedPreprocessorSymbols - Friend ReadOnly CurrentVersionNumber As Double = Double.Parse(LanguageVersion.Latest.MapSpecifiedToEffectiveVersion().GetErrorName()) + Friend ReadOnly Property CurrentVersionNumber As Double + Get + Return Double.Parse(LanguageVersion.Latest.MapSpecifiedToEffectiveVersion().GetErrorName(), CultureInfo.InvariantCulture) + End Get + End Property ''' ''' Adds predefined preprocessor symbols VBC_VER and TARGET to given list of preprocessor symbols if not included yet. diff --git a/src/Compilers/VisualBasic/Test/Syntax/Parser/VisualBasicParseOptionsTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Parser/VisualBasicParseOptionsTests.vb index e9e9faffe754a857f7a58fb1ec4c602032dcec9c..d3ed77793ac521b448cd2eb64b6323877af22e1c 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Parser/VisualBasicParseOptionsTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Parser/VisualBasicParseOptionsTests.vb @@ -1,6 +1,7 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. Imports System.Collections.Immutable +Imports System.Globalization Imports System.Linq Imports Roslyn.Test.Utilities @@ -84,7 +85,22 @@ Public Class VisualBasicParseOptionsTests Max(). ToDisplayString() - Assert.Equal(highest, PredefinedPreprocessorSymbols.CurrentVersionNumber.ToString()) + Assert.Equal(highest, PredefinedPreprocessorSymbols.CurrentVersionNumber.ToString(CultureInfo.InvariantCulture)) + End Sub + + + Public Sub CurrentVersionNumberIsCultureIndependent() + Dim currentCulture = CultureInfo.CurrentCulture + Try + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture + Dim invariantCultureVersion = PredefinedPreprocessorSymbols.CurrentVersionNumber + ' cs-CZ uses decimal comma, which can cause issues + CultureInfo.CurrentCulture = New CultureInfo("cs-CZ") + Dim czechCultureVersion = PredefinedPreprocessorSymbols.CurrentVersionNumber + Assert.Equal(invariantCultureVersion, czechCultureVersion) + Finally + CultureInfo.CurrentCulture = currentCulture + End Try End Sub