提交 058e6edd 编写于 作者: J Jared Parsons 提交者: GitHub

Merge pull request #21095 from svick/vbc-culture

Fix vbc on non-English cultures
' 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
''' <summary>
''' Adds predefined preprocessor symbols VBC_VER and TARGET to given list of preprocessor symbols if not included yet.
......
' 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
<Fact, WorkItem(21094, "https://github.com/dotnet/roslyn/issues/21094")>
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
<Fact>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册