Vscode-powershell: [cultureinfo]::CurrentCulture is Read-Only in the Powershell Integrated Console

Created on 20 Feb 2019  路  5Comments  路  Source: PowerShell/vscode-powershell

Issue Type: Bug

In the Powershell Integrated Console of VS Code

PowerShell Integrated Console

PS C:\> 1.23
1,23
PS C:\EDI> [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator = "."
Exception setting "NumberDecimalSeparator": "L'instance est en lecture seule."
At line:1 char:1
+ [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator = " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

PS C:\> 1.23
1,23

In a normal Windows Powershell console

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS C:\EDI> 1.23
1,23
PS C:\EDI> [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator = "."
PS C:\EDI> 1.23
1.23

Extension version: 1.11.0
VS Code version: Code 1.31.1 (1b8e8302e405050205e69b59abb3559592bb9e60, 2019-02-12T02:20:54.427Z)
OS version: Windows_NT x64 6.1.7601


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz (4 x 2400)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled|
|Memory (System)|7.88GB (2.09GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|


Area-Integrated Console Issue-Bug

Most helpful comment

@SydneyhSmith, I have installed PowerShell Preview Extension but still get the same error in the PowerShell Integrated Console

PowerShell Integrated Console

PS C:\> [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="."
Exception setting "NumberDecimalSeparator": "L'instance est en lecture seule."
At line:1 char:1
+ [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\>

Extensions (8)

Extension|Author (truncated)|Version
---|---|---
overtype|ada|0.2.0
vscode-edifact|DAX|0.5.1
xml|Dot|2.4.0
gitlens|eam|9.5.1
reg|ion|0.0.2
mssql|ms-|1.4.0
PowerShell-Preview|ms-|2.0.0
vsc-jsonsnippets|wmo|0.1.4

All 5 comments

@AlexBillon07 thanks for reporting this--I can reproduce this in the PowerShell extension. This feature is available in the PowerShell Preview Extension which you may want to give a look to and see if it meets your needs. Thanks!

@SydneyhSmith, I have installed PowerShell Preview Extension but still get the same error in the PowerShell Integrated Console

PowerShell Integrated Console

PS C:\> [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="."
Exception setting "NumberDecimalSeparator": "L'instance est en lecture seule."
At line:1 char:1
+ [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\>

Extensions (8)

Extension|Author (truncated)|Version
---|---|---
overtype|ada|0.2.0
vscode-edifact|DAX|0.5.1
xml|Dot|2.4.0
gitlens|eam|9.5.1
reg|ion|0.0.2
mssql|ms-|1.4.0
PowerShell-Preview|ms-|2.0.0
vsc-jsonsnippets|wmo|0.1.4

Setting [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="." works in Powershell [cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="." but for Powershell 7 it is a read-only property.

[cultureinfo]::CurrentCulture.NumberFormat.NumberDecimalSeparator="." but for Powershell 7 it is a read-only property.

Looks like this is true in the ordinary PowerShell console as well and is likely to be a .NET Core change, meaning it's something that the extension should not seek to fix

Thanks for looking into it @BjornNordblom!

Was this page helpful?
0 / 5 - 0 ratings