From 99fd81ccaf472fdcacf60a0d7ff6f0c3cfcecbc4 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 10 Dec 2024 22:07:08 -0800 Subject: [PATCH 01/45] Update the test model --- .../VisualBasicUnifiedSettingsTests.vb | 32 +++++++++++++------ ...io.LanguageServices.Test.Utilities2.vbproj | 7 ++-- .../TestModels/AlternateDefault.vb | 15 +++++++++ .../TestModels/EnumIntegerToString.vb | 13 ++++++++ .../UnifiedSettings/TestModels/Input.vb | 14 ++++++++ .../UnifiedSettings/TestModels/Map.vb | 14 ++++++++ .../UnifiedSettings/TestModels/Migration.vb | 12 +++++++ .../TestModels/MigrationType.vb | 12 +++++++ .../UnifiedSettings/TestModels/Pass.vb | 9 ++++++ .../TestModels/UnifiedSettingOption.vb | 31 ++++++++++++++++++ .../TestModels/UnifiedSettingsEnumOption.vb | 16 ++++++++++ 11 files changed, 163 insertions(+), 12 deletions(-) create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 7f42c3704baf2..bb0783174a847 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -5,11 +5,13 @@ Imports System.Collections.Immutable Imports System.IO Imports System.Reflection +Imports System.Text.Json Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings +Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Imports Newtonsoft.Json.Linq Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings @@ -79,16 +81,26 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - Using reader = New StreamReader(registrationFileStream) - Dim registrationFile = Await reader.ReadToEndAsync().ConfigureAwait(False) - Dim pkgDefFile = Await pkgDefFileReader.ReadToEndAsync().ConfigureAwait(False) - Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings()) - Dim categoriesTitle = registrationJsonObject.SelectToken("$.categories['textEditor.basic'].title") - Assert.Equal("Visual Basic", categoriesTitle) - Dim optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.basic.intellisense'].legacyOptionPageId") - Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, optionPageId.ToString()) - TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath:="textEditor.basic.intellisense", languageName:=LanguageNames.VisualBasic, pkgDefFile) - End Using + Dim pkgDefFile = Await pkgDefFileReader.ReadToEndAsync().ConfigureAwait(False) + Dim parseOption = New JsonDocumentOptions() With { + .CommentHandling = JsonCommentHandling.Skip + } + Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) + Dim properties = registrationDocument.RootElement.GetProperty("properties") + Assert.NotNull(properties) + For Each setting In properties.EnumerateObject + Dim unifiedSettingsName = setting.Name + Dim actualOption = setting.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean)) + Dim l = 6 + + Next + + 'Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings()) + 'Dim categoriesTitle = registrationJsonObject.SelectToken("$.categories['textEditor.basic'].title") + 'Assert.Equal("Visual Basic", categoriesTitle) + 'Dim optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.basic.intellisense'].legacyOptionPageId") + 'Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, optionPageId.ToString()) + 'TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath:="textEditor.basic.intellisense", languageName:=LanguageNames.VisualBasic, pkgDefFile) End Using End Using End Using diff --git a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj index fe756c77e4fdb..268ad247154de 100644 --- a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj +++ b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj @@ -43,7 +43,7 @@ - + @@ -52,13 +52,16 @@ - + + + + diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb new file mode 100644 index 0000000000000..c0e19eecf4a57 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -0,0 +1,15 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class AlternateDefault + + Public Property FlagName As String + + + Public Property [Default] As String + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb new file mode 100644 index 0000000000000..eda597a6a789a --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb @@ -0,0 +1,13 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class EnumIntegerToString + Inherits MigrationType + + Public Property Map() As Map + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb new file mode 100644 index 0000000000000..5d19d31c75c78 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -0,0 +1,14 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class Input + + Public Property Store As String + + Public Property Path As String + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb new file mode 100644 index 0000000000000..d10173fab1c83 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb @@ -0,0 +1,14 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class Map + + Public Property Result As String + + Public Property Match As Integer + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb new file mode 100644 index 0000000000000..a8e982cf974ce --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb @@ -0,0 +1,12 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class Migration + + Public Property Pass As Pass + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb new file mode 100644 index 0000000000000..f081acef563d6 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb @@ -0,0 +1,12 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class MigrationType + + Public Property Input As Input + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb new file mode 100644 index 0000000000000..246552f77b262 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb @@ -0,0 +1,9 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class Pass + Inherits MigrationType + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb new file mode 100644 index 0000000000000..b0a2429acd9d4 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb @@ -0,0 +1,31 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + + Public Class UnifiedSettingsOption(Of T) + + Public Property Title As String + + + Public Property Type As String + + + Public Property [Default] As T + + + Public Property AlternateDefault As AlternateDefault + + + Public Property Order As Integer + + + Public Property EnableWhen As String + + + Public Property Migration As Migration + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb new file mode 100644 index 0000000000000..22affafbde145 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb @@ -0,0 +1,16 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class UnifiedSettingsEnumOption + Inherits UnifiedSettingsOption(Of String) + + Public Property [Enum] As String() + + + Public Property EnumLabels As String() + End Class +End Namespace From 52dce403bc490fed157e9130fe2c71173e5d57d8 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 10 Dec 2024 22:14:12 -0800 Subject: [PATCH 02/45] Add category model --- .../TestModels/UnifiedSettingsCategory.vb | 16 ++++++++++++++++ ...SettingOption.vb => UnifiedSettingsOption.vb} | 0 2 files changed, 16 insertions(+) create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb rename src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/{UnifiedSettingOption.vb => UnifiedSettingsOption.vb} (100%) diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb new file mode 100644 index 0000000000000..47e3c0ca285c7 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb @@ -0,0 +1,16 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports Newtonsoft.Json + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Public Class UnifiedSettingsCategory + + Public Property Title As String + + + Public Property LegacyOptionPageId As String + + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb similarity index 100% rename from src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingOption.vb rename to src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb From 8be183121935c34b24425131877651a815f29e41 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 10 Dec 2024 22:27:07 -0800 Subject: [PATCH 03/45] Add test --- .../VisualBasicUnifiedSettingsTests.vb | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index bb0783174a847..1182a95f004c8 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -76,6 +76,24 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Return MyBase.GetOptionsDefaultValue([option]) End Function + + Public Async Function CategoriesTest() As Task + Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") + Dim parseOption = New JsonDocumentOptions() With { + .CommentHandling = JsonCommentHandling.Skip + } + Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) + Dim categories = registrationDocument.RootElement.GetProperty("categories") + + 'Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings()) + 'Dim categoriesTitle = registrationJsonObject.SelectToken("$.categories['textEditor.basic'].title") + 'Assert.Equal("Visual Basic", categoriesTitle) + 'Dim optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.basic.intellisense'].legacyOptionPageId") + 'Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, optionPageId.ToString()) + 'TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath:="textEditor.basic.intellisense", languageName:=LanguageNames.VisualBasic, pkgDefFile) + End Using + End Function + Public Async Function IntelliSensePageTests() As Task Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") @@ -87,11 +105,11 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings } Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) Dim properties = registrationDocument.RootElement.GetProperty("properties") + Assert.NotNull(properties) For Each setting In properties.EnumerateObject Dim unifiedSettingsName = setting.Name Dim actualOption = setting.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean)) - Dim l = 6 Next From 298cad6eb22e285ef6e79e8cbc2caa59ac496415 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Wed, 11 Dec 2024 11:15:26 -0800 Subject: [PATCH 04/45] Add details --- .../VisualBasicUnifiedSettingsTests.vb | 15 ++++++++------- .../TestModels/UnifiedSettingsCategory.vb | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 1182a95f004c8..33da29b3ed952 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -84,18 +84,19 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings } Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) Dim categories = registrationDocument.RootElement.GetProperty("categories") + Dim nameToCategories = categories.EnumerateObject.ToDictionary( + Function(kvp) kvp.Name, + Function(kvp) kvp.Value.Deserialize(Of UnifiedSettingsCategory)) - 'Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings()) - 'Dim categoriesTitle = registrationJsonObject.SelectToken("$.categories['textEditor.basic'].title") - 'Assert.Equal("Visual Basic", categoriesTitle) - 'Dim optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.basic.intellisense'].legacyOptionPageId") - 'Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, optionPageId.ToString()) - 'TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath:="textEditor.basic.intellisense", languageName:=LanguageNames.VisualBasic, pkgDefFile) + Assert.True(nameToCategories.ContainsKey("textEditor.basic")) + Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) + + Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) End Using End Function - Public Async Function IntelliSensePageTests() As Task + Public Async Function IntelliSensePageTest() As Task Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") Using pkgDefFileReader = New StreamReader(pkgDefFileStream) diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb index 47e3c0ca285c7..ea8f3facfbec5 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb @@ -2,14 +2,14 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Newtonsoft.Json +Imports System.Text.Json.Serialization Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Public Class UnifiedSettingsCategory - + Public Property Title As String - + Public Property LegacyOptionPageId As String End Class From ccf186476fd79ff8d9564e702fc973e0218166a1 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Wed, 11 Dec 2024 18:20:47 -0800 Subject: [PATCH 05/45] Add CategoriesTest --- ...isualStudio.LanguageServices.CSharp.csproj | 2 +- .../VisualBasicUnifiedSettingsTests.vb | 3 +- .../UnifiedSettings/UnifiedSettingsTests.vb | 48 +++++++++++++++++++ ...Studio.LanguageServices.VisualBasic.vbproj | 2 +- .../visualBasicSettings.registration.json | 2 +- 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj b/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj index 6ff52d800af00..150726d55eeae 100644 --- a/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj +++ b/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj @@ -54,7 +54,7 @@ - + true VSPackage Designer diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 33da29b3ed952..874c902c148c8 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -89,9 +89,10 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Function(kvp) kvp.Value.Deserialize(Of UnifiedSettingsCategory)) Assert.True(nameToCategories.ContainsKey("textEditor.basic")) - Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) + Assert.Equal("Visual Basic", EvalResource(nameToCategories("textEditor.basic").Title)) Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) + Assert.Equal("IntelliSense", EvalResource(nameToCategories("textEditor.basic.intellisense").Title)) End Using End Function diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb index ecf8ba700f9bf..adf92a5dbb485 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb @@ -3,13 +3,16 @@ ' See the LICENSE file in the project root for more information. Imports System.Collections.Immutable +Imports System.Globalization Imports System.IO.Hashing Imports System.Text Imports System.Text.RegularExpressions Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Options +Imports Microsoft.VisualStudio.LanguageServices.CSharp Imports Microsoft.VisualStudio.LanguageServices.Options Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage +Imports Microsoft.VisualStudio.LanguageServices.VisualBasic Imports Newtonsoft.Json.Linq Imports Roslyn.Test.Utilities Imports Roslyn.Utilities @@ -224,5 +227,50 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings Assert.NotEqual(-1, indexOfTheDefaultMapping) Assert.True(indexOfTheRealDefaultMapping < indexOfTheDefaultMapping) End Sub + + Private Const CSharpLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.CSharp.dll" + + Private Const VisualBasicLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" + + Private Const LanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.dll" + + Protected Shared Function EvalResource(resourceReference As String) As String + ' Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters + Dim resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1) + Dim resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1) + Dim resourceDll As String = Nothing + ' We reference the string in two ways + ' 1. "@102;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" where the guid is the package guid. It is the recommended way to locate string. + ' 2. "@Analysis;..\\Microsoft.VisualStudio.LanguageServices.dll". It is a special way we asked to locate string + Dim localizedString As String = Nothing + Dim culture = New CultureInfo("en") + Dim packageGuid As Guid = Nothing + If Guid.TryParse(resources, packageGuid) Then + If packageGuid = Guids.CSharpPackageId Then + Return CSharp.VSPackage.ResourceManager.GetString(resourcesIdentifier) + ElseIf packageGuid = Guids.VisualBasicPackageId Then + Return VisualBasic.VSPackage.ResourceManager.GetString(resourcesIdentifier) + Else + Assert.Fail($"Unexpected package Id: {packageGuid}") + End If + Else + resourceDll = resourceReference.Substring(resourceReference.IndexOf("\\") + 1) + End If + + Select Case resourceDll + Case CSharpLanguageServiceDllName + localizedString = CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case VisualBasicLanguageServiceDllName + localizedString = BasicVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case LanguageServiceDllName + localizedString = ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case Else + Assert.Fail($"Resources should only the fetched from {CSharpLanguageServiceDllName}, {VisualBasicLanguageServiceDllName} or {LanguageServiceDllName}.") + End Select + + Assert.NotNull(localizedString) + Return localizedString + End Function + End Class End Namespace diff --git a/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj b/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj index b94764b606b87..00ff829d6b33c 100644 --- a/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj +++ b/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj @@ -55,7 +55,7 @@ - + true VSPackage Designer diff --git a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json index a9d618f73ad50..cb65151330b6c 100644 --- a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json +++ b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json @@ -175,7 +175,7 @@ }, "categories": { "textEditor.basic":{ - "title": "Visual Basic" + "title": "@101;{574fc912-f74f-4b4e-92c3-f695c208a2bb}" }, "textEditor.basic.intellisense": { "title": "@112;{574fc912-f74f-4b4e-92c3-f695c208a2bb}", From 7d00a4b5fa41d4024991f506c9b3676402f13091 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Wed, 11 Dec 2024 21:59:11 -0800 Subject: [PATCH 06/45] Update alternateDefault --- .../VisualBasicUnifiedSettingsTests.vb | 57 ++++++++++++++----- .../TestModels/AlternateDefault.vb | 4 +- .../TestModels/UnifiedSettingsOption.vb | 2 +- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 874c902c148c8..14f094f30c4bb 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -9,10 +9,8 @@ Imports System.Text.Json Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels -Imports Newtonsoft.Json.Linq Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Public Class VisualBasicUnifiedSettingsTests @@ -33,6 +31,20 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings End Get End Property + Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of (unifiedSettingsPath As String, roslynOption As IOption2, UnifiedSettingsOption)) + Get + Return ImmutableArray.Create(Of (String, IOption2))( + ("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), + ("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), + ("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), + ("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), + ("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), + ("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), + ("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), + ("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) + End Get + End Property + Friend Overrides Function GetEnumOptionValues([option] As IOption2) As Object() Dim allValues = [Enum].GetValues([option].Type).Cast(Of Object) If [option].Equals(CompletionOptionsStorage.SnippetsBehavior) Then @@ -107,23 +119,42 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings } Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) Dim properties = registrationDocument.RootElement.GetProperty("properties") - Assert.NotNull(properties) - For Each setting In properties.EnumerateObject - Dim unifiedSettingsName = setting.Name - Dim actualOption = setting.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean)) - Next + Dim expectedGroupPrefix = "textEditor.basic.intellisense" + Dim actualOptions = properties.EnumerateObject.Where(Function([property]) [property].Name.StartsWith(expectedGroupPrefix)).ToImmutableArray() + Assert.Equal(IntelliSenseOnboardedOptions.Length, actualOptions.Length) + + For Each optionPair In actualOptions.Zip(IntelliSenseOnboardedOptions, Function(actual, expected) (actual, expected)) + Dim expected = optionPair.expected + Dim actualName = optionPair.actual.Name - 'Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings()) - 'Dim categoriesTitle = registrationJsonObject.SelectToken("$.categories['textEditor.basic'].title") - 'Assert.Equal("Visual Basic", categoriesTitle) - 'Dim optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.basic.intellisense'].legacyOptionPageId") - 'Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, optionPageId.ToString()) - 'TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath:="textEditor.basic.intellisense", languageName:=LanguageNames.VisualBasic, pkgDefFile) + Next End Using End Using End Using End Function + + Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) + Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) + Dim expectedOption = expected.roslynOption + Dim type = expectedOption.Type + If type = GetType(Boolean) Then + VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) + ElseIf type.IsEnum Then + VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) + Else + Assert.Fail("We only have enum and boolean option now. Add more if needed") + End If + End Sub + + Private Sub VerifyBooleanOption(roslynOption As IOption2, actualOption As UnifiedSettingsOption(Of Boolean)) + End Sub + + Private Sub VerifyEnumOption(roslynOption As IOption2, actualOption As UnifiedSettingsEnumOption) + End Sub + + Private Sub VerifyTitle() + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb index c0e19eecf4a57..5a91ef83e9f10 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -5,11 +5,11 @@ Imports System.Text.Json.Serialization Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class AlternateDefault + Public Class AlternateDefault(Of T) Public Property FlagName As String - Public Property [Default] As String + Public Property [Default] As T End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb index b0a2429acd9d4..4d0b5ce859a3c 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb @@ -17,7 +17,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Property [Default] As T - Public Property AlternateDefault As AlternateDefault + Public Property AlternateDefault As AlternateDefault(Of T) Public Property Order As Integer From 3849b2ee0eceb9702d23b8fc101e9108e63c8920 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Wed, 11 Dec 2024 22:56:34 -0800 Subject: [PATCH 07/45] Back to newtonsoft.json --- .../VisualBasicUnifiedSettingsTests.vb | 118 ++++++++---------- .../TestModels/AlternateDefault.vb | 8 +- .../TestModels/EnumIntegerToString.vb | 6 +- .../UnifiedSettings/TestModels/Input.vb | 8 +- .../UnifiedSettings/TestModels/Map.vb | 8 +- .../UnifiedSettings/TestModels/Migration.vb | 6 +- .../TestModels/MigrationType.vb | 6 +- .../UnifiedSettings/TestModels/Pass.vb | 2 +- .../TestModels/ResourceConverter.vb | 33 +++++ .../TestModels/UnifiedSettingsCategory.vb | 9 +- .../TestModels/UnifiedSettingsEnumOption.vb | 8 +- .../TestModels/UnifiedSettingsOption.vb | 20 +-- .../UnifiedSettings/TestModels/Utilities.vb | 55 ++++++++ .../UnifiedSettings/UnifiedSettingsTests.vb | 45 ------- 14 files changed, 185 insertions(+), 147 deletions(-) create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 14f094f30c4bb..39bf39254e73e 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -5,12 +5,13 @@ Imports System.Collections.Immutable Imports System.IO Imports System.Reflection -Imports System.Text.Json Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Public Class VisualBasicUnifiedSettingsTests @@ -31,7 +32,7 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings End Get End Property - Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of (unifiedSettingsPath As String, roslynOption As IOption2, UnifiedSettingsOption)) + Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of (unifiedSettingsPath As String, roslynOption As IOption2)) Get Return ImmutableArray.Create(Of (String, IOption2))( ("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), @@ -91,70 +92,61 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Public Async Function CategoriesTest() As Task Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Dim parseOption = New JsonDocumentOptions() With { - .CommentHandling = JsonCommentHandling.Skip - } - Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) - Dim categories = registrationDocument.RootElement.GetProperty("categories") - Dim nameToCategories = categories.EnumerateObject.ToDictionary( - Function(kvp) kvp.Name, - Function(kvp) kvp.Value.Deserialize(Of UnifiedSettingsCategory)) - - Assert.True(nameToCategories.ContainsKey("textEditor.basic")) - Assert.Equal("Visual Basic", EvalResource(nameToCategories("textEditor.basic").Title)) - - Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) - Assert.Equal("IntelliSense", EvalResource(nameToCategories("textEditor.basic.intellisense").Title)) - End Using - End Function - - - Public Async Function IntelliSensePageTest() As Task - Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - Dim pkgDefFile = Await pkgDefFileReader.ReadToEndAsync().ConfigureAwait(False) - Dim parseOption = New JsonDocumentOptions() With { - .CommentHandling = JsonCommentHandling.Skip - } - Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) - Dim properties = registrationDocument.RootElement.GetProperty("properties") - Assert.NotNull(properties) - - Dim expectedGroupPrefix = "textEditor.basic.intellisense" - Dim actualOptions = properties.EnumerateObject.Where(Function([property]) [property].Name.StartsWith(expectedGroupPrefix)).ToImmutableArray() - Assert.Equal(IntelliSenseOnboardedOptions.Length, actualOptions.Length) - - For Each optionPair In actualOptions.Zip(IntelliSenseOnboardedOptions, Function(actual, expected) (actual, expected)) - Dim expected = optionPair.expected - Dim actualName = optionPair.actual.Name - - Next - End Using + Using reader = New StreamReader(registrationFileStream) + Dim registrationFile = Await reader.ReadToEndAsync() + Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) + Dim categories = registrationJsonObject.Property("categories") + Dim nameToCategories = categories.Value.Children(Of JProperty).ToDictionary( + Function(jProperty) jProperty.Name, + Function(jProperty) jProperty.Value.ToObject(Of UnifiedSettingsCategory)) + + Assert.True(nameToCategories.ContainsKey("textEditor.basic")) + Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) + + Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) + Assert.Equal("IntelliSense", nameToCategories("textEditor.basic.intellisense").Title) End Using End Using End Function - Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) - Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) - Dim expectedOption = expected.roslynOption - Dim type = expectedOption.Type - If type = GetType(Boolean) Then - VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) - ElseIf type.IsEnum Then - VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) - Else - Assert.Fail("We only have enum and boolean option now. Add more if needed") - End If - End Sub - - Private Sub VerifyBooleanOption(roslynOption As IOption2, actualOption As UnifiedSettingsOption(Of Boolean)) - End Sub - - Private Sub VerifyEnumOption(roslynOption As IOption2, actualOption As UnifiedSettingsEnumOption) - End Sub - - Private Sub VerifyTitle() - End Sub + ' + 'Public Async Function IntelliSensePageTest() As Task + ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") + ' Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") + ' Using pkgDefFileReader = New StreamReader(pkgDefFileStream) + ' Dim pkgDefFile = Await pkgDefFileReader.ReadToEndAsync().ConfigureAwait(False) + ' Dim parseOption = New JsonDocumentOptions() With { + ' .CommentHandling = JsonCommentHandling.Skip + ' } + ' Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) + ' Dim properties = registrationDocument.RootElement.GetProperty("properties") + ' Assert.NotNull(properties) + + ' Dim expectedGroupPrefix = "textEditor.basic.intellisense" + ' Dim actualOptions = properties.EnumerateObject.Where(Function([property]) [property].Name.StartsWith(expectedGroupPrefix)).ToImmutableArray() + ' Assert.Equal(IntelliSenseOnboardedOptions.Length, actualOptions.Length) + + ' For Each optionPair In actualOptions.Zip(IntelliSenseOnboardedOptions, Function(actual, expected) (actual, expected)) + ' Dim expected = optionPair.expected + ' Dim actualName = optionPair.actual.Name + + ' Next + ' End Using + ' End Using + ' End Using + 'End Function + + 'Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) + ' Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) + ' Dim expectedOption = expected.roslynOption + ' Dim type = expectedOption.Type + ' If type = GetType(Boolean) Then + ' VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) + ' ElseIf type.IsEnum Then + ' VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) + ' Else + ' Assert.Fail("We only have enum and boolean option now. Add more if needed") + ' End If + 'End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb index 5a91ef83e9f10..125fc5f486f07 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -2,14 +2,14 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class AlternateDefault(Of T) - + Friend Class AlternateDefault(Of T) + Public Property FlagName As String - + Public Property [Default] As T End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb index eda597a6a789a..3b0127d281760 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb @@ -2,12 +2,12 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class EnumIntegerToString + Friend Class EnumIntegerToString Inherits MigrationType - + Public Property Map() As Map End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index 5d19d31c75c78..82a91207c6766 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -2,13 +2,13 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class Input - + Friend Class Input + Public Property Store As String - + Public Property Path As String End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb index d10173fab1c83..fab0e93d6455c 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb @@ -2,13 +2,13 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class Map - + Friend Class Map + Public Property Result As String - + Public Property Match As Integer End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb index a8e982cf974ce..db19960cd4945 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb @@ -2,11 +2,11 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class Migration - + Friend Class Migration + Public Property Pass As Pass End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb index f081acef563d6..8aa7aaa82565a 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb @@ -2,11 +2,11 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class MigrationType - + Friend Class MigrationType + Public Property Input As Input End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb index 246552f77b262..b7ffc165bc5ea 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb @@ -3,7 +3,7 @@ ' See the LICENSE file in the project root for more information. Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class Pass + Friend Class Pass Inherits MigrationType End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb new file mode 100644 index 0000000000000..9a2ad7ce394ca --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb @@ -0,0 +1,33 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports Newtonsoft.Json +Imports Newtonsoft.Json.Linq +Imports Roslyn.Utilities + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Friend Class ResourceConverter + Inherits JsonConverter + + Public Overrides Sub WriteJson(writer As JsonWriter, value As Object, serializer As JsonSerializer) + Throw New NotImplementedException() + End Sub + + Public Overrides Function ReadJson(reader As JsonReader, objectType As Type, existingValue As Object, serializer As JsonSerializer) As Object + Dim token = JToken.Load(reader) + If token.Type = JTokenType.String Then + Return EvalResource(token.ToString) + ElseIf token.Type = JTokenType.Array Then + Dim array = token.Values + Return array.Where(Function(arrayElement) arrayElement.Type = JTokenType.String).SelectAsArray(Function(arrayElement) EvalResource(arrayElement.ToString())) + End If + + Throw ExceptionUtilities.UnexpectedValue(token.Type) + End Function + + Public Overrides Function CanConvert(objectType As Type) As Boolean + Return objectType = GetType(String) OrElse objectType = GetType(String()) + End Function + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb index ea8f3facfbec5..9150c9c0c792b 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb @@ -2,14 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class UnifiedSettingsCategory - + Friend Class UnifiedSettingsCategory + + Public Property Title As String - + Public Property LegacyOptionPageId As String End Class diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb index 22affafbde145..60c7228dc9e8e 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb @@ -2,15 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class UnifiedSettingsEnumOption + Friend Class UnifiedSettingsEnumOption Inherits UnifiedSettingsOption(Of String) - + Public Property [Enum] As String() - + Public Property EnumLabels As String() End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb index 4d0b5ce859a3c..5d5ed27047cff 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb @@ -2,30 +2,32 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports System.Text.Json.Serialization +Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Public Class UnifiedSettingsOption(Of T) - + Friend Class UnifiedSettingsOption(Of T) + + Public Property Title As String - + Public Property Type As String - + Public Property [Default] As T - + Public Property AlternateDefault As AlternateDefault(Of T) - + Public Property Order As Integer - + Public Property EnableWhen As String - + Public Property Migration As Migration + End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb new file mode 100644 index 0000000000000..2d7540151104c --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb @@ -0,0 +1,55 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Globalization +Imports Microsoft.VisualStudio.LanguageServices +Imports Microsoft.VisualStudio.LanguageServices.CSharp +Imports Microsoft.VisualStudio.LanguageServices.VisualBasic + +Friend Module Utilities + Private Const CSharpLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.CSharp.dll" + + Private Const VisualBasicLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" + + Private Const LanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.dll" + + Friend Function EvalResource(resourceReference As String) As String + ' Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters + Dim resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1) + Dim resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1) + Dim resourceDll As String = Nothing + ' We reference the string in two ways + ' 1. "@102;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" where the guid is the package guid. It is the recommended way to locate string. + ' 2. "@Analysis;..\\Microsoft.VisualStudio.LanguageServices.dll". It is a special way we asked to locate string + Dim localizedString As String = Nothing + Dim culture = New CultureInfo("en") + Dim packageGuid As Guid = Nothing + If Guid.TryParse(resources, packageGuid) Then + If packageGuid = Guids.CSharpPackageId Then + Return CSharp.VSPackage.ResourceManager.GetString(resourcesIdentifier) + ElseIf packageGuid = Guids.VisualBasicPackageId Then + Return VisualBasic.VSPackage.ResourceManager.GetString(resourcesIdentifier) + Else + Assert.Fail($"Unexpected package Id: {packageGuid}") + End If + Else + resourceDll = resourceReference.Substring(resourceReference.IndexOf("\\") + 1) + End If + + Select Case resourceDll + Case CSharpLanguageServiceDllName + localizedString = CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case VisualBasicLanguageServiceDllName + localizedString = BasicVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case LanguageServiceDllName + localizedString = ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture) + Case Else + Assert.Fail($"Resources should only the fetched from {CSharpLanguageServiceDllName}, {VisualBasicLanguageServiceDllName} or {LanguageServiceDllName}.") + End Select + + Assert.NotNull(localizedString) + Return localizedString + End Function + +End Module diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb index adf92a5dbb485..c39a79c83d8d3 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb @@ -227,50 +227,5 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings Assert.NotEqual(-1, indexOfTheDefaultMapping) Assert.True(indexOfTheRealDefaultMapping < indexOfTheDefaultMapping) End Sub - - Private Const CSharpLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.CSharp.dll" - - Private Const VisualBasicLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" - - Private Const LanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.dll" - - Protected Shared Function EvalResource(resourceReference As String) As String - ' Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters - Dim resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1) - Dim resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1) - Dim resourceDll As String = Nothing - ' We reference the string in two ways - ' 1. "@102;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" where the guid is the package guid. It is the recommended way to locate string. - ' 2. "@Analysis;..\\Microsoft.VisualStudio.LanguageServices.dll". It is a special way we asked to locate string - Dim localizedString As String = Nothing - Dim culture = New CultureInfo("en") - Dim packageGuid As Guid = Nothing - If Guid.TryParse(resources, packageGuid) Then - If packageGuid = Guids.CSharpPackageId Then - Return CSharp.VSPackage.ResourceManager.GetString(resourcesIdentifier) - ElseIf packageGuid = Guids.VisualBasicPackageId Then - Return VisualBasic.VSPackage.ResourceManager.GetString(resourcesIdentifier) - Else - Assert.Fail($"Unexpected package Id: {packageGuid}") - End If - Else - resourceDll = resourceReference.Substring(resourceReference.IndexOf("\\") + 1) - End If - - Select Case resourceDll - Case CSharpLanguageServiceDllName - localizedString = CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case VisualBasicLanguageServiceDllName - localizedString = BasicVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case LanguageServiceDllName - localizedString = ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case Else - Assert.Fail($"Resources should only the fetched from {CSharpLanguageServiceDllName}, {VisualBasicLanguageServiceDllName} or {LanguageServiceDllName}.") - End Select - - Assert.NotNull(localizedString) - Return localizedString - End Function - End Class End Namespace From f5cb0306c42a0c3d840834af155edd7832576989 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 12 Dec 2024 14:13:54 -0800 Subject: [PATCH 08/45] Update input --- .../Def/Options/VisualStudioOptionStorage.cs | 16 ++---- .../TestModels/AlternateDefault.vb | 10 ++++ .../UnifiedSettings/TestModels/Input.vb | 52 +++++++++++++++++++ .../UnifiedSettings/TestModels/Migration.vb | 1 + .../TestModels/UnifiedSettingsEnumOption.vb | 12 +++++ .../TestModels/UnifiedSettingsOption.vb | 22 ++++++++ .../UnifiedSettings/TestModels/Utilities.vb | 4 +- .../UnifiedSettings/UnifiedSettingsTests.vb | 3 -- 8 files changed, 105 insertions(+), 15 deletions(-) diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 5759847f9b1a7..9b150781dd0e5 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -85,25 +85,19 @@ public bool TryFetch(FeatureFlagPersister persister, OptionKey2 optionKey, out o => persister.TryFetch(optionKey, FlagName, out value); } - internal sealed class LocalUserProfileStorage : VisualStudioOptionStorage + internal sealed class LocalUserProfileStorage(string path, string key) : VisualStudioOptionStorage { - private readonly string _path; - private readonly string _key; - - public LocalUserProfileStorage(string path, string key) - { - _path = path; - _key = key; - } + public string Path => path; + public string Key => key; public Task PersistAsync(LocalUserRegistryOptionPersister persister, OptionKey2 optionKey, object? value) { - persister.Persist(optionKey, _path, _key, value); + persister.Persist(optionKey, path, key, value); return Task.CompletedTask; } public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 optionKey, out object? value) - => persister.TryFetch(optionKey, _path, _key, out value); + => persister.TryFetch(optionKey, path, key, out value); } public static readonly IReadOnlyDictionary Storages = new Dictionary() diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb index 125fc5f486f07..1499c844ce35b 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -2,6 +2,8 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Microsoft.CodeAnalysis.Options +Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels @@ -11,5 +13,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Property [Default] As T + + Public Shared Function CreateFromOption([option] As IOption2, alternativeDefault As T) As AlternateDefault(Of T) + Dim configName = [option].Definition.ConfigName + Dim visualStudioStorage = Storages(configName) + ' Option has to be FeatureFlagStorage to be used as alternative default + Dim featureFlagStorage = DirectCast(visualStudioStorage, FeatureFlagStorage) + Return New AlternateDefault(Of T) With {.FlagName = featureFlagStorage.FlagName, .[Default] = alternativeDefault} + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index 82a91207c6766..2fa172e23ae1c 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -2,7 +2,13 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.Options +Imports Microsoft.VisualStudio.LanguageServices.Options +Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage +Imports Microsoft.VisualStudio.Shell Imports Newtonsoft.Json +Imports Roslyn.Utilities Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class Input @@ -10,5 +16,51 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Property Store As String Public Property Path As String + + Public Shared Function CreateInput([option] As IOption2) As Input + Dim configName = [option].Definition.ConfigName + Dim visualStudioStorage = Storages(configName) + + Return New Input() With {.Store = GetStore(visualStudioStorage), .Path = GetPath(visualStudioStorage)} + End Function + + Public Shared Function CreateInput([option] As IPerLanguageValuedOption, languageName As String) As Input + Dim configName = [option].Definition.ConfigName + Dim visualStudioStorage = Storages(configName) + Return New Input() With {.Store = GetStore(visualStudioStorage), .Path = GetPath(visualStudioStorage, languageName)} + End Function + + Private Shared Function GetStore(storage As VisualStudioOptionStorage) As String + If TypeOf storage Is RoamingProfileStorage Then + Return "SettingsManager" + ElseIf TypeOf storage Is LocalUserProfileStorage Then + Return "VsUserSettingsRegistry" + Else + Throw ExceptionUtilities.Unreachable + End If + End Function + + Private Shared Function GetPath(storage As VisualStudioOptionStorage, Optional languageName As String = Nothing) As String + If TypeOf storage Is RoamingProfileStorage Then + Dim roamingProfileStorage = DirectCast(storage, RoamingProfileStorage) + Return roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(If(languageName = Nothing, String.Empty, languageName))) + ElseIf TypeOf storage Is LocalUserProfileStorage Then + Dim localUserProfileStorage = DirectCast(storage, LocalUserProfileStorage) + Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.key}" + Else + Throw ExceptionUtilities.Unreachable + End If + End Function + + Private Shared Function GetSubstituteLanguage(languageName As String) As String + Select Case languageName + Case LanguageNames.CSharp + Return "CSharp" + Case LanguageNames.VisualBasic + Return "VisualBasic" + Case Else + Return languageName + End Select + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb index db19960cd4945..4f0fb393ad2b0 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb @@ -2,6 +2,7 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb index 60c7228dc9e8e..86f290170339d 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb @@ -2,6 +2,7 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels @@ -12,5 +13,16 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Property EnumLabels As String() + + Public Shared Function CreateEnumOption( + roslynOption As IOption2, + title As String, + defaultValue As Boolean, + featureFlagOption As IOption2, + enumLabels As String(), + [enum] As String(), + languageName As String) As UnifiedSettingsEnumOption + + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb index 5d5ed27047cff..c1bf0f9ca6718 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb @@ -2,6 +2,7 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels @@ -29,5 +30,26 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Property Migration As Migration + Public Shared Function CreateBooleanOption( + roslynOption As IOption2, + title As String, + defaultValue As Boolean, + alternativeDefault As Boolean, + featureFlagOption As IOption2, + enableWhenOptionAndValue As ([option] As String, value As Object), + languageName As String) As UnifiedSettingsOption(Of Boolean) + Dim type = roslynOption.Type + Assert.True(type = GetType(Boolean) OrElse Nullable.GetUnderlyingType(type) = GetType(Boolean)) + Assert.NotEqual(defaultValue, alternativeDefault) + + Return New UnifiedSettingsOption(Of Boolean)() With { + .Title = title, + .Type = "boolean", + .[Default] = defaultValue, + .EnableWhen = $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'", + .AlternateDefault = TestModels.AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault) + } + + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb index 2d7540151104c..cc27dd33dda69 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb @@ -3,9 +3,12 @@ ' See the LICENSE file in the project root for more information. Imports System.Globalization +Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices Imports Microsoft.VisualStudio.LanguageServices.CSharp Imports Microsoft.VisualStudio.LanguageServices.VisualBasic +Imports Roslyn.Utilities +Imports Microsoft.CodeAnalysis Friend Module Utilities Private Const CSharpLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.CSharp.dll" @@ -51,5 +54,4 @@ Friend Module Utilities Assert.NotNull(localizedString) Return localizedString End Function - End Module diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb index c39a79c83d8d3..ecf8ba700f9bf 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb @@ -3,16 +3,13 @@ ' See the LICENSE file in the project root for more information. Imports System.Collections.Immutable -Imports System.Globalization Imports System.IO.Hashing Imports System.Text Imports System.Text.RegularExpressions Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.CSharp Imports Microsoft.VisualStudio.LanguageServices.Options Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage -Imports Microsoft.VisualStudio.LanguageServices.VisualBasic Imports Newtonsoft.Json.Linq Imports Roslyn.Test.Utilities Imports Roslyn.Utilities From c4987d4c120945dd810064c664052a627e8c4ecd Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 12 Dec 2024 22:17:56 -0800 Subject: [PATCH 09/45] Clean --- .../VisualBasicUnifiedSettingsTests.vb | 99 +++++++++---------- .../UnifiedSettings/ExpectedUnifiedSetting.vb | 22 +++++ .../TestModels/AlternateDefault.vb | 11 ++- .../TestModels/EnumIntegerToString.vb | 8 +- .../UnifiedSettings/TestModels/Input.vb | 14 ++- .../UnifiedSettings/TestModels/Map.vb | 9 +- .../UnifiedSettings/TestModels/Migration.vb | 7 +- .../TestModels/MigrationType.vb | 6 +- .../UnifiedSettings/TestModels/Pass.vb | 4 + .../TestModels/UnifiedSettingsCategory.vb | 8 +- .../TestModels/UnifiedSettingsEnumOption.vb | 12 ++- .../TestModels/UnifiedSettingsOption.vb | 47 ++------- .../TestModels/UnifiedSettingsOptionBase.vb | 57 +++++++++++ .../UnifiedSettings/TestModels/Utilities.vb | 2 - 14 files changed, 193 insertions(+), 113 deletions(-) create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 39bf39254e73e..69dfacd9f4b98 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -10,7 +10,6 @@ Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels -Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings @@ -32,20 +31,6 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings End Get End Property - Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of (unifiedSettingsPath As String, roslynOption As IOption2)) - Get - Return ImmutableArray.Create(Of (String, IOption2))( - ("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), - ("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), - ("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), - ("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), - ("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), - ("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), - ("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), - ("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) - End Get - End Property - Friend Overrides Function GetEnumOptionValues([option] As IOption2) As Object() Dim allValues = [Enum].GetValues([option].Type).Cast(Of Object) If [option].Equals(CompletionOptionsStorage.SnippetsBehavior) Then @@ -109,44 +94,50 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings End Using End Function - ' - 'Public Async Function IntelliSensePageTest() As Task - ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - ' Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - ' Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - ' Dim pkgDefFile = Await pkgDefFileReader.ReadToEndAsync().ConfigureAwait(False) - ' Dim parseOption = New JsonDocumentOptions() With { - ' .CommentHandling = JsonCommentHandling.Skip - ' } - ' Dim registrationDocument = Await JsonDocument.ParseAsync(registrationFileStream, parseOption) - ' Dim properties = registrationDocument.RootElement.GetProperty("properties") - ' Assert.NotNull(properties) - - ' Dim expectedGroupPrefix = "textEditor.basic.intellisense" - ' Dim actualOptions = properties.EnumerateObject.Where(Function([property]) [property].Name.StartsWith(expectedGroupPrefix)).ToImmutableArray() - ' Assert.Equal(IntelliSenseOnboardedOptions.Length, actualOptions.Length) - - ' For Each optionPair In actualOptions.Zip(IntelliSenseOnboardedOptions, Function(actual, expected) (actual, expected)) - ' Dim expected = optionPair.expected - ' Dim actualName = optionPair.actual.Name - - ' Next - ' End Using - ' End Using - ' End Using - 'End Function - - 'Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) - ' Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) - ' Dim expectedOption = expected.roslynOption - ' Dim type = expectedOption.Type - ' If type = GetType(Boolean) Then - ' VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) - ' ElseIf type.IsEnum Then - ' VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) - ' Else - ' Assert.Fail("We only have enum and boolean option now. Add more if needed") - ' End If - 'End Sub + Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of ExpectedUnifiedSetting) + Get + Return ImmutableArray.Create(Of ExpectedUnifiedSetting)( + New ExpectedUnifiedSetting( + "textEditor.basic.intellisense.triggerCompletionOnTypingLetters", + CompletionOptionsStorage.TriggerOnTypingLetters, + UnifiedSettingsOptionBase + ) + } + + '("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), + '("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), + '("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), + '("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), + '("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), + '("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), + '("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), + '("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) + End Get + End Property + + + + Public Async Function IntelliSensePageTest() As Task + Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") + Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") + Using pkgDefFileReader = New StreamReader(pkgDefFileStream) + + End Using + End Using + End Using + End Function + + Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) + Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) + Dim expectedOption = expected.roslynOption + Dim type = expectedOption.Type + If type = GetType(Boolean) Then + VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) + ElseIf type.IsEnum Then + VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) + Else + Assert.Fail("We only have enum and boolean option now. Add more if needed") + End If + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb new file mode 100644 index 0000000000000..39cb005488bc7 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb @@ -0,0 +1,22 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports Microsoft.CodeAnalysis.Options +Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings + Friend Class ExpectedUnifiedSetting + Public ReadOnly Property UnifiedSettingPath As String + + Public ReadOnly Property [Option] As IOption2 + + Public ReadOnly Property UnifiedSettingsOption As UnifiedSettingsOptionBase + + Public Sub New(unifiedSettingPath As String, [option] As IOption2, unifiedSettingsOption As UnifiedSettingsOptionBase) + Me.UnifiedSettingPath = unifiedSettingPath + Me.Option = [option] + Me.UnifiedSettingsOption = unifiedSettingsOption + End Sub + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb index 1499c844ce35b..606f183974ae9 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -9,17 +9,22 @@ Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class AlternateDefault(Of T) - Public Property FlagName As String + Public ReadOnly Property FlagName As String - Public Property [Default] As T + Public ReadOnly Property [Default] As T + + Public Sub New(flagName As String, [default] As T) + Me.FlagName = flagName + Me.Default = [default] + End Sub Public Shared Function CreateFromOption([option] As IOption2, alternativeDefault As T) As AlternateDefault(Of T) Dim configName = [option].Definition.ConfigName Dim visualStudioStorage = Storages(configName) ' Option has to be FeatureFlagStorage to be used as alternative default Dim featureFlagStorage = DirectCast(visualStudioStorage, FeatureFlagStorage) - Return New AlternateDefault(Of T) With {.FlagName = featureFlagStorage.FlagName, .[Default] = alternativeDefault} + Return New AlternateDefault(Of T)(featureFlagStorage.FlagName, alternativeDefault) End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb index 3b0127d281760..8cef2ede2120e 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb @@ -7,7 +7,13 @@ Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class EnumIntegerToString Inherits MigrationType + - Public Property Map() As Map + Public ReadOnly Property Map As Map() + + Public Sub New(map As Map(), input As Input) + MyBase.New(input) + Me.Map = map + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index 2fa172e23ae1c..80100d60c6c4d 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -6,28 +6,32 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices.Options Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage -Imports Microsoft.VisualStudio.Shell Imports Newtonsoft.Json Imports Roslyn.Utilities Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class Input - Public Property Store As String + Public ReadOnly Property Store As String - Public Property Path As String + Public ReadOnly Property Path As String + + Public Sub New(store As String, path As String) + Me.Store = store + Me.Path = path + End Sub Public Shared Function CreateInput([option] As IOption2) As Input Dim configName = [option].Definition.ConfigName Dim visualStudioStorage = Storages(configName) - Return New Input() With {.Store = GetStore(visualStudioStorage), .Path = GetPath(visualStudioStorage)} + Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage)) End Function Public Shared Function CreateInput([option] As IPerLanguageValuedOption, languageName As String) As Input Dim configName = [option].Definition.ConfigName Dim visualStudioStorage = Storages(configName) - Return New Input() With {.Store = GetStore(visualStudioStorage), .Path = GetPath(visualStudioStorage, languageName)} + Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage, languageName)) End Function Private Shared Function GetStore(storage As VisualStudioOptionStorage) As String diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb index fab0e93d6455c..28905e3eb8249 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb @@ -7,8 +7,13 @@ Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class Map - Public Property Result As String + Public ReadOnly Property Result As String - Public Property Match As Integer + Public ReadOnly Property Match As Integer + + Public Sub New(result As String, match As Integer) + Me.Result = result + Me.Match = match + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb index 4f0fb393ad2b0..ecf37121a0026 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb @@ -2,12 +2,15 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class Migration - Public Property Pass As Pass + Public ReadOnly Property Pass As Pass + + Public Sub New(pass As Pass) + Me.Pass = pass + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb index 8aa7aaa82565a..03dfd616b9460 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb @@ -7,6 +7,10 @@ Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class MigrationType - Public Property Input As Input + Public ReadOnly Property Input As Input + + Public Sub New(input As Input) + Me.Input = input + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb index b7ffc165bc5ea..7aeb273f9052e 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb @@ -5,5 +5,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class Pass Inherits MigrationType + + Public Sub New(input As Input) + MyBase.New(input) + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb index 9150c9c0c792b..a4b4811d6e458 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb @@ -8,10 +8,14 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Friend Class UnifiedSettingsCategory - Public Property Title As String + Public ReadOnly Property Title As String - Public Property LegacyOptionPageId As String + Public ReadOnly Property LegacyOptionPageId As String + Public Sub New(title As String, legacyOptionPageId As String) + Me.Title = title + Me.LegacyOptionPageId = legacyOptionPageId + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb index 86f290170339d..81dc7f3f8514f 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb @@ -8,11 +8,19 @@ Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class UnifiedSettingsEnumOption Inherits UnifiedSettingsOption(Of String) + - Public Property [Enum] As String() + Public ReadOnly Property [Enum] As String() - Public Property EnumLabels As String() + + Public ReadOnly Property EnumLabels As String() + + Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration, [default] As String, alternateDefault As AlternateDefault(Of String), [enum] As String(), enumLabels As String()) + MyBase.New(title, type, order, enableWhen, migration, [default], alternateDefault) + Me.Enum = [enum] + Me.EnumLabels = enumLabels + End Sub Public Shared Function CreateEnumOption( roslynOption As IOption2, diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb index c1bf0f9ca6718..1d0c1a11062d3 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb @@ -2,54 +2,23 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels Friend Class UnifiedSettingsOption(Of T) - - - Public Property Title As String - - - Public Property Type As String + Inherits UnifiedSettingsOptionBase - Public Property [Default] As T + Public ReadOnly Property [Default] As T - Public Property AlternateDefault As AlternateDefault(Of T) - - - Public Property Order As Integer - - - Public Property EnableWhen As String - - - Public Property Migration As Migration - - Public Shared Function CreateBooleanOption( - roslynOption As IOption2, - title As String, - defaultValue As Boolean, - alternativeDefault As Boolean, - featureFlagOption As IOption2, - enableWhenOptionAndValue As ([option] As String, value As Object), - languageName As String) As UnifiedSettingsOption(Of Boolean) - Dim type = roslynOption.Type - Assert.True(type = GetType(Boolean) OrElse Nullable.GetUnderlyingType(type) = GetType(Boolean)) - Assert.NotEqual(defaultValue, alternativeDefault) - - Return New UnifiedSettingsOption(Of Boolean)() With { - .Title = title, - .Type = "boolean", - .[Default] = defaultValue, - .EnableWhen = $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'", - .AlternateDefault = TestModels.AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault) - } + Public ReadOnly Property AlternateDefault As AlternateDefault(Of T) - End Function + Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration, [default] As T, alternateDefault As AlternateDefault(Of T)) + MyBase.New(title, type, order, enableWhen, migration) + Me.Default = [default] + Me.AlternateDefault = alternateDefault + End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb new file mode 100644 index 0000000000000..bc1e3165face6 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb @@ -0,0 +1,57 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports Microsoft.CodeAnalysis.Options +Imports Newtonsoft.Json + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels + Friend Class UnifiedSettingsOptionBase + + + Public ReadOnly Property Title As String + + + Public ReadOnly Property Type As String + + + Public ReadOnly Property Order As Integer + + + Public ReadOnly Property EnableWhen As String + + + Public ReadOnly Property Migration As Migration + + Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration) + Me.Title = title + Me.Type = type + Me.Order = order + Me.EnableWhen = enableWhen + Me.Migration = migration + End Sub + + Public Shared Function CreateBooleanOption( + roslynOption As IOption2, + title As String, + order As Integer, + defaultValue As Boolean, + alternativeDefault As Boolean, + featureFlagOption As IOption2, + enableWhenOptionAndValue As ([option] As String, value As Object), + languageName As String) As UnifiedSettingsOption(Of Boolean) + Dim type = roslynOption.Type + Assert.True(type = GetType(Boolean) OrElse Nullable.GetUnderlyingType(type) = GetType(Boolean)) + Assert.NotEqual(defaultValue, alternativeDefault) + + Return New UnifiedSettingsOption(Of Boolean)( + title, + "boolean", + order, + $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'", + New Migration(New Pass(Input.CreateInput(roslynOption))), + defaultValue, + AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault)) + End Function + End Class +End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb index cc27dd33dda69..36aaacdeb1482 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb @@ -3,11 +3,9 @@ ' See the LICENSE file in the project root for more information. Imports System.Globalization -Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices Imports Microsoft.VisualStudio.LanguageServices.CSharp Imports Microsoft.VisualStudio.LanguageServices.VisualBasic -Imports Roslyn.Utilities Imports Microsoft.CodeAnalysis Friend Module Utilities From 2cbbeffa474a12c01a5190797709937e62088f2b Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 00:08:35 -0800 Subject: [PATCH 10/45] test the first option --- .../VisualBasicUnifiedSettingsTests.vb | 61 +++++++++++++------ .../TestModels/ResourceConverter.vb | 2 +- .../TestModels/UnifiedSettingsOptionBase.vb | 10 ++- .../UnifiedSettings/TestModels/Utilities.vb | 2 +- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 69dfacd9f4b98..b2517ef2ba293 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -96,13 +96,19 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of ExpectedUnifiedSetting) Get - Return ImmutableArray.Create(Of ExpectedUnifiedSetting)( + Return ImmutableArray.Create( New ExpectedUnifiedSetting( "textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters, - UnifiedSettingsOptionBase - ) - } + UnifiedSettingsOptionBase.CreateBooleanOption( + CompletionOptionsStorage.TriggerOnTypingLetters, + "Show completion list after a character is typed", + order:=0, + defaultValue:=True, + Nothing, + Nothing, + LanguageNames.VisualBasic)) + ) '("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), '("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), @@ -119,25 +125,42 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Public Async Function IntelliSensePageTest() As Task Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - + Using reader = New StreamReader(registrationFileStream) + Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") + Using pkgDefFileReader = New StreamReader(pkgDefFileStream) + Dim registrationFile = Await reader.ReadToEndAsync() + Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) + Dim properties = registrationJsonObject.Property("properties").Value.Children(Of JProperty).ToImmutableArray() + ' TODO: Assert number is correct + + For i = 0 To IntelliSenseOnboardedOptions.Length + Dim actualProperty = properties(i) + Dim expectedOption = IntelliSenseOnboardedOptions(i) + If expectedOption.Option.Type Is GetType(Boolean) Then + Dim actualOption = actualProperty.Value.ToObject(Of UnifiedSettingsOption(Of Boolean)) + Assert.Equal(expectedOption.UnifiedSettingPath, actualProperty.Name) + + End If + Next + + Dim hj = 8 + End Using End Using End Using End Using End Function - Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) - Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) - Dim expectedOption = expected.roslynOption - Dim type = expectedOption.Type - If type = GetType(Boolean) Then - VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) - ElseIf type.IsEnum Then - VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) - Else - Assert.Fail("We only have enum and boolean option now. Add more if needed") - End If - End Sub + 'Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) + ' Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) + ' Dim expectedOption = expected.roslynOption + ' Dim type = expectedOption.Type + ' If type = GetType(Boolean) Then + ' VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) + ' ElseIf type.IsEnum Then + ' VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) + ' Else + ' Assert.Fail("We only have enum and boolean option now. Add more if needed") + ' End If + 'End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb index 9a2ad7ce394ca..cdadeb572765c 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb @@ -17,7 +17,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Overrides Function ReadJson(reader As JsonReader, objectType As Type, existingValue As Object, serializer As JsonSerializer) As Object Dim token = JToken.Load(reader) If token.Type = JTokenType.String Then - Return EvalResource(token.ToString) + Return EvalResource(token.ToString()) ElseIf token.Type = JTokenType.Array Then Dim array = token.Values Return array.Where(Function(arrayElement) arrayElement.Type = JTokenType.String).SelectAsArray(Function(arrayElement) EvalResource(arrayElement.ToString())) diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb index bc1e3165face6..9f7a83a9ee4e1 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb @@ -6,7 +6,7 @@ Imports Microsoft.CodeAnalysis.Options Imports Newtonsoft.Json Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class UnifiedSettingsOptionBase + Friend MustInherit Class UnifiedSettingsOptionBase Public ReadOnly Property Title As String @@ -36,22 +36,20 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test title As String, order As Integer, defaultValue As Boolean, - alternativeDefault As Boolean, - featureFlagOption As IOption2, + alternativeDefault As (featureFlagOption As IOption2, alternateDefault As Boolean), enableWhenOptionAndValue As ([option] As String, value As Object), languageName As String) As UnifiedSettingsOption(Of Boolean) Dim type = roslynOption.Type Assert.True(type = GetType(Boolean) OrElse Nullable.GetUnderlyingType(type) = GetType(Boolean)) - Assert.NotEqual(defaultValue, alternativeDefault) Return New UnifiedSettingsOption(Of Boolean)( title, "boolean", order, - $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'", + If(enableWhenOptionAndValue.option Is Nothing, Nothing, $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'"), New Migration(New Pass(Input.CreateInput(roslynOption))), defaultValue, - AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault)) + If(alternativeDefault.featureFlagOption Is Nothing, Nothing, AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault.alternateDefault))) End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb index 36aaacdeb1482..8eba26629aea3 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb @@ -35,7 +35,7 @@ Friend Module Utilities Assert.Fail($"Unexpected package Id: {packageGuid}") End If Else - resourceDll = resourceReference.Substring(resourceReference.IndexOf("\\") + 1) + resourceDll = resourceReference.Substring(resourceReference.IndexOf("\") + 1) End If Select Case resourceDll From e5cc574eed9be7b3f0463bef6f9bf1134e9d0d08 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 14:03:15 -0800 Subject: [PATCH 11/45] Modify the resources --- .../Impl/Options/IntelliSenseOptionPageStrings.cs | 2 +- src/VisualStudio/Core/Def/ServicesVSResources.resx | 9 ++++++--- .../Core/Def/xlf/ServicesVSResources.cs.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.de.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.es.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.fr.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.it.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.ja.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.ko.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.pl.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.ru.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.tr.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 9 +++++++-- .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 9 +++++++-- .../VisualBasicUnifiedSettingsTests.vb | 1 + ...ualStudio.LanguageServices.Test.Utilities2.vbproj | 3 --- .../UnifiedSettings/TestModels/AlternateDefault.vb | 7 +++++++ .../UnifiedSettings/TestModels/Input.vb | 9 ++++++++- .../UnifiedSettings/TestModels/Migration.vb | 6 ++++++ .../UnifiedSettings/TestModels/MigrationType.vb | 6 ++++++ .../UnifiedSettings/TestModels/Pass.vb | 6 ++++++ .../TestModels/UnifiedSettingsOption.vb | 12 ++++++++++++ .../Impl/Options/IntelliSenseOptionPageStrings.vb | 2 +- 24 files changed, 145 insertions(+), 35 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageStrings.cs b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageStrings.cs index d6cb5cbc2a022..6642d01360003 100644 --- a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageStrings.cs +++ b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageStrings.cs @@ -9,7 +9,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.Options internal static class IntelliSenseOptionPageStrings { public static string Option_Show_completion_list_after_a_character_is_typed - => ServicesVSResources.Show_completion_list_after_a_character_is_typed; + => ServicesVSResources._Show_completion_list_after_a_character_is_typed; public static string Option_Show_completion_list_after_a_character_is_deleted => ServicesVSResources.Show_completion_list_after_a_character_is_deleted; diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 1e64b619eff39..4f6f03a2c42c9 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1871,9 +1871,6 @@ Additional information: {1} Performance - - _Show completion list after a character is typed - _Highlight matching portions of completion list items @@ -1922,4 +1919,10 @@ Additional information: {1} Show "Remove Unused References" command in Solution Explorer + + _Show completion list after a character is typed + + + Show completion list after a character is typed + \ No newline at end of file diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index 0018c4444143e..acff95d1e685d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code na konci řádku kódu diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index c67415f79e122..cf048777d411e 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code am Ende der Codezeile diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index d7a365f5a4bea..37a39ce09900d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code al final de la línea de código diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 06248745a2432..2ab4fc7f325f1 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code à la fin de la ligne de code diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index aabda29bb7313..95182621a28d8 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code alla fine della riga di codice diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 0c40cbf6242da..4df43cd163941 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code コード行の末尾で diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 1a4a025ee9bae..82acf9c78622b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code 코드 줄의 끝에 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index e37e31f4f773f..424bd39f3eafa 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code na końcu wiersza kodu diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index fc676afe710c1..f26e337e8ab5a 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code no final da linha de código diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index d1567c5a71846..28a3b6f132cee 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code в конце строки кода diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 9a8551d21a3dc..357321da8ab40 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code kod satırı sonunda diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index ea8ced5280557..29f29adb997c3 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code 在代码行的末尾 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index eeefe118181bf..455a5d1b0a47c 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -1403,8 +1403,8 @@ - _Show completion list after a character is typed - _Show completion list after a character is typed + Show completion list after a character is typed + Show completion list after a character is typed @@ -1857,6 +1857,11 @@ _Only add new line on enter after end of fully typed word + + _Show completion list after a character is typed + _Show completion list after a character is typed + + at the end of the line of code 在程式碼結尾 diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index b2517ef2ba293..6ddef80f6ff1d 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -139,6 +139,7 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings If expectedOption.Option.Type Is GetType(Boolean) Then Dim actualOption = actualProperty.Value.ToObject(Of UnifiedSettingsOption(Of Boolean)) Assert.Equal(expectedOption.UnifiedSettingPath, actualProperty.Name) + Assert.Equal(expectedOption.UnifiedSettingsOption, actualOption) End If Next diff --git a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj index 268ad247154de..6ca1ded5756a1 100644 --- a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj +++ b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj @@ -59,9 +59,6 @@ - - - diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb index 606f183974ae9..ac6e4f244e911 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb @@ -26,5 +26,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Dim featureFlagStorage = DirectCast(visualStudioStorage, FeatureFlagStorage) Return New AlternateDefault(Of T)(featureFlagStorage.FlagName, alternativeDefault) End Function + + Public Overrides Function Equals(obj As Object) As Boolean + Dim [default] = TryCast(obj, AlternateDefault(Of T)) + Return [default] IsNot Nothing AndAlso + FlagName = [default].FlagName AndAlso + EqualityComparer(Of T).Default.Equals(Me.Default, [default].Default) + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index 80100d60c6c4d..6807290080360 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -50,7 +50,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Return roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(If(languageName = Nothing, String.Empty, languageName))) ElseIf TypeOf storage Is LocalUserProfileStorage Then Dim localUserProfileStorage = DirectCast(storage, LocalUserProfileStorage) - Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.key}" + Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.Key}" Else Throw ExceptionUtilities.Unreachable End If @@ -66,5 +66,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Return languageName End Select End Function + + Public Overrides Function Equals(obj As Object) As Boolean + Dim input = TryCast(obj, Input) + Return input IsNot Nothing AndAlso + Store = input.Store AndAlso + Path = input.Path + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb index ecf37121a0026..98c14c5120a4b 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb @@ -12,5 +12,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Sub New(pass As Pass) Me.Pass = pass End Sub + + Public Overrides Function Equals(obj As Object) As Boolean + Dim migration = TryCast(obj, Migration) + Return migration IsNot Nothing AndAlso + EqualityComparer(Of Pass).Default.Equals(Pass, migration.Pass) + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb index 03dfd616b9460..65abc45692c2f 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb @@ -12,5 +12,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Sub New(input As Input) Me.Input = input End Sub + + Public Overrides Function Equals(obj As Object) As Boolean + Dim type = TryCast(obj, MigrationType) + Return type IsNot Nothing AndAlso + EqualityComparer(Of Input).Default.Equals(Input, type.Input) + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb index 7aeb273f9052e..435b6755b2545 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb @@ -9,5 +9,11 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Public Sub New(input As Input) MyBase.New(input) End Sub + + Public Overrides Function Equals(obj As Object) As Boolean + Dim pass = TryCast(obj, Pass) + Return pass IsNot Nothing AndAlso + EqualityComparer(Of Input).Default.Equals(Input, pass.Input) + End Function End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb index 1d0c1a11062d3..ee737293f7819 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb @@ -20,5 +20,17 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test Me.Default = [default] Me.AlternateDefault = alternateDefault End Sub + + Public Overrides Function Equals(obj As Object) As Boolean + Dim [option] = TryCast(obj, UnifiedSettingsOption(Of T)) + Return [option] IsNot Nothing AndAlso + Title = [option].Title AndAlso + Type = [option].Type AndAlso + Order = [option].Order AndAlso + EnableWhen = [option].EnableWhen AndAlso + EqualityComparer(Of Migration).Default.Equals(Migration, [option].Migration) AndAlso + EqualityComparer(Of T).Default.Equals([Default], [option].Default) AndAlso + EqualityComparer(Of AlternateDefault(Of T)).Default.Equals(AlternateDefault, [option].AlternateDefault) + End Function End Class End Namespace diff --git a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb index d83c86e62658d..9ad66afbc9a05 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb @@ -8,7 +8,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options BasicVSResources.Completion_Lists Public ReadOnly Property Option_Show_completion_list_after_a_character_is_typed As String = - ServicesVSResources.Show_completion_list_after_a_character_is_typed + ServicesVSResources._Show_completion_list_after_a_character_is_typed Public ReadOnly Property Option_Show_completion_list_after_a_character_is_deleted As String = ServicesVSResources.Show_completion_list_after_a_character_is_deleted From 505227a40a1002089eda8fd7c82919abf3e6c438 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 15:07:18 -0800 Subject: [PATCH 12/45] Fix test --- .../UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb index 9f7a83a9ee4e1..e3d408de00867 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb @@ -47,7 +47,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.Test "boolean", order, If(enableWhenOptionAndValue.option Is Nothing, Nothing, $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'"), - New Migration(New Pass(Input.CreateInput(roslynOption))), + New Migration(New Pass(Input.CreateInput(CType(roslynOption, IPerLanguageValuedOption), languageName))), defaultValue, If(alternativeDefault.featureFlagOption Is Nothing, Nothing, AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault.alternateDefault))) End Function From bb6cdef9c5103a3af9112978e3161c4722b39f34 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 16:50:09 -0800 Subject: [PATCH 13/45] Move test to NextUnitTests --- ...isualStudio.LanguageServices.CSharp.csproj | 1 + .../Roslyn.VisualStudio.Next.UnitTests.csproj | 2 + .../TestModel/UnifiedSettingBase.cs | 65 +++++++++++++++++++ .../UnifiedSettings/UnifiedSettingsTests.cs | 22 +++++++ ...alStudio.LanguageServices.UnitTests.vbproj | 4 -- .../VisualBasicUnifiedSettingsTests.vb | 60 ++++++++++------- ...io.LanguageServices.Test.Utilities2.vbproj | 8 ++- .../UnifiedSettingsJsonResourceConverter.vb | 20 ++++++ ...Studio.LanguageServices.VisualBasic.vbproj | 1 + ...eAnalysis.Workspaces.Test.Utilities.csproj | 6 +- 10 files changed, 156 insertions(+), 33 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs create mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb diff --git a/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj b/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj index 150726d55eeae..151a0533819f1 100644 --- a/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj +++ b/src/VisualStudio/CSharp/Impl/Microsoft.VisualStudio.LanguageServices.CSharp.csproj @@ -51,6 +51,7 @@ + diff --git a/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj b/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj index 0da9a5230befa..15438d02432fc 100644 --- a/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj +++ b/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj @@ -66,5 +66,7 @@ + + \ No newline at end of file diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs new file mode 100644 index 0000000000000..6b30182109f7a --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +{ + internal abstract record UnifiedSettingBase + { + [JsonPropertyName("title")] + public required string Title { get; init; } + + [JsonPropertyName("type")] + public required string Type { get; init; } + + [JsonPropertyName("order")] + public required int Order { get; init; } + + [JsonPropertyName("enableWhen")] + public string? EnableWhen { get; init; } + + [JsonPropertyName("Migration")] + public required Migration Migration { get; init; } + } + + internal record UnifiedSettingsOption : UnifiedSettingBase + { + [JsonPropertyName("Default")] + public required T Default { get; init; } + + [JsonPropertyName("AlternativeDefault")] + public AlternativeDefault? AlternativeDefault { get; init; } + } + + public record AlternativeDefault + { + [JsonPropertyName("FlagName")] + public required string FlagName { get; init; } + + [JsonPropertyName("Default")] + public required T Default { get; init; } + } + + internal record Migration + { + [JsonPropertyName("pass")] + public required Pass Pass { get; init; } + } + + internal record Pass + { + [JsonPropertyName("input")] + public required Input Input { get; init; } + } + + internal record Input + { + [JsonPropertyName("store")] + public required string Store { get; init; } + + [JsonPropertyName("path")] + public required string Path { get; init; } + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs new file mode 100644 index 0000000000000..b76a09b0532f1 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xunit; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings +{ + public class UnifiedSettingsTests + { + [Fact] + public Task VisualBasicIntellisenseTest() + { + + } + } +} diff --git a/src/VisualStudio/Core/Test/Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj b/src/VisualStudio/Core/Test/Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj index 982fa6235b259..ff7653acf0a89 100644 --- a/src/VisualStudio/Core/Test/Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj +++ b/src/VisualStudio/Core/Test/Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj @@ -62,8 +62,4 @@ - - - - \ No newline at end of file diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 6ddef80f6ff1d..a1d05b5a7a6d9 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -5,6 +5,8 @@ Imports System.Collections.Immutable Imports System.IO Imports System.Reflection +Imports System.Text.Json +Imports System.Text.Json.Nodes Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options @@ -121,36 +123,48 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings End Get End Property - Public Async Function IntelliSensePageTest() As Task Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Using reader = New StreamReader(registrationFileStream) - Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - Dim registrationFile = Await reader.ReadToEndAsync() - Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) - Dim properties = registrationJsonObject.Property("properties").Value.Children(Of JProperty).ToImmutableArray() - ' TODO: Assert number is correct - - For i = 0 To IntelliSenseOnboardedOptions.Length - Dim actualProperty = properties(i) - Dim expectedOption = IntelliSenseOnboardedOptions(i) - If expectedOption.Option.Type Is GetType(Boolean) Then - Dim actualOption = actualProperty.Value.ToObject(Of UnifiedSettingsOption(Of Boolean)) - Assert.Equal(expectedOption.UnifiedSettingPath, actualProperty.Name) - Assert.Equal(expectedOption.UnifiedSettingsOption, actualOption) - - End If - Next - - Dim hj = 8 - End Using - End Using + Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") + Dim jsonDocument = Await JsonNode.ParseAsync(registrationFileStream, documentOptions:=New JsonDocumentOptions() With {.CommentHandling = JsonCommentHandling.Skip}) + Dim properties = jsonDocument.Root("properties") + + Dim j = 9 + End Using End Using End Function + ' + 'Public Async Function IntelliSensePageTest() As Task + ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") + ' Using reader = New StreamReader(registrationFileStream) + ' Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") + ' Using pkgDefFileReader = New StreamReader(pkgDefFileStream) + ' Dim registrationFile = Await reader.ReadToEndAsync() + ' Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) + ' Dim properties = registrationJsonObject.Property("properties").Value.Children(Of JProperty).ToImmutableArray() + ' TODO: Assert number is correct + + ' For i = 0 To IntelliSenseOnboardedOptions.Length + ' Dim actualProperty = properties(i) + ' Dim expectedOption = IntelliSenseOnboardedOptions(i) + ' If expectedOption.Option.Type Is GetType(Boolean) Then + ' Dim actualOption = actualProperty.Value.ToObject(Of UnifiedSettingsOption(Of Boolean)) + ' Assert.Equal(expectedOption.UnifiedSettingPath, actualProperty.Name) + ' Assert.Equal(expectedOption.UnifiedSettingsOption, actualOption) + + ' End If + ' Next + + ' Dim hj = 8 + ' End Using + ' End Using + ' End Using + ' End Using + 'End Function + 'Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) ' Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) ' Dim expectedOption = expected.roslynOption diff --git a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj index 6ca1ded5756a1..e54d43268864e 100644 --- a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj +++ b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj @@ -9,6 +9,11 @@ false true + + + + + @@ -56,9 +61,6 @@ - - - diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb new file mode 100644 index 0000000000000..73bffbf1b8222 --- /dev/null +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb @@ -0,0 +1,20 @@ +' Licensed to the .NET Foundation under one or more agreements. +' The .NET Foundation licenses this file to you under the MIT license. +' See the LICENSE file in the project root for more information. + +Imports System.Text.Json +Imports System.Text.Json.Serialization + +Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings + Public Class UnifiedSettingsJsonResourceConverter + Inherits JsonConverter(Of String) + + Public Overrides Sub Write(writer As Utf8JsonWriter, value As String, options As JsonSerializerOptions) + Throw New NotImplementedException() + End Sub + + Public Overrides Function Read(ByRef reader As Utf8JsonReader, typeToConvert As Type, options As JsonSerializerOptions) As String + Throw New NotImplementedException() + End Function + End Class +End Namespace diff --git a/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj b/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj index 00ff829d6b33c..491f2a1e80c77 100644 --- a/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj +++ b/src/VisualStudio/VisualBasic/Impl/Microsoft.VisualStudio.LanguageServices.VisualBasic.vbproj @@ -47,6 +47,7 @@ + diff --git a/src/Workspaces/CoreTestUtilities/Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj b/src/Workspaces/CoreTestUtilities/Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj index d0f1477e85b71..33edabf4394ff 100644 --- a/src/Workspaces/CoreTestUtilities/Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj +++ b/src/Workspaces/CoreTestUtilities/Microsoft.CodeAnalysis.Workspaces.Test.Utilities.csproj @@ -62,9 +62,9 @@ - - - + + + From d15cb2acc76ed5b67d6ec08baa3e9c47aa97b692 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 17:14:34 -0800 Subject: [PATCH 14/45] Move to C#! --- ...o.LanguageServices.CSharp.UnitTests.csproj | 4 ---- .../Roslyn.VisualStudio.Next.UnitTests.csproj | 8 +++++++- .../TestModel/UnifiedSettingBase.cs | 2 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 10 ++++++++-- .../UnifiedSettingsJsonResourceConverter.vb | 20 ------------------- 5 files changed, 16 insertions(+), 28 deletions(-) delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb diff --git a/src/VisualStudio/CSharp/Test/Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj b/src/VisualStudio/CSharp/Test/Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj index 22661423096ba..cab7be9c43233 100644 --- a/src/VisualStudio/CSharp/Test/Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj +++ b/src/VisualStudio/CSharp/Test/Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests.csproj @@ -80,8 +80,4 @@ - - - - \ No newline at end of file diff --git a/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj b/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj index 15438d02432fc..ffd478efc1217 100644 --- a/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj +++ b/src/VisualStudio/Core/Test.Next/Roslyn.VisualStudio.Next.UnitTests.csproj @@ -67,6 +67,12 @@ - + + + + + + + \ No newline at end of file diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 6b30182109f7a..14d71d31bcd21 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -6,7 +6,7 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel { - internal abstract record UnifiedSettingBase + internal abstract record UnifiedSettingBase() { [JsonPropertyName("title")] public required string Title { get; init; } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index b76a09b0532f1..0fb16436c1214 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -5,7 +5,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Xunit; @@ -14,9 +17,12 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings public class UnifiedSettingsTests { [Fact] - public Task VisualBasicIntellisenseTest() + public async Task VisualBasicIntellisenseTest() { - + using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); + using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + var properties = jsonDocument!.Root["properties"]; } } } diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb deleted file mode 100644 index 73bffbf1b8222..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsJsonResourceConverter.vb +++ /dev/null @@ -1,20 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports System.Text.Json -Imports System.Text.Json.Serialization - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings - Public Class UnifiedSettingsJsonResourceConverter - Inherits JsonConverter(Of String) - - Public Overrides Sub Write(writer As Utf8JsonWriter, value As String, options As JsonSerializerOptions) - Throw New NotImplementedException() - End Sub - - Public Overrides Function Read(ByRef reader As Utf8JsonReader, typeToConvert As Type, options As JsonSerializerOptions) As String - Throw New NotImplementedException() - End Function - End Class -End Namespace From 4d1f33d4f658508d4a9ef335c19e5afa6638aee9 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 18:03:52 -0800 Subject: [PATCH 15/45] Add converter --- .../TestModel/ResourceConverter.cs | 24 ++++++++ .../UnifiedSettings/TestModel/Utilities.cs | 55 +++++++++++++++++++ .../UnifiedSettings/TestModels/Utilities.vb | 43 --------------- 3 files changed, 79 insertions(+), 43 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs new file mode 100644 index 0000000000000..3bef59fa13a00 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +{ + internal class ResourceConverter : JsonConverter + { + public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var locReference = reader.GetString()!; + return Utilities.EvalResource(locReference); + } + + public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs new file mode 100644 index 0000000000000..cfd9d79bd380d --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs @@ -0,0 +1,55 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using Microsoft.VisualStudio.LanguageServices; +using Microsoft.VisualStudio.LanguageServices.CSharp; +using Roslyn.Utilities; +using CSharpPackage = Microsoft.VisualStudio.LanguageServices.CSharp.VSPackage; +using VisualBasicPackage = Microsoft.VisualStudio.LanguageServices.VisualBasic.VSPackage; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +{ + internal static class Utilities + { + private const string CSharpLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.CSharp.dll"; + + private const string VisualBasicLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll"; + + private const string LanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.dll"; + + public static string EvalResource(string resourceReference) + { + // Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters + var resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1); + var resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1); + var culture = new CultureInfo("en"); + if (Guid.TryParse(resources, out var packageGuid)) + { + if (packageGuid.Equals(Guids.CSharpPackageId)) + { + return CSharpPackage.ResourceManager.GetString(resourcesIdentifier, culture); + } + else if (packageGuid.Equals(Guids.VisualBasicPackageId)) + { + return VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture); + } + else + { + throw ExceptionUtilities.Unreachable(); + } + } + + var resourceDll = resourceReference[(resourceReference.IndexOf("\\") + 1)..]; + return resourceDll switch + { + CSharpLanguageServiceDllName => CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture), + VisualBasicLanguageServiceDllName => VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture), + LanguageServiceDllName => ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture), + _ => throw ExceptionUtilities.UnexpectedValue(resourceDll) + }; + } + } +} diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb index 8eba26629aea3..36f1dbfecbdfb 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb @@ -9,47 +9,4 @@ Imports Microsoft.VisualStudio.LanguageServices.VisualBasic Imports Microsoft.CodeAnalysis Friend Module Utilities - Private Const CSharpLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.CSharp.dll" - - Private Const VisualBasicLanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll" - - Private Const LanguageServiceDllName As String = "Microsoft.VisualStudio.LanguageServices.dll" - - Friend Function EvalResource(resourceReference As String) As String - ' Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters - Dim resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1) - Dim resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1) - Dim resourceDll As String = Nothing - ' We reference the string in two ways - ' 1. "@102;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" where the guid is the package guid. It is the recommended way to locate string. - ' 2. "@Analysis;..\\Microsoft.VisualStudio.LanguageServices.dll". It is a special way we asked to locate string - Dim localizedString As String = Nothing - Dim culture = New CultureInfo("en") - Dim packageGuid As Guid = Nothing - If Guid.TryParse(resources, packageGuid) Then - If packageGuid = Guids.CSharpPackageId Then - Return CSharp.VSPackage.ResourceManager.GetString(resourcesIdentifier) - ElseIf packageGuid = Guids.VisualBasicPackageId Then - Return VisualBasic.VSPackage.ResourceManager.GetString(resourcesIdentifier) - Else - Assert.Fail($"Unexpected package Id: {packageGuid}") - End If - Else - resourceDll = resourceReference.Substring(resourceReference.IndexOf("\") + 1) - End If - - Select Case resourceDll - Case CSharpLanguageServiceDllName - localizedString = CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case VisualBasicLanguageServiceDllName - localizedString = BasicVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case LanguageServiceDllName - localizedString = ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture) - Case Else - Assert.Fail($"Resources should only the fetched from {CSharpLanguageServiceDllName}, {VisualBasicLanguageServiceDllName} or {LanguageServiceDllName}.") - End Select - - Assert.NotNull(localizedString) - Return localizedString - End Function End Module From db9a31bf8796360c8f63e598bae1ac0ddee16db7 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 13 Dec 2024 18:15:27 -0800 Subject: [PATCH 16/45] Add setting --- .../UnifiedSettings/TestModel/ExpectedSetting.cs | 15 +++++++++++++++ .../TestModel/UnifiedSettingBase.cs | 1 + 2 files changed, 16 insertions(+) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs new file mode 100644 index 0000000000000..21999c70dc8a6 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.CodeAnalysis.Options; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +{ + internal class ExpectedSetting(string path, IOption2 option, UnifiedSettingBase setting) + { + public string ExpectedUnifiedSettingsPath => path; + public IOption2 Option => option; + public UnifiedSettingBase ExpectedUnifiedSetting => setting; + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 14d71d31bcd21..f655961155a3b 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -9,6 +9,7 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel internal abstract record UnifiedSettingBase() { [JsonPropertyName("title")] + [JsonConverter(typeof(ResourceConverter))] public required string Title { get; init; } [JsonPropertyName("type")] From f9d6f864a48e05ad9afd762b5cd6e5e43b422523 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 16 Dec 2024 11:05:55 -0800 Subject: [PATCH 17/45] Modify test model --- .../TestModel/ExpectedSetting.cs | 30 +++++++++ .../TestModel/UnifiedSettingBase.cs | 61 +++++++++++++++++-- .../UnifiedSettings/UnifiedSettingsTests.cs | 17 ++++++ .../VisualBasicUnifiedSettingsTests.vb | 2 +- .../UnifiedSettings/TestModels/Input.vb | 2 +- 5 files changed, 104 insertions(+), 8 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs index 21999c70dc8a6..6c290a3f515cd 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs @@ -11,5 +11,35 @@ internal class ExpectedSetting(string path, IOption2 option, UnifiedSettingBase public string ExpectedUnifiedSettingsPath => path; public IOption2 Option => option; public UnifiedSettingBase ExpectedUnifiedSetting => setting; + + public static ExpectedSetting Create( + string ExpectedUnifiedSettingsPath, + IOption2 roslynOption, + string title, + int order, + T defaultValue, + (IOption2 featureFlagOption, object value) featureFlagAndExperimentValue = default, + (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, + string? languageName = null) + { + var migration = new Migration + { + Pass = new Pass() + { + Input = Input(roslynOption, languageName) + } + }; + + var alternativeDefault = featureFlagAndExperimentValue is not default + ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value) + : null; + + var enableWhen = enableWhenOptionAndValue is not default + ? $"config:{enableWhen}" + + + + + } } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index f655961155a3b..08a9d3c0c22c0 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -3,6 +3,11 @@ // See the LICENSE file in the project root for more information. using System.Text.Json.Serialization; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Options; +using Roslyn.Utilities; +using Xunit; +using static Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel { @@ -36,11 +41,19 @@ internal record UnifiedSettingsOption : UnifiedSettingBase public record AlternativeDefault { - [JsonPropertyName("FlagName")] - public required string FlagName { get; init; } + [JsonPropertyName("flagName")] + public string FlagName { get; } - [JsonPropertyName("Default")] - public required T Default { get; init; } + [JsonPropertyName("default")] + public T Default { get; } + + public AlternativeDefault(IOption2 featureFlagOption, T defaultValue) + { + var optionStorage = Storages[featureFlagOption.Definition.ConfigName]; + Assert.IsType(optionStorage); + FlagName = ((FeatureFlagStorage)optionStorage).FlagName; + Default = defaultValue; + } } internal record Migration @@ -58,9 +71,45 @@ internal record Pass internal record Input { [JsonPropertyName("store")] - public required string Store { get; init; } + public string Store { get; } [JsonPropertyName("path")] - public required string Path { get; init; } + public string Path { get; } + + public Input(IOption2 option, string? languageName = null) + { + Store = GetStore(option); + Assert.True(option is IPerLanguageValuedOption && languageName is null); + Path = GetPath(option, languageName); + } + + private static string GetStore(IOption2 option) + { + var optionStorage = Storages[option.Definition.ConfigName]; + return optionStorage switch + { + RoamingProfileStorage => "SettingsManager", + LocalUserProfileStorage => "VsUserSettingsRegistry", + _ => throw ExceptionUtilities.Unreachable() + }; + } + + private static string GetPath(IOption2 option, string? languageName) + { + var languageId = languageName switch + { + LanguageNames.CSharp => "CSharp", + LanguageNames.VisualBasic => "VisualBasic", + null => string.Empty, + }; + + var optionStorage = Storages[option.Definition.ConfigName]; + return option switch + { + RoamingProfileStorage roamingProfile => roamingProfile.Key.Replace("%LANGUAGE%", languageId), + LocalUserProfileStorage userProfileStorage => $"{userProfileStorage.Path}\\{userProfileStorage.Key}" + _ => throw ExceptionUtilities.UnexpectedValue(option) + }; + } } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 0fb16436c1214..fc1f5064f7928 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -4,18 +4,35 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using System.Reflection; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Threading.Tasks; +using Microsoft.CodeAnalysis.Completion; +using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings { public class UnifiedSettingsTests { + private static readonly ImmutableArray s_expectedIntellisenseSettings = [ + new ExpectedSetting("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", + CompletionOptionsStorage.TriggerOnTypingLetters, + new UnifiedSettingsOption() + { + Title = "Show completion list after a character is typed", + Order = 0, + Default = true, + AlternativeDefault = null, + EnableWhen = null, + Type = "Boolean", + Migration = null + })]; + [Fact] public async Task VisualBasicIntellisenseTest() { diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index a1d05b5a7a6d9..b1876dc631900 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -128,7 +128,7 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") Dim jsonDocument = Await JsonNode.ParseAsync(registrationFileStream, documentOptions:=New JsonDocumentOptions() With {.CommentHandling = JsonCommentHandling.Skip}) - Dim properties = jsonDocument.Root("properties") + Dim properties = jsonDocument.Root.("properties") Dim j = 9 diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index 6807290080360..e6693b1ad5d09 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -5,7 +5,7 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices.Options -Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage +Imports Imports Newtonsoft.Json Imports Roslyn.Utilities From 2f7d9839ef0949a97cd5a8e5533022f6c8412cc8 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 16 Dec 2024 14:47:33 -0800 Subject: [PATCH 18/45] File scope namespace --- .../TestModel/AlternativeDefault.cs | 27 ++++ .../TestModel/ExpectedSetting.cs | 45 ------ .../UnifiedSettings/TestModel/Input.cs | 57 ++++++++ .../UnifiedSettings/TestModel/Migration.cs | 14 ++ .../UnifiedSettings/TestModel/Pass.cs | 13 ++ .../TestModel/UnifiedSettingBase.cs | 112 +++++---------- .../TestModel/UnifiedSettingsOption.cs | 16 +++ .../UnifiedSettings/TestModel/Utilities.cs | 63 +++++---- .../UnifiedSettings/UnifiedSettingsTests.cs | 48 +++---- .../VisualBasicUnifiedSettingsTests.vb | 1 - .../UnifiedSettings/TestModels/Input.vb | 128 +++++++++--------- 11 files changed, 280 insertions(+), 244 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs delete mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Pass.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs new file mode 100644 index 0000000000000..32d3da5fff445 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; +using Microsoft.CodeAnalysis.Options; +using Xunit; +using static Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +public record AlternativeDefault +{ + [JsonPropertyName("flagName")] + public string FlagName { get; } + + [JsonPropertyName("default")] + public T Default { get; } + + public AlternativeDefault(IOption2 featureFlagOption, T defaultValue) + { + var optionStorage = Storages[featureFlagOption.Definition.ConfigName]; + Assert.IsType(optionStorage); + FlagName = ((FeatureFlagStorage)optionStorage).FlagName; + Default = defaultValue; + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs deleted file mode 100644 index 6c290a3f515cd..0000000000000 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ExpectedSetting.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using Microsoft.CodeAnalysis.Options; - -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel -{ - internal class ExpectedSetting(string path, IOption2 option, UnifiedSettingBase setting) - { - public string ExpectedUnifiedSettingsPath => path; - public IOption2 Option => option; - public UnifiedSettingBase ExpectedUnifiedSetting => setting; - - public static ExpectedSetting Create( - string ExpectedUnifiedSettingsPath, - IOption2 roslynOption, - string title, - int order, - T defaultValue, - (IOption2 featureFlagOption, object value) featureFlagAndExperimentValue = default, - (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, - string? languageName = null) - { - var migration = new Migration - { - Pass = new Pass() - { - Input = Input(roslynOption, languageName) - } - }; - - var alternativeDefault = featureFlagAndExperimentValue is not default - ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value) - : null; - - var enableWhen = enableWhenOptionAndValue is not default - ? $"config:{enableWhen}" - - - - - } - } -} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs new file mode 100644 index 0000000000000..d2f02aea6b5a8 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Options; +using Roslyn.Utilities; +using Xunit; +using static Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Input +{ + [JsonPropertyName("store")] + public string Store { get; } + + [JsonPropertyName("path")] + public string Path { get; } + + public Input(IOption2 option, string? languageName = null) + { + Assert.False(option is IPerLanguageValuedOption && languageName is null); + Store = GetStore(option); + Path = GetPath(option, languageName); + } + + private static string GetStore(IOption2 option) + { + var optionStorage = Storages[option.Definition.ConfigName]; + return optionStorage switch + { + RoamingProfileStorage => "SettingsManager", + LocalUserProfileStorage => "VsUserSettingsRegistry", + _ => throw ExceptionUtilities.Unreachable() + }; + } + + private static string GetPath(IOption2 option, string? languageName) + { + var languageId = languageName switch + { + LanguageNames.CSharp => "CSharp", + LanguageNames.VisualBasic => "VisualBasic", + null => string.Empty, + }; + + var optionStorage = Storages[option.Definition.ConfigName]; + return optionStorage switch + { + RoamingProfileStorage roamingProfile => roamingProfile.Key.Replace("%LANGUAGE%", languageId), + LocalUserProfileStorage userProfileStorage => $"{userProfileStorage.Path}\\{userProfileStorage.Key}", + _ => throw ExceptionUtilities.UnexpectedValue(option) + }; + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs new file mode 100644 index 0000000000000..a25bba7a5d821 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Migration +{ + [JsonPropertyName("pass")] + public required Pass Pass { get; init; } +} + diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Pass.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Pass.cs new file mode 100644 index 0000000000000..a5681b04da612 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Pass.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Pass +{ + [JsonPropertyName("input")] + public required Input Input { get; init; } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 08a9d3c0c22c0..19472a5e03587 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -2,16 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Text.Json.Serialization; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; -using Xunit; -using static Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel { - internal abstract record UnifiedSettingBase() + internal abstract partial record UnifiedSettingBase() { [JsonPropertyName("title")] [JsonConverter(typeof(ResourceConverter))] @@ -28,87 +26,45 @@ internal abstract record UnifiedSettingBase() [JsonPropertyName("Migration")] public required Migration Migration { get; init; } - } - - internal record UnifiedSettingsOption : UnifiedSettingBase - { - [JsonPropertyName("Default")] - public required T Default { get; init; } - - [JsonPropertyName("AlternativeDefault")] - public AlternativeDefault? AlternativeDefault { get; init; } - } - - public record AlternativeDefault - { - [JsonPropertyName("flagName")] - public string FlagName { get; } - - [JsonPropertyName("default")] - public T Default { get; } - - public AlternativeDefault(IOption2 featureFlagOption, T defaultValue) - { - var optionStorage = Storages[featureFlagOption.Definition.ConfigName]; - Assert.IsType(optionStorage); - FlagName = ((FeatureFlagStorage)optionStorage).FlagName; - Default = defaultValue; - } - } - - internal record Migration - { - [JsonPropertyName("pass")] - public required Pass Pass { get; init; } - } - internal record Pass - { - [JsonPropertyName("input")] - public required Input Input { get; init; } - } - - internal record Input - { - [JsonPropertyName("store")] - public string Store { get; } - - [JsonPropertyName("path")] - public string Path { get; } - - public Input(IOption2 option, string? languageName = null) + public static UnifiedSettingsOption Create( + IOption2 onboaredOption, + string title, + int order, + T defaultValue, + (IOption2 featureFlagOption, object value) featureFlagAndExperimentValue = default, + (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, + string? languageName = null) { - Store = GetStore(option); - Assert.True(option is IPerLanguageValuedOption && languageName is null); - Path = GetPath(option, languageName); - } - - private static string GetStore(IOption2 option) - { - var optionStorage = Storages[option.Definition.ConfigName]; - return optionStorage switch + var migration = new Migration { - RoamingProfileStorage => "SettingsManager", - LocalUserProfileStorage => "VsUserSettingsRegistry", - _ => throw ExceptionUtilities.Unreachable() + Pass = new Pass() + { + Input = Input(onboaredOption, languageName) + } }; - } - private static string GetPath(IOption2 option, string? languageName) - { - var languageId = languageName switch - { - LanguageNames.CSharp => "CSharp", - LanguageNames.VisualBasic => "VisualBasic", - null => string.Empty, - }; + var type = onboaredOption.Definition.Type; + // If the option's type is nullable type, like bool?, we use bool in the registration file. + var underlyingType = Nullable.GetUnderlyingType(type); + var nonNullableType = underlyingType ?? type; + + var alternativeDefault = featureFlagAndExperimentValue is not default + ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value) + : null; + + var enableWhen = enableWhenOptionAndValue is not default + ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue]}='{enableWhenOptionAndValue.whenValue}'" + : null; - var optionStorage = Storages[option.Definition.ConfigName]; - return option switch + return new UnifiedSettingsOption() { - RoamingProfileStorage roamingProfile => roamingProfile.Key.Replace("%LANGUAGE%", languageId), - LocalUserProfileStorage userProfileStorage => $"{userProfileStorage.Path}\\{userProfileStorage.Key}" - _ => throw ExceptionUtilities.UnexpectedValue(option) + Title = title, + Type = nonNullableType.ToString().ToCamelCase(), + Order = order, + EnableWhen = enableWhen, + Migration = migration, + AlternativeDefault = alternativeDefault, }; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs new file mode 100644 index 0000000000000..b19197b98b60d --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record UnifiedSettingsOption : UnifiedSettingBase +{ + [JsonPropertyName("Default")] + public required T Default { get; init; } + + [JsonPropertyName("AlternativeDefault")] + public AlternativeDefault? AlternativeDefault { get; init; } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs index cfd9d79bd380d..49bc032d2b491 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs @@ -10,46 +10,45 @@ using CSharpPackage = Microsoft.VisualStudio.LanguageServices.CSharp.VSPackage; using VisualBasicPackage = Microsoft.VisualStudio.LanguageServices.VisualBasic.VSPackage; -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal static class Utilities { - internal static class Utilities - { - private const string CSharpLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.CSharp.dll"; + private const string CSharpLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.CSharp.dll"; - private const string VisualBasicLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll"; + private const string VisualBasicLanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.VisualBasic.dll"; - private const string LanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.dll"; + private const string LanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.dll"; - public static string EvalResource(string resourceReference) + public static string EvalResource(string resourceReference) + { + // Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters + var resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1); + var resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1); + var culture = new CultureInfo("en"); + if (Guid.TryParse(resources, out var packageGuid)) { - // Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters - var resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1); - var resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1); - var culture = new CultureInfo("en"); - if (Guid.TryParse(resources, out var packageGuid)) + if (packageGuid.Equals(Guids.CSharpPackageId)) { - if (packageGuid.Equals(Guids.CSharpPackageId)) - { - return CSharpPackage.ResourceManager.GetString(resourcesIdentifier, culture); - } - else if (packageGuid.Equals(Guids.VisualBasicPackageId)) - { - return VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture); - } - else - { - throw ExceptionUtilities.Unreachable(); - } + return CSharpPackage.ResourceManager.GetString(resourcesIdentifier, culture); } - - var resourceDll = resourceReference[(resourceReference.IndexOf("\\") + 1)..]; - return resourceDll switch + else if (packageGuid.Equals(Guids.VisualBasicPackageId)) { - CSharpLanguageServiceDllName => CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture), - VisualBasicLanguageServiceDllName => VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture), - LanguageServiceDllName => ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture), - _ => throw ExceptionUtilities.UnexpectedValue(resourceDll) - }; + return VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture); + } + else + { + throw ExceptionUtilities.Unreachable(); + } } + + var resourceDll = resourceReference[(resourceReference.IndexOf("\\") + 1)..]; + return resourceDll switch + { + CSharpLanguageServiceDllName => CSharpVSResources.ResourceManager.GetString(resourcesIdentifier, culture), + VisualBasicLanguageServiceDllName => VisualBasicPackage.ResourceManager.GetString(resourcesIdentifier, culture), + LanguageServiceDllName => ServicesVSResources.ResourceManager.GetString(resourcesIdentifier, culture), + _ => throw ExceptionUtilities.UnexpectedValue(resourceDll) + }; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index fc1f5064f7928..10a44c3083b0d 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -11,35 +11,35 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Threading.Tasks; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.Options; using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings; + +public class UnifiedSettingsTests { - public class UnifiedSettingsTests - { - private static readonly ImmutableArray s_expectedIntellisenseSettings = [ - new ExpectedSetting("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", - CompletionOptionsStorage.TriggerOnTypingLetters, - new UnifiedSettingsOption() - { - Title = "Show completion list after a character is typed", - Order = 0, - Default = true, - AlternativeDefault = null, - EnableWhen = null, - Type = "Boolean", - Migration = null - })]; + internal static readonly ImmutableDictionary s_optionToUnifiedSettingPath = ImmutableDictionary.Empty. + Add(CompletionOptionsStorage.TriggerOnTypingLetters, "textEditor.basic.intellisense.triggerCompletionOnTypingLetters"); - [Fact] - public async Task VisualBasicIntellisenseTest() - { - using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); - using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); - var jsonDocument = await JsonNode.ParseAsync(registrationFileStream, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); - var properties = jsonDocument!.Root["properties"]; - } + private static readonly ImmutableDictionary s_optionToExpectedUnifiedSettings = ImmutableDictionary.Empty. + Add(CompletionOptionsStorage.TriggerOnTypingLetters, UnifiedSettingBase.Create( + CompletionOptionsStorage.TriggerOnTypingLetters, + title: "Show completion list after a character is typed", + order: 0, + defaultValue: true, + featureFlagAndExperimentValue: default, + enableWhenOptionAndValue: default, + languageName: LanguageNames.VisualBasic)); + + [Fact] + public async Task VisualBasicIntellisenseTest() + { + using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); + using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + var properties = jsonDocument!.Root["properties"]; } } diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index b1876dc631900..8a9c9a311d11d 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -128,7 +128,6 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") Dim jsonDocument = Await JsonNode.ParseAsync(registrationFileStream, documentOptions:=New JsonDocumentOptions() With {.CommentHandling = JsonCommentHandling.Skip}) - Dim properties = jsonDocument.Root.("properties") Dim j = 9 diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb index e6693b1ad5d09..88d4cd850e60f 100644 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb @@ -2,76 +2,76 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.Options -Imports -Imports Newtonsoft.Json -Imports Roslyn.Utilities +'Imports Microsoft.CodeAnalysis +'Imports Microsoft.CodeAnalysis.Options +'Imports Microsoft.VisualStudio.LanguageServices.Options +'Imports +'Imports Newtonsoft.Json +'Imports Roslyn.Utilities -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class Input - - Public ReadOnly Property Store As String - - Public ReadOnly Property Path As String +'Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels +' Friend Class Input +' +' Public ReadOnly Property Store As String +' +' Public ReadOnly Property Path As String - Public Sub New(store As String, path As String) - Me.Store = store - Me.Path = path - End Sub +' Public Sub New(store As String, path As String) +' Me.Store = store +' Me.Path = path +' End Sub - Public Shared Function CreateInput([option] As IOption2) As Input - Dim configName = [option].Definition.ConfigName - Dim visualStudioStorage = Storages(configName) +' Public Shared Function CreateInput([option] As IOption2) As Input +' Dim configName = [option].Definition.ConfigName +' Dim visualStudioStorage = Storages(configName) - Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage)) - End Function +' Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage)) +' End Function - Public Shared Function CreateInput([option] As IPerLanguageValuedOption, languageName As String) As Input - Dim configName = [option].Definition.ConfigName - Dim visualStudioStorage = Storages(configName) - Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage, languageName)) - End Function +' Public Shared Function CreateInput([option] As IPerLanguageValuedOption, languageName As String) As Input +' Dim configName = [option].Definition.ConfigName +' Dim visualStudioStorage = Storages(configName) +' Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage, languageName)) +' End Function - Private Shared Function GetStore(storage As VisualStudioOptionStorage) As String - If TypeOf storage Is RoamingProfileStorage Then - Return "SettingsManager" - ElseIf TypeOf storage Is LocalUserProfileStorage Then - Return "VsUserSettingsRegistry" - Else - Throw ExceptionUtilities.Unreachable - End If - End Function +' Private Shared Function GetStore(storage As VisualStudioOptionStorage) As String +' If TypeOf storage Is RoamingProfileStorage Then +' Return "SettingsManager" +' ElseIf TypeOf storage Is LocalUserProfileStorage Then +' Return "VsUserSettingsRegistry" +' Else +' Throw ExceptionUtilities.Unreachable +' End If +' End Function - Private Shared Function GetPath(storage As VisualStudioOptionStorage, Optional languageName As String = Nothing) As String - If TypeOf storage Is RoamingProfileStorage Then - Dim roamingProfileStorage = DirectCast(storage, RoamingProfileStorage) - Return roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(If(languageName = Nothing, String.Empty, languageName))) - ElseIf TypeOf storage Is LocalUserProfileStorage Then - Dim localUserProfileStorage = DirectCast(storage, LocalUserProfileStorage) - Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.Key}" - Else - Throw ExceptionUtilities.Unreachable - End If - End Function +' Private Shared Function GetPath(storage As VisualStudioOptionStorage, Optional languageName As String = Nothing) As String +' If TypeOf storage Is RoamingProfileStorage Then +' Dim roamingProfileStorage = DirectCast(storage, RoamingProfileStorage) +' Return roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(If(languageName = Nothing, String.Empty, languageName))) +' ElseIf TypeOf storage Is LocalUserProfileStorage Then +' Dim localUserProfileStorage = DirectCast(storage, LocalUserProfileStorage) +' Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.Key}" +' Else +' Throw ExceptionUtilities.Unreachable +' End If +' End Function - Private Shared Function GetSubstituteLanguage(languageName As String) As String - Select Case languageName - Case LanguageNames.CSharp - Return "CSharp" - Case LanguageNames.VisualBasic - Return "VisualBasic" - Case Else - Return languageName - End Select - End Function +' Private Shared Function GetSubstituteLanguage(languageName As String) As String +' Select Case languageName +' Case LanguageNames.CSharp +' Return "CSharp" +' Case LanguageNames.VisualBasic +' Return "VisualBasic" +' Case Else +' Return languageName +' End Select +' End Function - Public Overrides Function Equals(obj As Object) As Boolean - Dim input = TryCast(obj, Input) - Return input IsNot Nothing AndAlso - Store = input.Store AndAlso - Path = input.Path - End Function - End Class -End Namespace +' Public Overrides Function Equals(obj As Object) As Boolean +' Dim input = TryCast(obj, Input) +' Return input IsNot Nothing AndAlso +' Store = input.Store AndAlso +' Path = input.Path +' End Function +' End Class +'End Namespace From a66774b707eda9eaa7ae6ed0f82dbcafa7c40abe Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 16 Dec 2024 16:33:24 -0800 Subject: [PATCH 19/45] Add enum model --- .../TestModel/EnumToInteger.cs | 16 ++++++++++++++ .../UnifiedSettings/TestModel/Map.cs | 21 +++++++++++++++++++ .../UnifiedSettings/TestModel/Migration.cs | 16 +++++++++++++- .../TestModel/UnifiedSettingBase.cs | 6 +++--- .../TestModel/UnifiedSettingsEnumOption.cs | 12 +++++++++++ 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs new file mode 100644 index 0000000000000..dc1309bd0acd2 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record EnumToInteger +{ + [JsonPropertyName("input")] + public required Input Input { get; init; } + + [JsonPropertyName("map")] + public required Map Map { get; init; } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs new file mode 100644 index 0000000000000..244b4232ec587 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Map +{ + public required EnumToValuePair[] EnumValueMatches { get; init; } + + internal record EnumToValuePair + { + [JsonPropertyName("result")] + public required string Result { get; init; } + + [JsonPropertyName("match")] + public required int Match { get; init; } + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs index a25bba7a5d821..5d5d58b1d7310 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs @@ -2,13 +2,27 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record Migration { + public Migration(EnumToInteger enumToInteger) + { + EnumToInteger = enumToInteger; + } + + public Migration(Pass? pass) + { + Pass = pass; + } + [JsonPropertyName("pass")] - public required Pass Pass { get; init; } + public Pass? Pass { get; init; } + + [JsonPropertyName("EnumToInteger")] + public EnumToInteger? EnumToInteger { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 19472a5e03587..205ce7858895a 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -28,7 +28,7 @@ internal abstract partial record UnifiedSettingBase() public required Migration Migration { get; init; } public static UnifiedSettingsOption Create( - IOption2 onboaredOption, + IOption2 onboardedOption, string title, int order, T defaultValue, @@ -40,11 +40,11 @@ public static UnifiedSettingsOption Create( { Pass = new Pass() { - Input = Input(onboaredOption, languageName) + Input = Input(onboardedOption, languageName) } }; - var type = onboaredOption.Definition.Type; + var type = onboardedOption.Definition.Type; // If the option's type is nullable type, like bool?, we use bool in the registration file. var underlyingType = Nullable.GetUnderlyingType(type); var nonNullableType = underlyingType ?? type; diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs new file mode 100644 index 0000000000000..ed6600437cf64 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record UnifiedSettingsEnumOption : UnifiedSettingsOption +{ + public required string[] @Enum { get; init; } + + public required string[] EnumLabel { get; init; } +} From fd492ee00ff18563ca5c3ccfc5c1757ba05b44d1 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 16 Dec 2024 17:51:13 -0800 Subject: [PATCH 20/45] Add enum constructor --- .../UnifiedSettings/TestModel/Migration.cs | 6 +- .../TestModel/UnifiedSettingBase.cs | 94 ++++++++++++++++--- .../UnifiedSettings/UnifiedSettingsTests.cs | 2 +- 3 files changed, 84 insertions(+), 18 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs index 5d5d58b1d7310..6a8cd7c00152c 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs @@ -14,15 +14,15 @@ public Migration(EnumToInteger enumToInteger) EnumToInteger = enumToInteger; } - public Migration(Pass? pass) + public Migration(Pass pass) { Pass = pass; } [JsonPropertyName("pass")] - public Pass? Pass { get; init; } + public Pass? Pass { get; } [JsonPropertyName("EnumToInteger")] - public EnumToInteger? EnumToInteger { get; init; } + public EnumToInteger? EnumToInteger { get; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 205ce7858895a..b531ca76b8e1c 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -3,9 +3,11 @@ // See the LICENSE file in the project root for more information. using System; +using System.Linq; using System.Text.Json.Serialization; using Microsoft.CodeAnalysis.Options; using Roslyn.Utilities; +using Xunit; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel { @@ -27,26 +29,23 @@ internal abstract partial record UnifiedSettingBase() [JsonPropertyName("Migration")] public required Migration Migration { get; init; } - public static UnifiedSettingsOption Create( + public static UnifiedSettingsOption CreateOption( IOption2 onboardedOption, string title, int order, - T defaultValue, - (IOption2 featureFlagOption, object value) featureFlagAndExperimentValue = default, + T? defaultValue = default, + (IOption2 featureFlagOption, T value) featureFlagAndExperimentValue = default, (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, - string? languageName = null) + string? languageName = null) where T : notnull { - var migration = new Migration - { - Pass = new Pass() - { - Input = Input(onboardedOption, languageName) - } - }; - + var migration = new Migration(new Pass { Input = new Input(onboardedOption, languageName) }); var type = onboardedOption.Definition.Type; // If the option's type is nullable type, like bool?, we use bool in the registration file. var underlyingType = Nullable.GetUnderlyingType(type); + if (underlyingType is not null) + { + Assert.True(featureFlagAndExperimentValue.value is not default); + } var nonNullableType = underlyingType ?? type; var alternativeDefault = featureFlagAndExperimentValue is not default @@ -54,10 +53,25 @@ public static UnifiedSettingsOption Create( : null; var enableWhen = enableWhenOptionAndValue is not default - ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue]}='{enableWhenOptionAndValue.whenValue}'" + ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.enableWhenOption]}='{enableWhenOptionAndValue.whenValue}'" : null; - return new UnifiedSettingsOption() + var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + // If the option default value is null, it means the option is in experiment mode and is hidden by a feature flag. + // In Unified Settings it is not allowed and should be replaced by using the alternative default. + // Like: + // "textEditor.csharp.intellisense.showNewSnippetExperience": { + // "type": "boolean", + // "default": false, + // "alternateDefault": { + // "flagName": "Roslyn.SnippetCompletion", + // "default": true + // } + // } + // so please specify a non-null default value. + Assert.NotNull(expectedDefault); + + return new UnifiedSettingsOption { Title = title, Type = nonNullableType.ToString().ToCamelCase(), @@ -65,6 +79,58 @@ public static UnifiedSettingsOption Create( EnableWhen = enableWhen, Migration = migration, AlternativeDefault = alternativeDefault, + Default = (T)expectedDefault + }; + } + + public static UnifiedSettingsEnumOption CreateEnumOption( + IOption2 onboardedOption, + string title, + int order, + T? defaultValue, + string[] enumLabels, + T[]? enumValues = null, + (IOption2 featureFlagOption, T value) featureFlagAndExperimentValue = default, + (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, + string? languageName = null) where T : Enum + { + var type = onboardedOption.Definition.Type; + // If the option's type is nullable type, we use the original type in the registration file. + var nonNullableType = Nullable.GetUnderlyingType(type) ?? type; + Assert.Equal(typeof(T), nonNullableType); + + var expectedEnumValues = enumValues ?? Enum.GetValues(nonNullableType).Cast().ToArray(); + var migration = new Migration(new EnumToInteger() + { + Input = new Input(onboardedOption, languageName), + Map = new Map() + { + EnumValueMatches = expectedEnumValues.SelectAsArray(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = value }) + } + }); + + var alternativeDefault = featureFlagAndExperimentValue is not default + ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value.ToString().ToCamelCase()) + : null; + + var enableWhen = enableWhenOptionAndValue is not default + ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.enableWhenOption]}='{enableWhenOptionAndValue.whenValue}'" + : null; + + var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + Assert.NotNull(expectedDefault); + + return new UnifiedSettingsEnumOption() + { + Title = title, + Type = "string", + Enum = expectedEnumValues.Select(value => value.ToString()).ToArray(), + EnumLabel = enumLabels, + Order = order, + EnableWhen = enableWhen, + Migration = migration, + AlternativeDefault = alternativeDefault, + Default = expectedDefault.ToString().ToCamelCase(), }; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 10a44c3083b0d..7b886bbfb5572 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -25,7 +25,7 @@ public class UnifiedSettingsTests Add(CompletionOptionsStorage.TriggerOnTypingLetters, "textEditor.basic.intellisense.triggerCompletionOnTypingLetters"); private static readonly ImmutableDictionary s_optionToExpectedUnifiedSettings = ImmutableDictionary.Empty. - Add(CompletionOptionsStorage.TriggerOnTypingLetters, UnifiedSettingBase.Create( + Add(CompletionOptionsStorage.TriggerOnTypingLetters, UnifiedSettingBase.CreateOption( CompletionOptionsStorage.TriggerOnTypingLetters, title: "Show completion list after a character is typed", order: 0, From fc8c1f8705621efe429e15471bcfea777ecb8ce8 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 17 Dec 2024 15:59:31 -0800 Subject: [PATCH 21/45] Delete unused types --- .../TestModel/AlternativeDefault.cs | 15 ++-- .../UnifiedSettings/TestModel/Input.cs | 13 ++- .../UnifiedSettings/TestModel/Migration.cs | 17 +--- .../TestModel/UnifiedSettingBase.cs | 49 +++++----- .../TestModel/UnifiedSettingsEnumOption.cs | 4 + .../TestModel/UnifiedSettingsOption.cs | 4 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 21 ++++- .../VisualBasicUnifiedSettingsTests.vb | 90 +++++++++---------- .../UnifiedSettings/ExpectedUnifiedSetting.vb | 22 ----- .../TestModels/AlternateDefault.vb | 37 -------- .../TestModels/EnumIntegerToString.vb | 19 ---- .../UnifiedSettings/TestModels/Input.vb | 77 ---------------- .../UnifiedSettings/TestModels/Map.vb | 19 ---- .../UnifiedSettings/TestModels/Migration.vb | 22 ----- .../TestModels/MigrationType.vb | 22 ----- .../UnifiedSettings/TestModels/Pass.vb | 19 ---- .../TestModels/ResourceConverter.vb | 33 ------- .../TestModels/UnifiedSettingsCategory.vb | 21 ----- .../TestModels/UnifiedSettingsEnumOption.vb | 36 -------- .../TestModels/UnifiedSettingsOption.vb | 36 -------- .../TestModels/UnifiedSettingsOptionBase.vb | 55 ------------ .../UnifiedSettings/TestModels/Utilities.vb | 12 --- 22 files changed, 117 insertions(+), 526 deletions(-) delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs index 32d3da5fff445..9862b6c608603 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs @@ -9,13 +9,18 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; -public record AlternativeDefault +internal record AlternativeDefault { - [JsonPropertyName("flagName")] - public string FlagName { get; } + public string FlagName { get; init; } - [JsonPropertyName("default")] - public T Default { get; } + public T Default { get; init; } + + [JsonConstructor] + public AlternativeDefault(string flagName, T @default) + { + FlagName = flagName; + Default = @default; + } public AlternativeDefault(IOption2 featureFlagOption, T defaultValue) { diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs index d2f02aea6b5a8..fd4cb12b0bb53 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Input.cs @@ -14,10 +14,17 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record Input { [JsonPropertyName("store")] - public string Store { get; } + public string Store { get; init; } [JsonPropertyName("path")] - public string Path { get; } + public string Path { get; init; } + + [JsonConstructor] + public Input(string store, string path) + { + Store = store; + Path = path; + } public Input(IOption2 option, string? languageName = null) { @@ -43,7 +50,7 @@ private static string GetPath(IOption2 option, string? languageName) { LanguageNames.CSharp => "CSharp", LanguageNames.VisualBasic => "VisualBasic", - null => string.Empty, + _ => string.Empty, }; var optionStorage = Storages[option.Definition.ConfigName]; diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs index 6a8cd7c00152c..85fcd930cb004 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs @@ -2,27 +2,16 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record Migration { - public Migration(EnumToInteger enumToInteger) - { - EnumToInteger = enumToInteger; - } - - public Migration(Pass pass) - { - Pass = pass; - } - [JsonPropertyName("pass")] - public Pass? Pass { get; } + public Pass? Pass { get; init; } - [JsonPropertyName("EnumToInteger")] - public EnumToInteger? EnumToInteger { get; } + [JsonPropertyName("enumToInteger")] + public EnumToInteger? EnumToInteger { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index b531ca76b8e1c..c8297f8eb29a6 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -26,7 +26,7 @@ internal abstract partial record UnifiedSettingBase() [JsonPropertyName("enableWhen")] public string? EnableWhen { get; init; } - [JsonPropertyName("Migration")] + [JsonPropertyName("migration")] public required Migration Migration { get; init; } public static UnifiedSettingsOption CreateOption( @@ -34,26 +34,26 @@ public static UnifiedSettingsOption CreateOption( string title, int order, T? defaultValue = default, - (IOption2 featureFlagOption, T value) featureFlagAndExperimentValue = default, - (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, + (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, + (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, string? languageName = null) where T : notnull { - var migration = new Migration(new Pass { Input = new Input(onboardedOption, languageName) }); + var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; var type = onboardedOption.Definition.Type; // If the option's type is nullable type, like bool?, we use bool in the registration file. var underlyingType = Nullable.GetUnderlyingType(type); if (underlyingType is not null) { - Assert.True(featureFlagAndExperimentValue.value is not default); + Assert.True(featureFlagAndExperimentValue is not null); } var nonNullableType = underlyingType ?? type; - var alternativeDefault = featureFlagAndExperimentValue is not default - ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value) + var alternativeDefault = featureFlagAndExperimentValue is not null + ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value) : null; - var enableWhen = enableWhenOptionAndValue is not default - ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.enableWhenOption]}='{enableWhenOptionAndValue.whenValue}'" + var enableWhen = enableWhenOptionAndValue is not null + ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" : null; var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; @@ -74,7 +74,7 @@ public static UnifiedSettingsOption CreateOption( return new UnifiedSettingsOption { Title = title, - Type = nonNullableType.ToString().ToCamelCase(), + Type = nonNullableType.Name.ToCamelCase(), Order = order, EnableWhen = enableWhen, Migration = migration, @@ -90,8 +90,8 @@ public static UnifiedSettingsEnumOption CreateEnumOption( T? defaultValue, string[] enumLabels, T[]? enumValues = null, - (IOption2 featureFlagOption, T value) featureFlagAndExperimentValue = default, - (IOption2 enableWhenOption, object whenValue) enableWhenOptionAndValue = default, + (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, + (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, string? languageName = null) where T : Enum { var type = onboardedOption.Definition.Type; @@ -99,22 +99,25 @@ public static UnifiedSettingsEnumOption CreateEnumOption( var nonNullableType = Nullable.GetUnderlyingType(type) ?? type; Assert.Equal(typeof(T), nonNullableType); - var expectedEnumValues = enumValues ?? Enum.GetValues(nonNullableType).Cast().ToArray(); - var migration = new Migration(new EnumToInteger() + var expectedEnumValues = enumValues ?? [.. Enum.GetValues(nonNullableType).Cast()]; + var migration = new Migration { - Input = new Input(onboardedOption, languageName), - Map = new Map() + EnumToInteger = new EnumToInteger { - EnumValueMatches = expectedEnumValues.SelectAsArray(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = value }) + Input = new Input(onboardedOption, languageName), + Map = new Map() + { + EnumValueMatches = [.. expectedEnumValues.Select(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] + } } - }); + }; - var alternativeDefault = featureFlagAndExperimentValue is not default - ? new AlternativeDefault(featureFlagAndExperimentValue.featureFlagOption, featureFlagAndExperimentValue.value.ToString().ToCamelCase()) + var alternativeDefault = featureFlagAndExperimentValue is not null + ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value.ToString().ToCamelCase()) : null; - var enableWhen = enableWhenOptionAndValue is not default - ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.enableWhenOption]}='{enableWhenOptionAndValue.whenValue}'" + var enableWhen = enableWhenOptionAndValue is not null + ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" : null; var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; @@ -124,7 +127,7 @@ public static UnifiedSettingsEnumOption CreateEnumOption( { Title = title, Type = "string", - Enum = expectedEnumValues.Select(value => value.ToString()).ToArray(), + Enum = [.. expectedEnumValues.Select(value => value.ToString())], EnumLabel = enumLabels, Order = order, EnableWhen = enableWhen, diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs index ed6600437cf64..b4092a08f7d5a 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -2,11 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Text.Json.Serialization; + namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record UnifiedSettingsEnumOption : UnifiedSettingsOption { + [JsonPropertyName("enum")] public required string[] @Enum { get; init; } + [JsonPropertyName("enumLabel")] public required string[] EnumLabel { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs index b19197b98b60d..90b9c673b5e59 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs @@ -8,9 +8,9 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record UnifiedSettingsOption : UnifiedSettingBase { - [JsonPropertyName("Default")] + [JsonPropertyName("default")] public required T Default { get; init; } - [JsonPropertyName("AlternativeDefault")] + [JsonPropertyName("alternativeDefault")] public AlternativeDefault? AlternativeDefault { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 7b886bbfb5572..3c8aa77b848a3 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; using Microsoft.CodeAnalysis.Options; +using Roslyn.Utilities; using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; @@ -30,8 +31,8 @@ public class UnifiedSettingsTests title: "Show completion list after a character is typed", order: 0, defaultValue: true, - featureFlagAndExperimentValue: default, - enableWhenOptionAndValue: default, + featureFlagAndExperimentValue: null, + enableWhenOptionAndValue: null, languageName: LanguageNames.VisualBasic)); [Fact] @@ -39,7 +40,19 @@ public async Task VisualBasicIntellisenseTest() { using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); - var jsonDocument = await JsonNode.ParseAsync(registrationFileStream, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); - var properties = jsonDocument!.Root["properties"]; + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + var expectedPrefix = "textEditor.basic.intellisense"; + var properties = jsonDocument!.Root["properties"]!.AsObject() + .Where(jsonObject => jsonObject.Key.StartsWith(expectedPrefix)) + .SelectAsArray(jsonObject => jsonObject.Value); + // Assert.Equal(s_optionToExpectedUnifiedSettings.Count, properties.Length); + foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_optionToExpectedUnifiedSettings, (actual, expected) => (actual, expected))) + { + // We only have bool and enum option now. + UnifiedSettingBase actualSettings = expectedOption.Definition.Type.IsEnum + ? actualJson.Deserialize()! + : actualJson.Deserialize>()!; + Assert.Equal(expectedSetting, actualSettings); + } } } diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index 8a9c9a311d11d..b54bcbfe29cdf 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -76,52 +76,52 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Return MyBase.GetOptionsDefaultValue([option]) End Function - - Public Async Function CategoriesTest() As Task - Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Using reader = New StreamReader(registrationFileStream) - Dim registrationFile = Await reader.ReadToEndAsync() - Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) - Dim categories = registrationJsonObject.Property("categories") - Dim nameToCategories = categories.Value.Children(Of JProperty).ToDictionary( - Function(jProperty) jProperty.Name, - Function(jProperty) jProperty.Value.ToObject(Of UnifiedSettingsCategory)) - - Assert.True(nameToCategories.ContainsKey("textEditor.basic")) - Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) - - Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) - Assert.Equal("IntelliSense", nameToCategories("textEditor.basic.intellisense").Title) - End Using - End Using - End Function + ' + 'Public Async Function CategoriesTest() As Task + ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") + ' Using reader = New StreamReader(registrationFileStream) + ' Dim registrationFile = Await reader.ReadToEndAsync() + ' Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) + ' Dim categories = registrationJsonObject.Property("categories") + ' Dim nameToCategories = categories.Value.Children(Of JProperty).ToDictionary( + ' Function(jProperty) jProperty.Name, + ' Function(jProperty) jProperty.Value.ToObject(Of UnifiedSettingsCategory)) + + ' Assert.True(nameToCategories.ContainsKey("textEditor.basic")) + ' Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) + + ' Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) + ' Assert.Equal("IntelliSense", nameToCategories("textEditor.basic.intellisense").Title) + ' End Using + ' End Using + 'End Function - Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of ExpectedUnifiedSetting) - Get - Return ImmutableArray.Create( - New ExpectedUnifiedSetting( - "textEditor.basic.intellisense.triggerCompletionOnTypingLetters", - CompletionOptionsStorage.TriggerOnTypingLetters, - UnifiedSettingsOptionBase.CreateBooleanOption( - CompletionOptionsStorage.TriggerOnTypingLetters, - "Show completion list after a character is typed", - order:=0, - defaultValue:=True, - Nothing, - Nothing, - LanguageNames.VisualBasic)) - ) - - '("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), - '("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), - '("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), - '("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), - '("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), - '("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), - '("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), - '("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) - End Get - End Property + 'Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of ExpectedUnifiedSetting) + ' Get + ' Return ImmutableArray.Create( + ' New ExpectedUnifiedSetting( + ' "textEditor.basic.intellisense.triggerCompletionOnTypingLetters", + ' CompletionOptionsStorage.TriggerOnTypingLetters, + ' UnifiedSettingsOptionBase.CreateBooleanOption( + ' CompletionOptionsStorage.TriggerOnTypingLetters, + ' "Show completion list after a character is typed", + ' order:=0, + ' defaultValue:=True, + ' Nothing, + ' Nothing, + ' LanguageNames.VisualBasic)) + ' ) + + ' '("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), + ' '("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), + ' '("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), + ' '("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), + ' '("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), + ' '("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), + ' '("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), + ' '("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) + ' End Get + 'End Property Public Async Function IntelliSensePageTest() As Task diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb deleted file mode 100644 index 39cb005488bc7..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/ExpectedUnifiedSetting.vb +++ /dev/null @@ -1,22 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings - Friend Class ExpectedUnifiedSetting - Public ReadOnly Property UnifiedSettingPath As String - - Public ReadOnly Property [Option] As IOption2 - - Public ReadOnly Property UnifiedSettingsOption As UnifiedSettingsOptionBase - - Public Sub New(unifiedSettingPath As String, [option] As IOption2, unifiedSettingsOption As UnifiedSettingsOptionBase) - Me.UnifiedSettingPath = unifiedSettingPath - Me.Option = [option] - Me.UnifiedSettingsOption = unifiedSettingsOption - End Sub - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb deleted file mode 100644 index ac6e4f244e911..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/AlternateDefault.vb +++ /dev/null @@ -1,37 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class AlternateDefault(Of T) - - Public ReadOnly Property FlagName As String - - - Public ReadOnly Property [Default] As T - - Public Sub New(flagName As String, [default] As T) - Me.FlagName = flagName - Me.Default = [default] - End Sub - - Public Shared Function CreateFromOption([option] As IOption2, alternativeDefault As T) As AlternateDefault(Of T) - Dim configName = [option].Definition.ConfigName - Dim visualStudioStorage = Storages(configName) - ' Option has to be FeatureFlagStorage to be used as alternative default - Dim featureFlagStorage = DirectCast(visualStudioStorage, FeatureFlagStorage) - Return New AlternateDefault(Of T)(featureFlagStorage.FlagName, alternativeDefault) - End Function - - Public Overrides Function Equals(obj As Object) As Boolean - Dim [default] = TryCast(obj, AlternateDefault(Of T)) - Return [default] IsNot Nothing AndAlso - FlagName = [default].FlagName AndAlso - EqualityComparer(Of T).Default.Equals(Me.Default, [default].Default) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb deleted file mode 100644 index 8cef2ede2120e..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/EnumIntegerToString.vb +++ /dev/null @@ -1,19 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class EnumIntegerToString - Inherits MigrationType - - - Public ReadOnly Property Map As Map() - - Public Sub New(map As Map(), input As Input) - MyBase.New(input) - Me.Map = map - End Sub - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb deleted file mode 100644 index 88d4cd850e60f..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Input.vb +++ /dev/null @@ -1,77 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -'Imports Microsoft.CodeAnalysis -'Imports Microsoft.CodeAnalysis.Options -'Imports Microsoft.VisualStudio.LanguageServices.Options -'Imports -'Imports Newtonsoft.Json -'Imports Roslyn.Utilities - -'Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels -' Friend Class Input -' -' Public ReadOnly Property Store As String -' -' Public ReadOnly Property Path As String - -' Public Sub New(store As String, path As String) -' Me.Store = store -' Me.Path = path -' End Sub - -' Public Shared Function CreateInput([option] As IOption2) As Input -' Dim configName = [option].Definition.ConfigName -' Dim visualStudioStorage = Storages(configName) - -' Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage)) -' End Function - -' Public Shared Function CreateInput([option] As IPerLanguageValuedOption, languageName As String) As Input -' Dim configName = [option].Definition.ConfigName -' Dim visualStudioStorage = Storages(configName) -' Return New Input(GetStore(visualStudioStorage), GetPath(visualStudioStorage, languageName)) -' End Function - -' Private Shared Function GetStore(storage As VisualStudioOptionStorage) As String -' If TypeOf storage Is RoamingProfileStorage Then -' Return "SettingsManager" -' ElseIf TypeOf storage Is LocalUserProfileStorage Then -' Return "VsUserSettingsRegistry" -' Else -' Throw ExceptionUtilities.Unreachable -' End If -' End Function - -' Private Shared Function GetPath(storage As VisualStudioOptionStorage, Optional languageName As String = Nothing) As String -' If TypeOf storage Is RoamingProfileStorage Then -' Dim roamingProfileStorage = DirectCast(storage, RoamingProfileStorage) -' Return roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(If(languageName = Nothing, String.Empty, languageName))) -' ElseIf TypeOf storage Is LocalUserProfileStorage Then -' Dim localUserProfileStorage = DirectCast(storage, LocalUserProfileStorage) -' Return $"{localUserProfileStorage.Path}\\{localUserProfileStorage.Key}" -' Else -' Throw ExceptionUtilities.Unreachable -' End If -' End Function - -' Private Shared Function GetSubstituteLanguage(languageName As String) As String -' Select Case languageName -' Case LanguageNames.CSharp -' Return "CSharp" -' Case LanguageNames.VisualBasic -' Return "VisualBasic" -' Case Else -' Return languageName -' End Select -' End Function - -' Public Overrides Function Equals(obj As Object) As Boolean -' Dim input = TryCast(obj, Input) -' Return input IsNot Nothing AndAlso -' Store = input.Store AndAlso -' Path = input.Path -' End Function -' End Class -'End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb deleted file mode 100644 index 28905e3eb8249..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Map.vb +++ /dev/null @@ -1,19 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class Map - - Public ReadOnly Property Result As String - - Public ReadOnly Property Match As Integer - - Public Sub New(result As String, match As Integer) - Me.Result = result - Me.Match = match - End Sub - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb deleted file mode 100644 index 98c14c5120a4b..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Migration.vb +++ /dev/null @@ -1,22 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class Migration - - Public ReadOnly Property Pass As Pass - - Public Sub New(pass As Pass) - Me.Pass = pass - End Sub - - Public Overrides Function Equals(obj As Object) As Boolean - Dim migration = TryCast(obj, Migration) - Return migration IsNot Nothing AndAlso - EqualityComparer(Of Pass).Default.Equals(Pass, migration.Pass) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb deleted file mode 100644 index 65abc45692c2f..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/MigrationType.vb +++ /dev/null @@ -1,22 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class MigrationType - - Public ReadOnly Property Input As Input - - Public Sub New(input As Input) - Me.Input = input - End Sub - - Public Overrides Function Equals(obj As Object) As Boolean - Dim type = TryCast(obj, MigrationType) - Return type IsNot Nothing AndAlso - EqualityComparer(Of Input).Default.Equals(Input, type.Input) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb deleted file mode 100644 index 435b6755b2545..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Pass.vb +++ /dev/null @@ -1,19 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class Pass - Inherits MigrationType - - Public Sub New(input As Input) - MyBase.New(input) - End Sub - - Public Overrides Function Equals(obj As Object) As Boolean - Dim pass = TryCast(obj, Pass) - Return pass IsNot Nothing AndAlso - EqualityComparer(Of Input).Default.Equals(Input, pass.Input) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb deleted file mode 100644 index cdadeb572765c..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/ResourceConverter.vb +++ /dev/null @@ -1,33 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json -Imports Newtonsoft.Json.Linq -Imports Roslyn.Utilities - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class ResourceConverter - Inherits JsonConverter - - Public Overrides Sub WriteJson(writer As JsonWriter, value As Object, serializer As JsonSerializer) - Throw New NotImplementedException() - End Sub - - Public Overrides Function ReadJson(reader As JsonReader, objectType As Type, existingValue As Object, serializer As JsonSerializer) As Object - Dim token = JToken.Load(reader) - If token.Type = JTokenType.String Then - Return EvalResource(token.ToString()) - ElseIf token.Type = JTokenType.Array Then - Dim array = token.Values - Return array.Where(Function(arrayElement) arrayElement.Type = JTokenType.String).SelectAsArray(Function(arrayElement) EvalResource(arrayElement.ToString())) - End If - - Throw ExceptionUtilities.UnexpectedValue(token.Type) - End Function - - Public Overrides Function CanConvert(objectType As Type) As Boolean - Return objectType = GetType(String) OrElse objectType = GetType(String()) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb deleted file mode 100644 index a4b4811d6e458..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsCategory.vb +++ /dev/null @@ -1,21 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class UnifiedSettingsCategory - - - Public ReadOnly Property Title As String - - - Public ReadOnly Property LegacyOptionPageId As String - - Public Sub New(title As String, legacyOptionPageId As String) - Me.Title = title - Me.LegacyOptionPageId = legacyOptionPageId - End Sub - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb deleted file mode 100644 index 81dc7f3f8514f..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsEnumOption.vb +++ /dev/null @@ -1,36 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Microsoft.CodeAnalysis.Options -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend Class UnifiedSettingsEnumOption - Inherits UnifiedSettingsOption(Of String) - - - Public ReadOnly Property [Enum] As String() - - - - Public ReadOnly Property EnumLabels As String() - - Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration, [default] As String, alternateDefault As AlternateDefault(Of String), [enum] As String(), enumLabels As String()) - MyBase.New(title, type, order, enableWhen, migration, [default], alternateDefault) - Me.Enum = [enum] - Me.EnumLabels = enumLabels - End Sub - - Public Shared Function CreateEnumOption( - roslynOption As IOption2, - title As String, - defaultValue As Boolean, - featureFlagOption As IOption2, - enumLabels As String(), - [enum] As String(), - languageName As String) As UnifiedSettingsEnumOption - - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb deleted file mode 100644 index ee737293f7819..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOption.vb +++ /dev/null @@ -1,36 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - - Friend Class UnifiedSettingsOption(Of T) - Inherits UnifiedSettingsOptionBase - - - Public ReadOnly Property [Default] As T - - - Public ReadOnly Property AlternateDefault As AlternateDefault(Of T) - - Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration, [default] As T, alternateDefault As AlternateDefault(Of T)) - MyBase.New(title, type, order, enableWhen, migration) - Me.Default = [default] - Me.AlternateDefault = alternateDefault - End Sub - - Public Overrides Function Equals(obj As Object) As Boolean - Dim [option] = TryCast(obj, UnifiedSettingsOption(Of T)) - Return [option] IsNot Nothing AndAlso - Title = [option].Title AndAlso - Type = [option].Type AndAlso - Order = [option].Order AndAlso - EnableWhen = [option].EnableWhen AndAlso - EqualityComparer(Of Migration).Default.Equals(Migration, [option].Migration) AndAlso - EqualityComparer(Of T).Default.Equals([Default], [option].Default) AndAlso - EqualityComparer(Of AlternateDefault(Of T)).Default.Equals(AlternateDefault, [option].AlternateDefault) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb deleted file mode 100644 index e3d408de00867..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/UnifiedSettingsOptionBase.vb +++ /dev/null @@ -1,55 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Microsoft.CodeAnalysis.Options -Imports Newtonsoft.Json - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels - Friend MustInherit Class UnifiedSettingsOptionBase - - - Public ReadOnly Property Title As String - - - Public ReadOnly Property Type As String - - - Public ReadOnly Property Order As Integer - - - Public ReadOnly Property EnableWhen As String - - - Public ReadOnly Property Migration As Migration - - Public Sub New(title As String, type As String, order As Integer, enableWhen As String, migration As Migration) - Me.Title = title - Me.Type = type - Me.Order = order - Me.EnableWhen = enableWhen - Me.Migration = migration - End Sub - - Public Shared Function CreateBooleanOption( - roslynOption As IOption2, - title As String, - order As Integer, - defaultValue As Boolean, - alternativeDefault As (featureFlagOption As IOption2, alternateDefault As Boolean), - enableWhenOptionAndValue As ([option] As String, value As Object), - languageName As String) As UnifiedSettingsOption(Of Boolean) - Dim type = roslynOption.Type - Assert.True(type = GetType(Boolean) OrElse Nullable.GetUnderlyingType(type) = GetType(Boolean)) - - Return New UnifiedSettingsOption(Of Boolean)( - title, - "boolean", - order, - If(enableWhenOptionAndValue.option Is Nothing, Nothing, $"config:{enableWhenOptionAndValue.option}=='{enableWhenOptionAndValue.value}'"), - New Migration(New Pass(Input.CreateInput(CType(roslynOption, IPerLanguageValuedOption), languageName))), - defaultValue, - If(alternativeDefault.featureFlagOption Is Nothing, Nothing, AlternateDefault(Of Boolean).CreateFromOption(roslynOption, alternativeDefault.alternateDefault))) - End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb deleted file mode 100644 index 36f1dbfecbdfb..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/TestModels/Utilities.vb +++ /dev/null @@ -1,12 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports System.Globalization -Imports Microsoft.VisualStudio.LanguageServices -Imports Microsoft.VisualStudio.LanguageServices.CSharp -Imports Microsoft.VisualStudio.LanguageServices.VisualBasic -Imports Microsoft.CodeAnalysis - -Friend Module Utilities -End Module From a64b29cf45696408a12faa770df978457d169b94 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 17 Dec 2024 21:44:44 -0800 Subject: [PATCH 22/45] Refactoring --- .../TestModel/UnifiedSettingBase.cs | 108 -------------- .../UnifiedSettings/UnifiedSettingsTests.cs | 135 +++++++++++++++++- 2 files changed, 129 insertions(+), 114 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index c8297f8eb29a6..fb2acac1f3b14 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -28,113 +28,5 @@ internal abstract partial record UnifiedSettingBase() [JsonPropertyName("migration")] public required Migration Migration { get; init; } - - public static UnifiedSettingsOption CreateOption( - IOption2 onboardedOption, - string title, - int order, - T? defaultValue = default, - (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, - (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) where T : notnull - { - var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; - var type = onboardedOption.Definition.Type; - // If the option's type is nullable type, like bool?, we use bool in the registration file. - var underlyingType = Nullable.GetUnderlyingType(type); - if (underlyingType is not null) - { - Assert.True(featureFlagAndExperimentValue is not null); - } - var nonNullableType = underlyingType ?? type; - - var alternativeDefault = featureFlagAndExperimentValue is not null - ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value) - : null; - - var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" - : null; - - var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; - // If the option default value is null, it means the option is in experiment mode and is hidden by a feature flag. - // In Unified Settings it is not allowed and should be replaced by using the alternative default. - // Like: - // "textEditor.csharp.intellisense.showNewSnippetExperience": { - // "type": "boolean", - // "default": false, - // "alternateDefault": { - // "flagName": "Roslyn.SnippetCompletion", - // "default": true - // } - // } - // so please specify a non-null default value. - Assert.NotNull(expectedDefault); - - return new UnifiedSettingsOption - { - Title = title, - Type = nonNullableType.Name.ToCamelCase(), - Order = order, - EnableWhen = enableWhen, - Migration = migration, - AlternativeDefault = alternativeDefault, - Default = (T)expectedDefault - }; - } - - public static UnifiedSettingsEnumOption CreateEnumOption( - IOption2 onboardedOption, - string title, - int order, - T? defaultValue, - string[] enumLabels, - T[]? enumValues = null, - (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, - (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) where T : Enum - { - var type = onboardedOption.Definition.Type; - // If the option's type is nullable type, we use the original type in the registration file. - var nonNullableType = Nullable.GetUnderlyingType(type) ?? type; - Assert.Equal(typeof(T), nonNullableType); - - var expectedEnumValues = enumValues ?? [.. Enum.GetValues(nonNullableType).Cast()]; - var migration = new Migration - { - EnumToInteger = new EnumToInteger - { - Input = new Input(onboardedOption, languageName), - Map = new Map() - { - EnumValueMatches = [.. expectedEnumValues.Select(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] - } - } - }; - - var alternativeDefault = featureFlagAndExperimentValue is not null - ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value.ToString().ToCamelCase()) - : null; - - var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{UnifiedSettingsTests.s_optionToUnifiedSettingPath[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" - : null; - - var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; - Assert.NotNull(expectedDefault); - - return new UnifiedSettingsEnumOption() - { - Title = title, - Type = "string", - Enum = [.. expectedEnumValues.Select(value => value.ToString())], - EnumLabel = enumLabels, - Order = order, - EnableWhen = enableWhen, - Migration = migration, - AlternativeDefault = alternativeDefault, - Default = expectedDefault.ToString().ToCamelCase(), - }; - } } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 3c8aa77b848a3..253bd7fc18845 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -7,7 +7,6 @@ using System.Collections.Immutable; using System.Linq; using System.Reflection; -using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Threading.Tasks; @@ -22,11 +21,24 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings; public class UnifiedSettingsTests { - internal static readonly ImmutableDictionary s_optionToUnifiedSettingPath = ImmutableDictionary.Empty. - Add(CompletionOptionsStorage.TriggerOnTypingLetters, "textEditor.basic.intellisense.triggerCompletionOnTypingLetters"); + /// + /// Dictionary containing the option to unified setting path for VB. + /// + private static readonly ImmutableDictionary s_visualBasicUnifiedSettingsStorage = ImmutableDictionary.Empty. + Add(CompletionOptionsStorage.TriggerOnTypingLetters, "textEditor.basic.intellisense.triggerCompletionOnTypingLetters"). + Add(CompletionOptionsStorage.TriggerOnDeletion, "textEditor.basic.intellisense.triggerCompletionOnDeletion"). + Add(CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, "textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems"). + Add(CompletionViewOptionsStorage.ShowCompletionItemFilters, "textEditor.basic.intellisense.showCompletionItemFilters"). + Add(CompletionOptionsStorage.SnippetsBehavior, "textEditor.basic.intellisense.snippetsBehavior"). + Add(CompletionOptionsStorage.EnterKeyBehavior, "textEditor.basic.intellisense.returnKeyCompletionBehavior"). + Add(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, "textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces"). + Add(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, "textEditor.basic.intellisense.enableArgumentCompletionSnippets"); - private static readonly ImmutableDictionary s_optionToExpectedUnifiedSettings = ImmutableDictionary.Empty. - Add(CompletionOptionsStorage.TriggerOnTypingLetters, UnifiedSettingBase.CreateOption( + /// + /// Dictionary containing the option to expected unified settings for VB intellisense page. + /// + private static readonly ImmutableDictionary s_visualBasicIntellisenseExpectedSettings = ImmutableDictionary.Empty. + Add(CompletionOptionsStorage.TriggerOnTypingLetters, CreateOption( CompletionOptionsStorage.TriggerOnTypingLetters, title: "Show completion list after a character is typed", order: 0, @@ -46,7 +58,7 @@ public async Task VisualBasicIntellisenseTest() .Where(jsonObject => jsonObject.Key.StartsWith(expectedPrefix)) .SelectAsArray(jsonObject => jsonObject.Value); // Assert.Equal(s_optionToExpectedUnifiedSettings.Count, properties.Length); - foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_optionToExpectedUnifiedSettings, (actual, expected) => (actual, expected))) + foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_visualBasicIntellisenseExpectedSettings, (actual, expected) => (actual, expected))) { // We only have bool and enum option now. UnifiedSettingBase actualSettings = expectedOption.Definition.Type.IsEnum @@ -55,4 +67,115 @@ public async Task VisualBasicIntellisenseTest() Assert.Equal(expectedSetting, actualSettings); } } + + #region Helpers + private static UnifiedSettingsOption CreateOption( + IOption2 onboardedOption, + string title, + int order, + T? defaultValue = default, + (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, + (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, + string? languageName = null) where T : notnull + { + var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; + var type = onboardedOption.Definition.Type; + // If the option's type is nullable type, like bool?, we use bool in the registration file. + var underlyingType = Nullable.GetUnderlyingType(type); + if (underlyingType is not null) + { + Assert.True(featureFlagAndExperimentValue is not null); + } + var nonNullableType = underlyingType ?? type; + + var alternativeDefault = featureFlagAndExperimentValue is not null + ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value) + : null; + + var enableWhen = enableWhenOptionAndValue is not null + ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" + : null; + + var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + // If the option default value is null, it means the option is in experiment mode and is hidden by a feature flag. + // In Unified Settings it is not allowed and should be replaced by using the alternative default. + // Like: + // "textEditor.csharp.intellisense.showNewSnippetExperience": { + // "type": "boolean", + // "default": false, + // "alternateDefault": { + // "flagName": "Roslyn.SnippetCompletion", + // "default": true + // } + // } + // so please specify a non-null default value. + Assert.NotNull(expectedDefault); + + return new UnifiedSettingsOption + { + Title = title, + Type = nonNullableType.Name.ToCamelCase(), + Order = order, + EnableWhen = enableWhen, + Migration = migration, + AlternativeDefault = alternativeDefault, + Default = (T)expectedDefault + }; + } + + private static UnifiedSettingsEnumOption CreateEnumOption( + IOption2 onboardedOption, + string title, + int order, + T? defaultValue, + string[] enumLabels, + T[]? enumValues = null, + (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, + (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, + string? languageName = null) where T : Enum + { + var type = onboardedOption.Definition.Type; + // If the option's type is nullable type, we use the original type in the registration file. + var nonNullableType = Nullable.GetUnderlyingType(type) ?? type; + Assert.Equal(typeof(T), nonNullableType); + + var expectedEnumValues = enumValues ?? [.. Enum.GetValues(nonNullableType).Cast()]; + var migration = new Migration + { + EnumToInteger = new EnumToInteger + { + Input = new Input(onboardedOption, languageName), + Map = new Map() + { + EnumValueMatches = [.. expectedEnumValues.Select(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] + } + } + }; + + var alternativeDefault = featureFlagAndExperimentValue is not null + ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value.ToString().ToCamelCase()) + : null; + + var enableWhen = enableWhenOptionAndValue is not null + ? $"config:{UnifiedSettingsTests.s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" + : null; + + var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + Assert.NotNull(expectedDefault); + + return new UnifiedSettingsEnumOption + { + Title = title, + Type = "string", + Enum = [.. expectedEnumValues.Select(value => value.ToString())], + EnumLabel = enumLabels, + Order = order, + EnableWhen = enableWhen, + Migration = migration, + AlternativeDefault = alternativeDefault, + Default = expectedDefault.ToString().ToCamelCase(), + }; + } + + #endregion } From 2ca17977a35c2d4ab57e47db74a71927e675e5dd Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 00:09:09 -0800 Subject: [PATCH 23/45] Change to array --- .../UnifiedSettings/UnifiedSettingsTests.cs | 75 +++++++++++++------ 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 253bd7fc18845..c4e4d0406c147 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -37,15 +37,53 @@ public class UnifiedSettingsTests /// /// Dictionary containing the option to expected unified settings for VB intellisense page. /// - private static readonly ImmutableDictionary s_visualBasicIntellisenseExpectedSettings = ImmutableDictionary.Empty. - Add(CompletionOptionsStorage.TriggerOnTypingLetters, CreateOption( + private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_visualBasicIntellisenseExpectedSettings = ImmutableArray.Create<(IOption2, UnifiedSettingBase)>( + (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( CompletionOptionsStorage.TriggerOnTypingLetters, title: "Show completion list after a character is typed", order: 0, + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( + CompletionOptionsStorage.TriggerOnDeletion, + title: "Show completion list after a character is deleted", + order: 1, defaultValue: true, - featureFlagAndExperimentValue: null, - enableWhenOptionAndValue: null, - languageName: LanguageNames.VisualBasic)); + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, CreateBooleanOption( + CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, + "Highlight matching portions of completion list items", + order: 10, + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.ShowCompletionItemFilters, CreateBooleanOption( + CompletionViewOptionsStorage.ShowCompletionItemFilters, + title: "Show completion item filters", + order: 20, + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.SnippetsBehavior, CreateEnumOption( + CompletionOptionsStorage.SnippetsBehavior, + "Snippets behavior", + order: 30, + enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], + enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( + CompletionOptionsStorage.EnterKeyBehavior, + "Enter key behavior", + order: 40, + enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enterA"], + enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, CreateBooleanOption( + CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, + title: "Show items from unimported namespaces", + order: 50, + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, CreateBooleanOption( + CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, + title: "Tab twice insert arguments", + defaultValue: false, + order: 60, + languageName: LanguageNames.VisualBasic))); [Fact] public async Task VisualBasicIntellisenseTest() @@ -57,7 +95,7 @@ public async Task VisualBasicIntellisenseTest() var properties = jsonDocument!.Root["properties"]!.AsObject() .Where(jsonObject => jsonObject.Key.StartsWith(expectedPrefix)) .SelectAsArray(jsonObject => jsonObject.Value); - // Assert.Equal(s_optionToExpectedUnifiedSettings.Count, properties.Length); + Assert.Equal(s_visualBasicIntellisenseExpectedSettings.Length, properties.Length); foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_visualBasicIntellisenseExpectedSettings, (actual, expected) => (actual, expected))) { // We only have bool and enum option now. @@ -69,27 +107,23 @@ public async Task VisualBasicIntellisenseTest() } #region Helpers - private static UnifiedSettingsOption CreateOption( + private static UnifiedSettingsOption CreateBooleanOption( IOption2 onboardedOption, string title, int order, - T? defaultValue = default, - (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, + bool? defaultValue = null, + (IOption2 featureFlagOption, bool value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) where T : notnull + string? languageName = null) { var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; var type = onboardedOption.Definition.Type; // If the option's type is nullable type, like bool?, we use bool in the registration file. var underlyingType = Nullable.GetUnderlyingType(type); - if (underlyingType is not null) - { - Assert.True(featureFlagAndExperimentValue is not null); - } var nonNullableType = underlyingType ?? type; var alternativeDefault = featureFlagAndExperimentValue is not null - ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value) + ? new AlternativeDefault(featureFlagAndExperimentValue.Value.featureFlagOption, featureFlagAndExperimentValue.Value.value) : null; var enableWhen = enableWhenOptionAndValue is not null @@ -111,7 +145,7 @@ private static UnifiedSettingsOption CreateOption( // so please specify a non-null default value. Assert.NotNull(expectedDefault); - return new UnifiedSettingsOption + return new UnifiedSettingsOption { Title = title, Type = nonNullableType.Name.ToCamelCase(), @@ -119,7 +153,7 @@ private static UnifiedSettingsOption CreateOption( EnableWhen = enableWhen, Migration = migration, AlternativeDefault = alternativeDefault, - Default = (T)expectedDefault + Default = (bool)expectedDefault }; } @@ -127,12 +161,11 @@ private static UnifiedSettingsEnumOption CreateEnumOption( IOption2 onboardedOption, string title, int order, - T? defaultValue, string[] enumLabels, T[]? enumValues = null, (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) where T : Enum + string? languageName = null) { var type = onboardedOption.Definition.Type; // If the option's type is nullable type, we use the original type in the registration file. @@ -157,10 +190,10 @@ private static UnifiedSettingsEnumOption CreateEnumOption( : null; var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{UnifiedSettingsTests.s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" + ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" : null; - var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + var expectedDefault = onboardedOption.Definition.DefaultValue; Assert.NotNull(expectedDefault); return new UnifiedSettingsEnumOption From 9c2fed439da44c224099d5b1660ae216f11a6ad9 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 12:00:43 -0800 Subject: [PATCH 24/45] Fix string --- .../Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Options/IntelliSenseOptionPageStrings.cs | 4 ++-- .../Core/Def/ServicesVSResources.resx | 3 +++ .../Core/Def/xlf/ServicesVSResources.cs.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.de.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.es.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.fr.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.it.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.ja.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.ko.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.pl.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.ru.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.tr.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 7 ++++++- .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 7 ++++++- .../UnifiedSettings/UnifiedSettingsTests.cs | 16 +++++++++------- .../Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Options/IntelliSenseOptionPageStrings.vb | 4 ++-- 19 files changed, 96 insertions(+), 26 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml index a44181d87df24..b72fb67001309 100644 --- a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -23,7 +23,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Show_completion_list_after_a_character_is_accelerator_deleted}" /> ServicesVSResources._Show_completion_list_after_a_character_is_typed; - public static string Option_Show_completion_list_after_a_character_is_deleted - => ServicesVSResources.Show_completion_list_after_a_character_is_deleted; + public static string Show_completion_list_after_a_character_is_accelerator_deleted + => ServicesVSResources.Show_completion_list_after_a_character_is_accelerator_deleted; public static string Option_Completion { diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 4f6f03a2c42c9..b3c4a6c0fb89a 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1881,6 +1881,9 @@ Additional information: {1} Snippets behavior + Show completion list after a character is deleted + + Show completion list after a character is _deleted diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index acff95d1e685d..d0f5f83bcd7d3 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -1397,11 +1397,16 @@ Zobrazit seznam pro doplňování - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index cf048777d411e..82c2fb0bc35bd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -1397,11 +1397,16 @@ Vervollständigungsliste anzeigen - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index 37a39ce09900d..24282a9716a84 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -1397,11 +1397,16 @@ Mostrar lista de finalización - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 2ab4fc7f325f1..9b09a2f9eb95b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -1397,11 +1397,16 @@ Afficher la liste de saisie semi-automatique - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index 95182621a28d8..c8a2f50eaab4d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -1397,11 +1397,16 @@ Mostra l'elenco di completamento - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 4df43cd163941..633a8338c3607 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -1397,11 +1397,16 @@ 入力候補一覧の表示 - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 82acf9c78622b..f8f5917bd3018 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -1397,11 +1397,16 @@ 완성 목록 표시 - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index 424bd39f3eafa..e1bc5e3661183 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -1397,11 +1397,16 @@ Pokaż listę uzupełniania - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index f26e337e8ab5a..662c23a07666f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -1397,11 +1397,16 @@ Mostrar a lista de conclusão - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index 28a3b6f132cee..bb73c21d1006e 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -1397,11 +1397,16 @@ Показать список завершения - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 357321da8ab40..02e66adce5104 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -1397,11 +1397,16 @@ Tamamlama listesini göster - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index 29f29adb997c3..42ac6606f0960 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -1397,11 +1397,16 @@ 显示完成列表 - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 455a5d1b0a47c..248ab522e3fb1 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -1397,11 +1397,16 @@ 顯示自動完成清單 - + Show completion list after a character is _deleted Show completion list after a character is _deleted + + Show completion list after a character is deleted + Show completion list after a character is deleted + + Show completion list after a character is typed Show completion list after a character is typed diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index c4e4d0406c147..0e651bb16251b 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -37,12 +37,13 @@ public class UnifiedSettingsTests /// /// Dictionary containing the option to expected unified settings for VB intellisense page. /// - private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_visualBasicIntellisenseExpectedSettings = ImmutableArray.Create<(IOption2, UnifiedSettingBase)>( + private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_visualBasicIntellisenseExpectedSettings = + [ (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( - CompletionOptionsStorage.TriggerOnTypingLetters, - title: "Show completion list after a character is typed", - order: 0, - languageName: LanguageNames.VisualBasic)), + CompletionOptionsStorage.TriggerOnTypingLetters, + title: "Show completion list after a character is typed", + order: 0, + languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( CompletionOptionsStorage.TriggerOnDeletion, title: "Show completion list after a character is deleted", @@ -83,7 +84,8 @@ public class UnifiedSettingsTests title: "Tab twice insert arguments", defaultValue: false, order: 60, - languageName: LanguageNames.VisualBasic))); + languageName: LanguageNames.VisualBasic)), + ]; [Fact] public async Task VisualBasicIntellisenseTest() @@ -178,7 +180,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( EnumToInteger = new EnumToInteger { Input = new Input(onboardedOption, languageName), - Map = new Map() + Map = new Map { EnumValueMatches = [.. expectedEnumValues.Select(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] } diff --git a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml index fe4bfff186c95..0501947fe968a 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -21,7 +21,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Show_completion_list_after_a_character_is_accelerator_deleted}" /> Date: Thu, 19 Dec 2024 14:34:55 -0800 Subject: [PATCH 25/45] Correct the string --- .../Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Options/IntelliSenseOptionPageStrings.cs | 8 ++++---- .../Core/Def/ServicesVSResources.resx | 10 ++++++++-- .../Core/Def/xlf/ServicesVSResources.cs.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.de.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.es.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.fr.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.it.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.ja.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.ko.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.pl.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.ru.xlf | 18 ++++++++++++++---- .../Core/Def/xlf/ServicesVSResources.tr.xlf | 18 ++++++++++++++---- .../Def/xlf/ServicesVSResources.zh-Hans.xlf | 18 ++++++++++++++---- .../Def/xlf/ServicesVSResources.zh-Hant.xlf | 18 ++++++++++++++---- .../TestModel/UnifiedSettingsEnumOption.cs | 4 ++-- .../UnifiedSettings/UnifiedSettingsTests.cs | 2 +- .../Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Options/IntelliSenseOptionPageStrings.vb | 8 ++++---- 20 files changed, 203 insertions(+), 67 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml index b72fb67001309..a44181d87df24 100644 --- a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -23,7 +23,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Show_completion_list_after_a_character_is_deleted}" /> ServicesVSResources._Show_completion_list_after_a_character_is_typed; - public static string Show_completion_list_after_a_character_is_accelerator_deleted - => ServicesVSResources.Show_completion_list_after_a_character_is_accelerator_deleted; + public static string Option_Show_completion_list_after_a_character_is_deleted + => ServicesVSResources.Show_completion_list_after_a_character_is__deleted; public static string Option_Completion { @@ -35,10 +35,10 @@ public static string Option_ShowSnippets } public static string Option_Highlight_matching_portions_of_completion_list_items - => ServicesVSResources.Highlight_matching_portions_of_completion_list_items; + => ServicesVSResources._Highlight_matching_portions_of_completion_list_items; public static string Option_Show_completion_item_filters - => ServicesVSResources.Show_completion_item_filters; + => ServicesVSResources.Show_completion_item__filters; public static string Option_Automatically_complete_statement_on_semicolon => CSharpVSResources.Automatically_complete_statement_on_semicolon; diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index b3c4a6c0fb89a..0b14e82b2a8b0 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1871,10 +1871,16 @@ Additional information: {1} Performance - + _Highlight matching portions of completion list items + + Highlight matching portions of completion list items + + Show completion item filters + + Show completion item _filters @@ -1883,7 +1889,7 @@ Additional information: {1} Show completion list after a character is deleted - + Show completion list after a character is _deleted diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index d0f5f83bcd7d3..5ef785f119e6e 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Zobrazit chyby a upozornění kompilátoru pro: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Zobrazit seznam pro doplňování - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ {0} se změní na veřejný. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index 82c2fb0bc35bd..0217f01cc2c01 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Compilerfehler und -warnungen anzeigen für: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Vervollständigungsliste anzeigen - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ "{0}" wird in öffentlichen Wert geändert. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index 24282a9716a84..c15411586cee0 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Mostrar errores y advertencias del compilador para: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Mostrar lista de finalización - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ "{0}" se cambiará a público. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 9b09a2f9eb95b..097d33cac8d48 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Afficher les erreurs et avertissements du compilateur pour : - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Afficher la liste de saisie semi-automatique - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' va être changé en valeur publique. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index c8a2f50eaab4d..df31944fc05a7 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Mostra errori e avvisi del compilatore per: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Mostra l'elenco di completamento - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' verrà modificato in pubblico. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 633a8338c3607..cea889fe00700 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ 次のコンパイラ エラーと警告を表示する: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list 入力候補一覧の表示 - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' はパブリックに変更されます。 + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index f8f5917bd3018..e88c2bdb11178 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ 다음에 대한 컴파일러 오류 및 경고 표시: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list 완성 목록 표시 - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}'이(가) 공용으로 변경됩니다. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index e1bc5e3661183..e355acc264423 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Pokaż błędy i ostrzeżenia kompilatora dla: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Pokaż listę uzupełniania - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ Element „{0}” zostanie zmieniony na publiczny. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 662c23a07666f..ddf5806b4ebe8 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Mostrar erros e alertas do compilador para: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Mostrar a lista de conclusão - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' será alterado para público. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index bb73c21d1006e..b0835fe2960e7 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Показывать ошибки и предупреждения компилятора для: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Показать список завершения - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ Элемент "{0}" будет изменен на открытый. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 02e66adce5104..0b6d3b1d34d9f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ Şunun için derleyici hatalarını ve uyarılarını göster: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list Tamamlama listesini göster - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' ortak olacak şekilde değiştirildi. + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index 42ac6606f0960..1163a2f8f7f81 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ 显示以下的编译器错误和警告: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list 显示完成列表 - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ “{0}”将更改为“公共”。 + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 248ab522e3fb1..77f23a7b6d549 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -523,8 +523,8 @@ - _Highlight matching portions of completion list items - _Highlight matching portions of completion list items + Highlight matching portions of completion list items + Highlight matching portions of completion list items @@ -1387,17 +1387,22 @@ 顯示編譯器錯誤和警告: - + Show completion item _filters Show completion item _filters + + Show completion item filters + Show completion item filters + + Show completion list 顯示自動完成清單 - + Show completion list after a character is _deleted Show completion list after a character is _deleted @@ -1857,6 +1862,11 @@ '{0}' 會變更為公用。 + + _Highlight matching portions of completion list items + _Highlight matching portions of completion list items + + _Only add new line on enter after end of fully typed word _Only add new line on enter after end of fully typed word diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs index b4092a08f7d5a..d87b89926d46d 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -11,6 +11,6 @@ internal record UnifiedSettingsEnumOption : UnifiedSettingsOption [JsonPropertyName("enum")] public required string[] @Enum { get; init; } - [JsonPropertyName("enumLabel")] - public required string[] EnumLabel { get; init; } + [JsonPropertyName("enumLabels")] + public required string[] EnumLabels { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 0e651bb16251b..c416a9a2e724a 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -203,7 +203,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( Title = title, Type = "string", Enum = [.. expectedEnumValues.Select(value => value.ToString())], - EnumLabel = enumLabels, + EnumLabels = enumLabels, Order = order, EnableWhen = enableWhen, Migration = migration, diff --git a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml index 0501947fe968a..fe4bfff186c95 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -21,7 +21,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Show_completion_list_after_a_character_is_deleted}" /> Date: Thu, 19 Dec 2024 14:39:21 -0800 Subject: [PATCH 26/45] Correct the typo in property name --- .../UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs | 4 ++-- .../Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs index d87b89926d46d..92907941acc35 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -11,6 +11,6 @@ internal record UnifiedSettingsEnumOption : UnifiedSettingsOption [JsonPropertyName("enum")] public required string[] @Enum { get; init; } - [JsonPropertyName("enumLabels")] - public required string[] EnumLabels { get; init; } + [JsonPropertyName("enumItemLabels")] + public required string[] EnumItemLabels { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index c416a9a2e724a..5130ea1e8e9e0 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -203,7 +203,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( Title = title, Type = "string", Enum = [.. expectedEnumValues.Select(value => value.ToString())], - EnumLabels = enumLabels, + EnumItemLabels = enumLabels, Order = order, EnableWhen = enableWhen, Migration = migration, From ce672ca35621e9ebe948753d77557bd3d592d205 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 16:12:21 -0800 Subject: [PATCH 27/45] Add another converter --- .../TestModel/EnumIntegerToString.cs | 35 +++++++++++++++ .../TestModel/EnumToInteger.cs | 16 ------- .../UnifiedSettings/TestModel/Map.cs | 13 ++---- .../UnifiedSettings/TestModel/Migration.cs | 4 +- .../TestModel/ResourceStringArrayConverter.cs | 43 +++++++++++++++++++ ...onverter.cs => ResourceStringConverter.cs} | 11 +++-- .../TestModel/UnifiedSettingBase.cs | 2 +- .../TestModel/UnifiedSettingsEnumOption.cs | 19 ++++++++ .../UnifiedSettings/UnifiedSettingsTests.cs | 25 +++++------ 9 files changed, 125 insertions(+), 43 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs delete mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs rename src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/{ResourceConverter.cs => ResourceStringConverter.cs} (67%) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs new file mode 100644 index 0000000000000..de7887506dcf0 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Linq; +using System.Text.Json.Serialization; +using Roslyn.Utilities; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record EnumIntegerToString +{ + [JsonPropertyName("input")] + public required Input Input { get; init; } + + [JsonPropertyName("map")] + public required Map[] Map { get; init; } + + public virtual bool Equals(EnumIntegerToString? other) + { + if (other is null) + return false; + + if (ReferenceEquals(this, other)) + return true; + + return Input.Equals(other.Input) && Map.SequenceEqual(other.Map); + } + + public override int GetHashCode() + { + return Hash.Combine(Input.GetHashCode(), Map.GetHashCode()); + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs deleted file mode 100644 index dc1309bd0acd2..0000000000000 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumToInteger.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Text.Json.Serialization; - -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; - -internal record EnumToInteger -{ - [JsonPropertyName("input")] - public required Input Input { get; init; } - - [JsonPropertyName("map")] - public required Map Map { get; init; } -} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs index 244b4232ec587..a6af5630d81ad 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Map.cs @@ -8,14 +8,9 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record Map { - public required EnumToValuePair[] EnumValueMatches { get; init; } + [JsonPropertyName("result")] + public required string Result { get; init; } - internal record EnumToValuePair - { - [JsonPropertyName("result")] - public required string Result { get; init; } - - [JsonPropertyName("match")] - public required int Match { get; init; } - } + [JsonPropertyName("match")] + public required int Match { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs index 85fcd930cb004..4ec36efb078ec 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Migration.cs @@ -11,7 +11,7 @@ internal record Migration [JsonPropertyName("pass")] public Pass? Pass { get; init; } - [JsonPropertyName("enumToInteger")] - public EnumToInteger? EnumToInteger { get; init; } + [JsonPropertyName("enumIntegerToString")] + public EnumIntegerToString? EnumIntegerToString { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs new file mode 100644 index 0000000000000..26450871d1330 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Text.Json; +using System.Text.Json.Serialization; +using Microsoft.CodeAnalysis.PooledObjects; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal class ResourceStringArrayConverter : JsonConverter +{ + public override string[] Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + if (reader.TokenType != JsonTokenType.StartArray) + throw new JsonException("Expected StartArray token"); + + using var _ = ArrayBuilder.GetInstance(out var builder); + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndArray) + break; + + if (reader.TokenType == JsonTokenType.String) + { + var value = reader.GetString()!; + builder.Add(Utilities.EvalResource(value)); + } + else + { + throw new JsonException("Token should be string"); + } + } + + return builder.ToArray(); + } + + public override void Write(Utf8JsonWriter writer, string[] value, JsonSerializerOptions options) + { + throw new NotImplementedException(); + } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs similarity index 67% rename from src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs rename to src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs index 3bef59fa13a00..34bd431dae33c 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceConverter.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs @@ -8,12 +8,17 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel { - internal class ResourceConverter : JsonConverter + internal class ResourceStringConverter : JsonConverter { public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var locReference = reader.GetString()!; - return Utilities.EvalResource(locReference); + if (reader.TokenType == JsonTokenType.String) + { + var locReference = reader.GetString()!; + return Utilities.EvalResource(locReference); + } + + throw new NotImplementedException(); } public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index fb2acac1f3b14..626df542fe801 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -14,7 +14,7 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel internal abstract partial record UnifiedSettingBase() { [JsonPropertyName("title")] - [JsonConverter(typeof(ResourceConverter))] + [JsonConverter(typeof(ResourceStringConverter))] public required string Title { get; init; } [JsonPropertyName("type")] diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs index 92907941acc35..b172fc17d5af7 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System; using System.Text.Json.Serialization; +using Roslyn.Utilities; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; @@ -12,5 +14,22 @@ internal record UnifiedSettingsEnumOption : UnifiedSettingsOption public required string[] @Enum { get; init; } [JsonPropertyName("enumItemLabels")] + [JsonConverter(typeof(ResourceStringArrayConverter))] public required string[] EnumItemLabels { get; init; } + + public virtual bool Equals(UnifiedSettingsEnumOption? other) + { + if (other is null) + return false; + + if (ReferenceEquals(this, other)) + return true; + + return base.Equals(other) && Enum.Equals(other.Enum) && EnumItemLabels.Equals(other.EnumItemLabels); + } + + public override int GetHashCode() + { + return Hash.Combine(base.GetHashCode(), Enum, EnumItemLabels); + } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 5130ea1e8e9e0..6fe914f175a16 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -48,7 +48,7 @@ public class UnifiedSettingsTests CompletionOptionsStorage.TriggerOnDeletion, title: "Show completion list after a character is deleted", order: 1, - defaultValue: true, + customDefaultValue: true, languageName: LanguageNames.VisualBasic)), (CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, CreateBooleanOption( CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, @@ -64,8 +64,10 @@ public class UnifiedSettingsTests CompletionOptionsStorage.SnippetsBehavior, "Snippets behavior", order: 30, + customDefaultValue: SnippetsRule.IncludeAfterTypingIdentifierQuestionTab, enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], + customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 0}], languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( CompletionOptionsStorage.EnterKeyBehavior, @@ -82,7 +84,7 @@ public class UnifiedSettingsTests (CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, CreateBooleanOption( CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, title: "Tab twice insert arguments", - defaultValue: false, + customDefaultValue: false, order: 60, languageName: LanguageNames.VisualBasic)), ]; @@ -113,7 +115,7 @@ private static UnifiedSettingsOption CreateBooleanOption( IOption2 onboardedOption, string title, int order, - bool? defaultValue = null, + bool? customDefaultValue = null, (IOption2 featureFlagOption, bool value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, string? languageName = null) @@ -132,7 +134,7 @@ private static UnifiedSettingsOption CreateBooleanOption( ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" : null; - var expectedDefault = defaultValue ?? onboardedOption.Definition.DefaultValue; + var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; // If the option default value is null, it means the option is in experiment mode and is hidden by a feature flag. // In Unified Settings it is not allowed and should be replaced by using the alternative default. // Like: @@ -164,10 +166,12 @@ private static UnifiedSettingsEnumOption CreateEnumOption( string title, int order, string[] enumLabels, + T? customDefaultValue = default, T[]? enumValues = null, + Map[]? customMaps = null, (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) + string? languageName = null) where T : System.Enum { var type = onboardedOption.Definition.Type; // If the option's type is nullable type, we use the original type in the registration file. @@ -177,13 +181,10 @@ private static UnifiedSettingsEnumOption CreateEnumOption( var expectedEnumValues = enumValues ?? [.. Enum.GetValues(nonNullableType).Cast()]; var migration = new Migration { - EnumToInteger = new EnumToInteger + EnumIntegerToString = new EnumIntegerToString { Input = new Input(onboardedOption, languageName), - Map = new Map - { - EnumValueMatches = [.. expectedEnumValues.Select(value => new Map.EnumToValuePair { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] - } + Map = customMaps ?? [.. expectedEnumValues.Select(value => new Map { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value)}) ] } }; @@ -195,14 +196,14 @@ private static UnifiedSettingsEnumOption CreateEnumOption( ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" : null; - var expectedDefault = onboardedOption.Definition.DefaultValue; + var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; Assert.NotNull(expectedDefault); return new UnifiedSettingsEnumOption { Title = title, Type = "string", - Enum = [.. expectedEnumValues.Select(value => value.ToString())], + Enum = [.. expectedEnumValues.Select(value => value.ToString().ToCamelCase())], EnumItemLabels = enumLabels, Order = order, EnableWhen = enableWhen, From c26141585db4fd7d94ce6cb9a1054c32f34e9fa4 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 16:20:11 -0800 Subject: [PATCH 28/45] Imple Equals and GetHashCode --- .../UnifiedSettings/TestModel/EnumIntegerToString.cs | 3 ++- .../UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs index de7887506dcf0..72d115d1d3168 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs @@ -5,6 +5,7 @@ using System; using System.Linq; using System.Text.Json.Serialization; +using Roslyn.Test.Utilities; using Roslyn.Utilities; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; @@ -30,6 +31,6 @@ public virtual bool Equals(EnumIntegerToString? other) public override int GetHashCode() { - return Hash.Combine(Input.GetHashCode(), Map.GetHashCode()); + return Hash.Combine(Input.GetHashCode(), Hash.CombineValues(Map)); } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs index b172fc17d5af7..7f6a904166f36 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsEnumOption.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; +using System.Linq; using System.Text.Json.Serialization; using Roslyn.Utilities; @@ -25,11 +25,11 @@ public virtual bool Equals(UnifiedSettingsEnumOption? other) if (ReferenceEquals(this, other)) return true; - return base.Equals(other) && Enum.Equals(other.Enum) && EnumItemLabels.Equals(other.EnumItemLabels); + return base.Equals(other) && @Enum.SequenceEqual(other.@Enum) && EnumItemLabels.SequenceEqual(other.EnumItemLabels); } public override int GetHashCode() { - return Hash.Combine(base.GetHashCode(), Enum, EnumItemLabels); + return Hash.Combine(Hash.Combine(base.GetHashCode(), Hash.CombineValues(@Enum)), Hash.CombineValues(EnumItemLabels)); } } From 3d60864ee3a71a7b3c2c55a49be3b4b8c901d17f Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 16:40:11 -0800 Subject: [PATCH 29/45] Fix string --- src/VisualStudio/Core/Def/ServicesVSResources.resx | 3 +++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf | 5 +++++ src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 5 +++++ .../Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs | 4 +++- .../UnifiedSettings/visualBasicSettings.registration.json | 2 +- 16 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 0b14e82b2a8b0..3b9136112e90b 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1916,6 +1916,9 @@ Additional information: {1} Enter key behavior: + + Enter key behavior + Show preview for rename _tracking diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index 5ef785f119e6e..97446f975a57d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -432,6 +432,11 @@ Zadejte hodnotu místa volání, nebo zvolte jiný druh vložení hodnoty. + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index 0217f01cc2c01..6a292df02a1f4 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -432,6 +432,11 @@ Geben Sie einen Aufrufsitewert ein, oder wählen Sie eine andere Art der Werteingabe aus. + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index c15411586cee0..1b512cc3c8a09 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -432,6 +432,11 @@ Escriba un valor de sitio de llamada o elija otro tipo de inserción de valor. + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 097d33cac8d48..49247d3370dbc 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -432,6 +432,11 @@ Entrer une valeur de site d'appel ou choisir un autre type d'injection de valeur + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index df31944fc05a7..6754e1f3f413c 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -432,6 +432,11 @@ Immettere un valore per il sito di chiamata o scegliere un tipo di inserimento valori diverso + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index cea889fe00700..e728239ed691f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -432,6 +432,11 @@ 呼び出しサイトの値を入力するか、別の値の挿入の種類を選択してください + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index e88c2bdb11178..aeb15f0e7c904 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -432,6 +432,11 @@ 호출 사이트 값을 입력하거나 다른 값 삽입 종류를 선택하세요. + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index e355acc264423..a1394e7851883 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -432,6 +432,11 @@ Wprowadź wartość lokalizacji wywołania lub wybierz inny rodzaj iniekcji wartości + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index ddf5806b4ebe8..e6cb5aa37a66f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -432,6 +432,11 @@ Insira um valor de site de chamada ou escolha um tipo de injeção de valor diferente + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index b0835fe2960e7..3194e0a98a9b4 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -432,6 +432,11 @@ Введите значение места вызова или выберите другой тип введения значения + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 0b6d3b1d34d9f..c052d756dec11 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -432,6 +432,11 @@ Bir çağrı sitesi değeri girin veya farklı bir değer yerleştirme tipi seçin + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index 1163a2f8f7f81..f9727ec8d84d1 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -432,6 +432,11 @@ 输入调用站点值或选择其他值注入类型 + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 77f23a7b6d549..c7bd18e3a253f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -432,6 +432,11 @@ 請輸入呼叫位置值,或選擇其他值插入種類 + + Enter key behavior + Enter key behavior + + Enter key behavior: Enter key behavior: diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 6fe914f175a16..e0ada41ddb87d 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -73,8 +73,10 @@ public class UnifiedSettingsTests CompletionOptionsStorage.EnterKeyBehavior, "Enter key behavior", order: 40, - enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enterA"], + customDefaultValue: EnterKeyRule.Always, + enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], + customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "always", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, CreateBooleanOption( CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, diff --git a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json index cb65151330b6c..4a25f87a8ab56 100644 --- a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json +++ b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json @@ -105,7 +105,7 @@ }, // CompletionOptionsStorage.EnterKeyBehavior "textEditor.basic.intellisense.returnKeyCompletionBehavior": { - "title": "@Enter_key_behavior_colon;..\\Microsoft.VisualStudio.LanguageServices.dll", + "title": "@Enter_key_behavior;..\\Microsoft.VisualStudio.LanguageServices.dll", "type": "string", "enum": [ "never", "afterFullyTypedWord", "always" ], "enumItemLabels": [ "@Never_add_new_line_on_enter;{574fc912-f74f-4b4e-92c3-f695c208a2bb}", "@Only_add_new_line_on_enter_after_end_of_fully_typed_word;{574fc912-f74f-4b4e-92c3-f695c208a2bb}", "@Always_add_new_line_on_enter;{574fc912-f74f-4b4e-92c3-f695c208a2bb}" ], From 9ac6bd296bf85b8abe0d07dc9d6947dd13855737 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 16:59:11 -0800 Subject: [PATCH 30/45] Fix string --- .../Impl/Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Impl/Options/IntelliSenseOptionPageStrings.cs | 4 ++-- src/VisualStudio/Core/Def/ServicesVSResources.resx | 8 +++++++- .../Core/Def/xlf/ServicesVSResources.cs.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.de.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.es.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.fr.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.it.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.ja.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.ko.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.pl.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.ru.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.tr.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 12 +++++++++++- .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 12 +++++++++++- .../UnifiedSettings/UnifiedSettingsTests.cs | 2 +- .../Impl/Options/IntelliSenseOptionPageControl.xaml | 2 +- .../Impl/Options/IntelliSenseOptionPageStrings.vb | 5 ++--- 19 files changed, 157 insertions(+), 22 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml index a44181d87df24..20871e782a672 100644 --- a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -76,7 +76,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Tab_twice_to_insert_arguments_experimental}" /> ServicesVSResources.Show_items_from_unimported_namespaces; - public static string Option_Tab_twice_to_insert_arguments - => ServicesVSResources.Tab_twice_to_insert_arguments; + public static string Option_Tab_twice_to_insert_arguments_experimental + => ServicesVSResources.Tab_twice_to_insert_arguments_experimental; public static string Automatically_show_completion_list_in_argument_lists => CSharpVSResources.Automatically_show_completion_list_in_argument_lists; diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 3b9136112e90b..79c01778091fc 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1389,9 +1389,12 @@ Additional information: {1} Symbols without references - + Tab twice to insert arguments (experimental) + + Tab twice to insert arguments + Apply @@ -1937,4 +1940,7 @@ Additional information: {1} Show completion list after a character is typed + + Experimental feature + \ No newline at end of file diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index 97446f975a57d..f7bbc0b701ba6 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -462,6 +462,11 @@ Chyba při aktualizaci potlačení: {0} + + Experimental feature + Experimental feature + + External Sources Externí zdroje @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Stisknout dvakrát tabulátor, aby se vložily argumenty (experimentální) + + + Tab twice to insert arguments (experimental) - Stisknout dvakrát tabulátor, aby se vložily argumenty (experimentální) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index 6a292df02a1f4..b2370c0e6adcd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -462,6 +462,11 @@ Fehler bei der Aktualisierung von Unterdrückungen: {0} + + Experimental feature + Experimental feature + + External Sources Externe Quellen @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Zweimaliges Drücken der TAB-Taste zum Einfügen von Argumenten (experimentell) + + + Tab twice to insert arguments (experimental) - Zweimaliges Drücken der TAB-Taste zum Einfügen von Argumenten (experimentell) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index 1b512cc3c8a09..ca0b472b58361 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -462,6 +462,11 @@ Actualización de errores de forma periódica: {0} + + Experimental feature + Experimental feature + + External Sources Orígenes externos @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Presionar dos veces la tecla Tab para insertar argumentos (experimental) + + + Tab twice to insert arguments (experimental) - Presionar dos veces la tecla Tab para insertar argumentos (experimental) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 49247d3370dbc..a871ea355a589 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -462,6 +462,11 @@ Erreur lors de la mise à jour des suppressions : {0} + + Experimental feature + Experimental feature + + External Sources Sources externes @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Appuyer deux fois sur Tab pour insérer des arguments (expérimental) + + + Tab twice to insert arguments (experimental) - Appuyer deux fois sur Tab pour insérer des arguments (expérimental) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index 6754e1f3f413c..fe1d4e38170a8 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -462,6 +462,11 @@ Errore durante l'aggiornamento delle eliminazioni: {0} + + Experimental feature + Experimental feature + + External Sources Origini esterne @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Premi due volte TAB per inserire gli argomenti (sperimentale) + + + Tab twice to insert arguments (experimental) - Premi due volte TAB per inserire gli argomenti (sperimentale) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index e728239ed691f..4615748826ff8 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -462,6 +462,11 @@ 抑制の更新でエラーが発生しました: {0} + + Experimental feature + Experimental feature + + External Sources 外部ソース @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + タブを 2 回押して引数を挿入する (試験段階) + + + Tab twice to insert arguments (experimental) - タブを 2 回押して引数を挿入する (試験段階) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index aeb15f0e7c904..1ca2863aaa20b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -462,6 +462,11 @@ 표시 중지를 업데이트하는 동안 오류가 발생했습니다. {0} + + Experimental feature + Experimental feature + + External Sources 외부 원본 @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + 두 번 탭하여 인수 삽입(실험적) + + + Tab twice to insert arguments (experimental) - 두 번 탭하여 인수 삽입(실험적) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index a1394e7851883..063db05b7822f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -462,6 +462,11 @@ Błąd podczas pomijania aktualizacji: {0} + + Experimental feature + Experimental feature + + External Sources Źródła zewnętrzne @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Dwukrotnie naciśnij klawisz Tab, aby wstawić argumenty (eksperymentalna) + + + Tab twice to insert arguments (experimental) - Dwukrotnie naciśnij klawisz Tab, aby wstawić argumenty (eksperymentalna) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index e6cb5aa37a66f..6755c85533efa 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -462,6 +462,11 @@ Erro ao atualizar supressões: {0} + + Experimental feature + Experimental feature + + External Sources Fontes Externas @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Pressione Tab duas vezes para inserir argumentos (experimental) + + + Tab twice to insert arguments (experimental) - Pressione Tab duas vezes para inserir argumentos (experimental) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index 3194e0a98a9b4..ebbac35a0fc85 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -462,6 +462,11 @@ Ошибка при обновлении подавлений: {0} + + Experimental feature + Experimental feature + + External Sources Внешние источники @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Дважды нажмите клавишу TAB, чтобы вставить аргументы (экспериментальная функция) + + + Tab twice to insert arguments (experimental) - Дважды нажмите клавишу TAB, чтобы вставить аргументы (экспериментальная функция) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index c052d756dec11..c5451bcb7cabe 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -462,6 +462,11 @@ Gizlemeler güncellenirken hata oluştu: {0} + + Experimental feature + Experimental feature + + External Sources Dış Kaynaklar @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + Bağımsız değişkenleri eklemek için iki kez dokunun (deneysel) + + + Tab twice to insert arguments (experimental) - Bağımsız değişkenleri eklemek için iki kez dokunun (deneysel) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index f9727ec8d84d1..bb75263b516b1 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -462,6 +462,11 @@ 更新抑制时出现错误: {0} + + Experimental feature + Experimental feature + + External Sources 外部源 @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + 按两次 Tab 以插入参数(实验性) + + + Tab twice to insert arguments (experimental) - 按两次 Tab 以插入参数(实验性) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index c7bd18e3a253f..1d914ef6ccafd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -462,6 +462,11 @@ 更新歸併時發生錯誤: {0} + + Experimental feature + Experimental feature + + External Sources 外部來源 @@ -1568,8 +1573,13 @@ {Locked="System.Void"} "System.Void" represents CLR's type and should not be localized + Tab twice to insert arguments + 按 Tab 鍵兩次可插入引數 (實驗性) + + + Tab twice to insert arguments (experimental) - 按 Tab 鍵兩次可插入引數 (實驗性) + Tab twice to insert arguments (experimental) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index e0ada41ddb87d..640338a61b170 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -85,7 +85,7 @@ public class UnifiedSettingsTests languageName: LanguageNames.VisualBasic)), (CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, CreateBooleanOption( CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, - title: "Tab twice insert arguments", + title: "Tab twice to insert arguments", customDefaultValue: false, order: 60, languageName: LanguageNames.VisualBasic)), diff --git a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml index fe4bfff186c95..cdc81d010c0b7 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -63,7 +63,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Tab_twice_to_insert_arguments_experimental}" /> diff --git a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb index 7ebeaff322c2a..67a8b73d86133 100644 --- a/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb +++ b/src/VisualStudio/VisualBasic/Impl/Options/IntelliSenseOptionPageStrings.vb @@ -46,8 +46,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options Public ReadOnly Property Option_Show_items_from_unimported_namespaces As String = ServicesVSResources.Show_items_from_unimported_namespaces - Public ReadOnly Property Option_Tab_twice_to_insert_arguments As String = - ServicesVSResources.Tab_twice_to_insert_arguments - + Public ReadOnly Property Option_Tab_twice_to_insert_arguments_experimental As String = + ServicesVSResources.Tab_twice_to_insert_arguments_experimental End Module End Namespace From 01a8fccc45c8240cce7afef09252293b2864b630 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 17:25:53 -0800 Subject: [PATCH 31/45] Add tag helper --- .../TestModel/EnumIntegerToString.cs | 2 - .../TestModel/UnifiedSettingBase.cs | 33 +++---- .../UnifiedSettings/UnifiedSettingsTests.cs | 40 ++++++++- .../VisualBasicUnifiedSettingsTests.vb | 87 ------------------- ...io.LanguageServices.Test.Utilities2.vbproj | 6 +- 5 files changed, 52 insertions(+), 116 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs index 72d115d1d3168..f9a91a8ed2c35 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/EnumIntegerToString.cs @@ -2,10 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; using System.Linq; using System.Text.Json.Serialization; -using Roslyn.Test.Utilities; using Roslyn.Utilities; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 626df542fe801..4dd96d5e8f0da 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -2,31 +2,24 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System; -using System.Linq; using System.Text.Json.Serialization; -using Microsoft.CodeAnalysis.Options; -using Roslyn.Utilities; -using Xunit; -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; +internal abstract record UnifiedSettingBase { - internal abstract partial record UnifiedSettingBase() - { - [JsonPropertyName("title")] - [JsonConverter(typeof(ResourceStringConverter))] - public required string Title { get; init; } + [JsonPropertyName("title")] + [JsonConverter(typeof(ResourceStringConverter))] + public required string Title { get; init; } - [JsonPropertyName("type")] - public required string Type { get; init; } + [JsonPropertyName("type")] + public required string Type { get; init; } - [JsonPropertyName("order")] - public required int Order { get; init; } + [JsonPropertyName("order")] + public required int Order { get; init; } - [JsonPropertyName("enableWhen")] - public string? EnableWhen { get; init; } + [JsonPropertyName("enableWhen")] + public string? EnableWhen { get; init; } - [JsonPropertyName("migration")] - public required Migration Migration { get; init; } - } + [JsonPropertyName("migration")] + public required Migration Migration { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 640338a61b170..41eb2d9e35e6d 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -3,12 +3,15 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Collections.Immutable; +using System.IO; +using System.IO.Hashing; using System.Linq; using System.Reflection; +using System.Text; using System.Text.Json; using System.Text.Json.Nodes; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; @@ -91,11 +94,18 @@ public class UnifiedSettingsTests languageName: LanguageNames.VisualBasic)), ]; + #region VisualBasicTest + + [Fact] + public async Task VisualBasicGroupTest() + { + + } + [Fact] public async Task VisualBasicIntellisenseTest() { using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); - using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); var expectedPrefix = "textEditor.basic.intellisense"; var properties = jsonDocument!.Root["properties"]!.AsObject() @@ -105,14 +115,36 @@ public async Task VisualBasicIntellisenseTest() foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_visualBasicIntellisenseExpectedSettings, (actual, expected) => (actual, expected))) { // We only have bool and enum option now. - UnifiedSettingBase actualSettings = expectedOption.Definition.Type.IsEnum + UnifiedSettingBase actualSetting = expectedOption.Definition.Type.IsEnum ? actualJson.Deserialize()! : actualJson.Deserialize>()!; - Assert.Equal(expectedSetting, actualSettings); + Assert.Equal(expectedSetting, actualSetting); } + + using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); + using var streamReader = new StreamReader(pkgDefFileStream!); + var pkgdefFile = await streamReader.ReadToEndAsync(); + + VerifyTag(jsonDocument.ToString(), pkgdefFile); } + #endregion + #region Helpers + + private static void VerifyTag(string registrationFile, string pkgdefFile) + { + var fileBytes = ASCIIEncoding.ASCII.GetBytes(registrationFile); + var expectedTags = BitConverter.ToInt64(XxHash128.Hash(fileBytes).Take(8).ToArray(), 0).ToString("X16"); + var regex = new Regex(""" + "CacheTag"=qword:\w{16} + """); + var match = regex.Match(pkgdefFile, 0).Value; + var actualTag = match[^16..]; + // Please change the CacheTag value in pkddefFile when you modify the registration file. + Assert.Equal(expectedTags, actualTag); + } + private static UnifiedSettingsOption CreateBooleanOption( IOption2 onboardedOption, string title, diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb index b54bcbfe29cdf..d9c52299b9329 100644 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb @@ -3,16 +3,10 @@ ' See the LICENSE file in the project root for more information. Imports System.Collections.Immutable -Imports System.IO -Imports System.Reflection -Imports System.Text.Json -Imports System.Text.Json.Nodes Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Completion Imports Microsoft.CodeAnalysis.Options Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings -Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings.TestModels -Imports Newtonsoft.Json.Linq Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings Public Class VisualBasicUnifiedSettingsTests @@ -95,86 +89,5 @@ Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings ' End Using ' End Using 'End Function - - 'Private Shared ReadOnly Property IntelliSenseOnboardedOptions As ImmutableArray(Of ExpectedUnifiedSetting) - ' Get - ' Return ImmutableArray.Create( - ' New ExpectedUnifiedSetting( - ' "textEditor.basic.intellisense.triggerCompletionOnTypingLetters", - ' CompletionOptionsStorage.TriggerOnTypingLetters, - ' UnifiedSettingsOptionBase.CreateBooleanOption( - ' CompletionOptionsStorage.TriggerOnTypingLetters, - ' "Show completion list after a character is typed", - ' order:=0, - ' defaultValue:=True, - ' Nothing, - ' Nothing, - ' LanguageNames.VisualBasic)) - ' ) - - ' '("textEditor.basic.intellisense.triggerCompletionOnTypingLetters", CompletionOptionsStorage.TriggerOnTypingLetters), - ' '("textEditor.basic.intellisense.triggerCompletionOnDeletion", CompletionOptionsStorage.TriggerOnDeletion), - ' '("textEditor.basic.intellisense.highlightMatchingPortionsOfCompletionListItems", CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems), - ' '("textEditor.basic.intellisense.showCompletionItemFilters", CompletionViewOptionsStorage.ShowCompletionItemFilters), - ' '("textEditor.basic.intellisense.snippetsBehavior", CompletionOptionsStorage.SnippetsBehavior), - ' '("textEditor.basic.intellisense.returnKeyCompletionBehavior", CompletionOptionsStorage.EnterKeyBehavior), - ' '("textEditor.basic.intellisense.showCompletionItemsFromUnimportedNamespaces", CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces), - ' '("textEditor.basic.intellisense.enableArgumentCompletionSnippets", CompletionViewOptionsStorage.EnableArgumentCompletionSnippets)) - ' End Get - 'End Property - - - Public Async Function IntelliSensePageTest() As Task - Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - Dim jsonDocument = Await JsonNode.ParseAsync(registrationFileStream, documentOptions:=New JsonDocumentOptions() With {.CommentHandling = JsonCommentHandling.Skip}) - - Dim j = 9 - - End Using - End Using - End Function - - ' - 'Public Async Function IntelliSensePageTest() As Task - ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - ' Using reader = New StreamReader(registrationFileStream) - ' Using pkgDefFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("PackageRegistration.pkgdef") - ' Using pkgDefFileReader = New StreamReader(pkgDefFileStream) - ' Dim registrationFile = Await reader.ReadToEndAsync() - ' Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) - ' Dim properties = registrationJsonObject.Property("properties").Value.Children(Of JProperty).ToImmutableArray() - ' TODO: Assert number is correct - - ' For i = 0 To IntelliSenseOnboardedOptions.Length - ' Dim actualProperty = properties(i) - ' Dim expectedOption = IntelliSenseOnboardedOptions(i) - ' If expectedOption.Option.Type Is GetType(Boolean) Then - ' Dim actualOption = actualProperty.Value.ToObject(Of UnifiedSettingsOption(Of Boolean)) - ' Assert.Equal(expectedOption.UnifiedSettingPath, actualProperty.Name) - ' Assert.Equal(expectedOption.UnifiedSettingsOption, actualOption) - - ' End If - ' Next - - ' Dim hj = 8 - ' End Using - ' End Using - ' End Using - ' End Using - 'End Function - - 'Private Sub Helper(expected As (unifiedSettingsPath As String, roslynOption As IOption2), actualProperty As JsonProperty) - ' Assert.Equal(expected.unifiedSettingsPath, actualProperty.Name) - ' Dim expectedOption = expected.roslynOption - ' Dim type = expectedOption.Type - ' If type = GetType(Boolean) Then - ' VerifyBooleanOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsOption(Of Boolean))) - ' ElseIf type.IsEnum Then - ' VerifyEnumOption(expectedOption, actualProperty.Value.Deserialize(Of UnifiedSettingsEnumOption)) - ' Else - ' Assert.Fail("We only have enum and boolean option now. Add more if needed") - ' End If - 'End Sub End Class End Namespace diff --git a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj index e54d43268864e..a74a7f6977dc3 100644 --- a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj +++ b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj @@ -10,9 +10,6 @@ true - - - @@ -61,6 +58,9 @@ + + + From f3148df1c83be88c01d5e3dd2ad5e606cc5d1e28 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 19 Dec 2024 17:44:56 -0800 Subject: [PATCH 32/45] Add category test --- .../UnifiedSettings/TestModel/Category.cs | 17 +++++++++++++ .../UnifiedSettings/UnifiedSettingsTests.cs | 24 +++++++++++++------ .../Impl/PackageRegistration.pkgdef | 2 +- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Category.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Category.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Category.cs new file mode 100644 index 0000000000000..7a95b5ccdf052 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Category.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Category +{ + [JsonPropertyName("title")] + [JsonConverter(typeof(ResourceStringConverter))] + public required string Title { get; init; } + + [JsonPropertyName("legacyOptionPageId")] + public string? LegacyOptionPageId { get; init; } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 41eb2d9e35e6d..33cd0a2f72957 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -16,6 +16,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; using Microsoft.CodeAnalysis.Options; +using Microsoft.VisualStudio.LanguageServices; using Roslyn.Utilities; using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; @@ -97,9 +98,17 @@ public class UnifiedSettingsTests #region VisualBasicTest [Fact] - public async Task VisualBasicGroupTest() + public async Task VisualBasicCategoriesTest() { - + using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + var categories = jsonDocument!.Root["categories"]!.AsObject(); + var propertyToCategory = categories.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Deserialize()); + Assert.Equal(2, propertyToCategory.Count); + Assert.Equal("Visual Basic", propertyToCategory["textEditor.basic"]!.Title); + Assert.Equal("IntelliSense", propertyToCategory["textEditor.basic.intellisense"]!.Title); + Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, propertyToCategory["textEditor.basic.intellisense"]!.LegacyOptionPageId); + await VerifyTagAsync(jsonDocument.ToString()); } [Fact] @@ -121,19 +130,20 @@ public async Task VisualBasicIntellisenseTest() Assert.Equal(expectedSetting, actualSetting); } - using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); - using var streamReader = new StreamReader(pkgDefFileStream!); - var pkgdefFile = await streamReader.ReadToEndAsync(); - VerifyTag(jsonDocument.ToString(), pkgdefFile); + await VerifyTagAsync(jsonDocument.ToString()); } #endregion #region Helpers - private static void VerifyTag(string registrationFile, string pkgdefFile) + private static async Task VerifyTagAsync(string registrationFile) { + using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); + using var streamReader = new StreamReader(pkgDefFileStream!); + var pkgdefFile = await streamReader.ReadToEndAsync(); + var fileBytes = ASCIIEncoding.ASCII.GetBytes(registrationFile); var expectedTags = BitConverter.ToInt64(XxHash128.Hash(fileBytes).Take(8).ToArray(), 0).ToString("X16"); var regex = new Regex(""" diff --git a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef index 6322d9937ce98..b52a355ca044e 100644 --- a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef @@ -195,4 +195,4 @@ [$RootKey$\SettingsManifests\{574fc912-f74f-4b4e-92c3-f695c208a2bb}] @="Microsoft.VisualStudio.LanguageServices.VisualBasic.VisualBasicPackage" "ManifestPath"="$PackageFolder$\UnifiedSettings\visualBasicSettings.registration.json" -"CacheTag"=qword:1F15ACF7AC28A65C +"CacheTag"=qword:CCFB7E35D42FEAD4 From 8ab888dc6dfdc102f350752d4d09782b956eac9a Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 20 Dec 2024 10:07:40 -0800 Subject: [PATCH 33/45] Add messages --- src/VisualStudio/Core/Def/ServicesVSResources.resx | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf | 2 +- src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf | 2 +- .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 2 +- .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 2 +- .../Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs | 4 +--- src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef | 4 ++-- .../UnifiedSettings/visualBasicSettings.registration.json | 5 +++++ 17 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 79c01778091fc..24f11bfd09f95 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1940,7 +1940,7 @@ Additional information: {1} Show completion list after a character is typed - + Experimental feature \ No newline at end of file diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index f7bbc0b701ba6..f50490a2ac205 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -462,7 +462,7 @@ Chyba při aktualizaci potlačení: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index b2370c0e6adcd..3d29ccd6b9ed2 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -462,7 +462,7 @@ Fehler bei der Aktualisierung von Unterdrückungen: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index ca0b472b58361..ad8ca890c358d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -462,7 +462,7 @@ Actualización de errores de forma periódica: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index a871ea355a589..ee25311c6c9f4 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -462,7 +462,7 @@ Erreur lors de la mise à jour des suppressions : {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index fe1d4e38170a8..5569c8f7b5098 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -462,7 +462,7 @@ Errore durante l'aggiornamento delle eliminazioni: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 4615748826ff8..342387661320f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -462,7 +462,7 @@ 抑制の更新でエラーが発生しました: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 1ca2863aaa20b..1fe8016910085 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -462,7 +462,7 @@ 표시 중지를 업데이트하는 동안 오류가 발생했습니다. {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index 063db05b7822f..0f605aa5c2c53 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -462,7 +462,7 @@ Błąd podczas pomijania aktualizacji: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 6755c85533efa..24d93af21d983 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -462,7 +462,7 @@ Erro ao atualizar supressões: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index ebbac35a0fc85..cee6f45aadbb3 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -462,7 +462,7 @@ Ошибка при обновлении подавлений: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index c5451bcb7cabe..4036b09087785 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -462,7 +462,7 @@ Gizlemeler güncellenirken hata oluştu: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index bb75263b516b1..8e8de8ef9cc60 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -462,7 +462,7 @@ 更新抑制时出现错误: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index 1d914ef6ccafd..c8637af14e6a3 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -462,7 +462,7 @@ 更新歸併時發生錯誤: {0} - + Experimental feature Experimental feature diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 33cd0a2f72957..f67b9672957ab 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -129,8 +129,6 @@ public async Task VisualBasicIntellisenseTest() : actualJson.Deserialize>()!; Assert.Equal(expectedSetting, actualSetting); } - - await VerifyTagAsync(jsonDocument.ToString()); } @@ -228,7 +226,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( EnumIntegerToString = new EnumIntegerToString { Input = new Input(onboardedOption, languageName), - Map = customMaps ?? [.. expectedEnumValues.Select(value => new Map { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value)}) ] + Map = customMaps ?? [.. expectedEnumValues.Select(value => new Map { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value)})] } }; diff --git a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef index b52a355ca044e..04cf35e3f6e42 100644 --- a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef @@ -191,8 +191,8 @@ "DisplayLineSeparators"=dword:00000001 // CacheTag value should be changed when registration file changes -// See https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/39345/Manifest-Build-Deployment-and-Setup-Authoring-In-Depth?anchor=example-pkgdef-key for more infomation +// See https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/39345/Manifest-Build-Deployment-and-Setup-Authoring-In-Depth?anchor=example-pkgdef-key for more information [$RootKey$\SettingsManifests\{574fc912-f74f-4b4e-92c3-f695c208a2bb}] @="Microsoft.VisualStudio.LanguageServices.VisualBasic.VisualBasicPackage" "ManifestPath"="$PackageFolder$\UnifiedSettings\visualBasicSettings.registration.json" -"CacheTag"=qword:CCFB7E35D42FEAD4 +"CacheTag"=qword:A051BA2C3046E62E diff --git a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json index 4a25f87a8ab56..8751cfb2f0791 100644 --- a/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json +++ b/src/VisualStudio/VisualBasic/Impl/UnifiedSettings/visualBasicSettings.registration.json @@ -163,6 +163,11 @@ "type": "boolean", "default": false, "order": 60, + "messages": [ + { + "text": "@Experimental_feature;..\\Microsoft.VisualStudio.LanguageServices.dll" + } + ], "migration": { "pass": { "input": { From 06b1b28e3f5f0ebbfd5208afd7fc0575026411e3 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 20 Dec 2024 15:31:11 -0800 Subject: [PATCH 34/45] Message covered by test --- .../UnifiedSettings/TestModel/Message.cs | 14 +++++++ .../TestModel/UnifiedSettingBase.cs | 37 +++++++++++++++++++ .../UnifiedSettings/UnifiedSettingsTests.cs | 9 +++-- 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Message.cs diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Message.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Message.cs new file mode 100644 index 0000000000000..2f593b9f5fd08 --- /dev/null +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Message.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Text.Json.Serialization; + +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + +internal record Message +{ + [JsonPropertyName("text")] + [JsonConverter(typeof(ResourceStringConverter))] + public required string Text { get; init; } +} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index 4dd96d5e8f0da..ef8419a21d390 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -2,7 +2,9 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Linq; using System.Text.Json.Serialization; +using Roslyn.Utilities; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal abstract record UnifiedSettingBase @@ -22,4 +24,39 @@ internal abstract record UnifiedSettingBase [JsonPropertyName("migration")] public required Migration Migration { get; init; } + + [JsonPropertyName("messages")] + public Message[]? Messages { get; init; } + + public virtual bool Equals(UnifiedSettingBase? other) + { + if (other is null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (Title != other.Title + || Type != other.Type + || Order != other.Order + || EnableWhen != other.EnableWhen + || !Migration.Equals(other.Migration)) + { + return false; + } + + if (Messages is not null && other.Messages is not null) + { + return Messages.SequenceEqual(other.Messages); + } + + return true; + } + + public override int GetHashCode() + => Hash.Combine(Hash.Combine(Hash.Combine(Hash.Combine(Hash.Combine(Title.GetHashCode(), Type.GetHashCode()), Order.GetHashCode()), EnableWhen?.GetHashCode() ?? 0), Migration.GetHashCode()), Messages is null ? 0 : Hash.CombineValues(Messages)); } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index f67b9672957ab..759552c2a6f73 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -92,7 +92,8 @@ public class UnifiedSettingsTests title: "Tab twice to insert arguments", customDefaultValue: false, order: 60, - languageName: LanguageNames.VisualBasic)), + languageName: LanguageNames.VisualBasic, + message: "Experimental feature")), ]; #region VisualBasicTest @@ -160,7 +161,8 @@ private static UnifiedSettingsOption CreateBooleanOption( bool? customDefaultValue = null, (IOption2 featureFlagOption, bool value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) + string? languageName = null, + string? message = null) { var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; var type = onboardedOption.Definition.Type; @@ -199,7 +201,8 @@ private static UnifiedSettingsOption CreateBooleanOption( EnableWhen = enableWhen, Migration = migration, AlternativeDefault = alternativeDefault, - Default = (bool)expectedDefault + Default = (bool)expectedDefault, + Messages = message is null ? null : [new Message { Text = message }], }; } From 6d1e5238014eeef0ba71e84e3fc69f389f8bcc26 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 20 Dec 2024 15:59:14 -0800 Subject: [PATCH 35/45] Add CSharp dictionary --- ....CodeAnalysis.CSharp.EditorFeatures.csproj | 1 + .../UnifiedSettings/UnifiedSettingsTests.cs | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/CSharp/Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj b/src/EditorFeatures/CSharp/Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj index b38a4252d8b6b..29acf31963df6 100644 --- a/src/EditorFeatures/CSharp/Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj +++ b/src/EditorFeatures/CSharp/Microsoft.CodeAnalysis.CSharp.EditorFeatures.csproj @@ -34,6 +34,7 @@ + diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 759552c2a6f73..5a8213d4aa05f 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -15,6 +15,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Completion; +using Microsoft.CodeAnalysis.Editor.CSharp.CompleteStatement; using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.LanguageServices; using Roslyn.Utilities; @@ -25,6 +26,27 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings; public class UnifiedSettingsTests { + #region CSharpTest + /// + /// Dictionary containing the option to unified setting path for C#. + /// + private static readonly ImmutableDictionary s_csharpUnifiedSettingsStorage = ImmutableDictionary.Empty. + Add(CompletionOptionsStorage.TriggerOnTypingLetters, "textEditor.csharp.intellisense.triggerCompletionOnTypingLetters"). + Add(CompletionOptionsStorage.TriggerOnDeletion, "textEditor.csharp.intellisense.triggerCompletionOnDeletion"). + Add(CompletionOptionsStorage.TriggerInArgumentLists, "textEditor.csharp.intellisense.triggerCompletionInArgumentLists"). + Add(CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, "textEditor.csharp.intellisense.highlightMatchingPortionsOfCompletionListItems"). + Add(CompletionViewOptionsStorage.ShowCompletionItemFilters, "textEditor.csharp.intellisense.showCompletionItemFilters"). + Add(CompleteStatementOptionsStorage.AutomaticallyCompleteStatementOnSemicolon, "textEditor.csharp.intellisense.completeStatementOnSemicolon"). + Add(CompletionOptionsStorage.SnippetsBehavior, "textEditor.csharp.intellisense.snippetsBehavior"). + Add(CompletionOptionsStorage.EnterKeyBehavior, "textEditor.csharp.intellisense.returnKeyCompletionBehavior"). + Add(CompletionOptionsStorage.ShowNameSuggestions, "textEditor.csharp.intellisense.showNameCompletionSuggestions"). + Add(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, "textEditor.csharp.intellisense.showCompletionItemsFromUnimportedNamespaces"). + Add(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, "textEditor.csharp.intellisense.enableArgumentCompletionSnippets"). + Add(CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, "textEditor.csharp.intellisense.showNewSnippetExperience"). + + #endregion + + #region VisualBasicTest /// /// Dictionary containing the option to unified setting path for VB. /// @@ -96,8 +118,6 @@ public class UnifiedSettingsTests message: "Experimental feature")), ]; - #region VisualBasicTest - [Fact] public async Task VisualBasicCategoriesTest() { From 21c5a598e1576d1f231275eccc19ab1aed9d04e9 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 20 Dec 2024 17:44:04 -0800 Subject: [PATCH 36/45] Add C# category test --- .../csharpSettings.registration.json | 2 +- .../UnifiedSettings/TestModel/Utilities.cs | 4 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 79 +++++++++++++++++-- 3 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json index fe49f53c9defa..c29f254cb33d0 100644 --- a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json +++ b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json @@ -241,7 +241,7 @@ }, "categories": { "textEditor.csharp":{ - "title": "C#" + "title": "@101;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" }, "textEditor.csharp.intellisense": { "title": "@103;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}", diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs index 49bc032d2b491..01a816265e1c2 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/Utilities.cs @@ -20,11 +20,11 @@ internal static class Utilities private const string LanguageServiceDllName = "Microsoft.VisualStudio.LanguageServices.dll"; - public static string EvalResource(string resourceReference) + public static string? EvalResource(string resourceReference) { // Start with 1 because to skip @ at the beginning, like @Show_completion_item_filters var resourcesIdentifier = resourceReference.Substring(1, resourceReference.IndexOf(";") - 1); - var resources = resourceReference.Substring(resourceReference.IndexOf(";") + 1); + var resources = resourceReference[(resourceReference.IndexOf(";") + 1)..]; var culture = new CultureInfo("en"); if (Guid.TryParse(resources, out var packageGuid)) { diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 5a8213d4aa05f..2cfd1cb7c1c66 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -42,7 +42,76 @@ public class UnifiedSettingsTests Add(CompletionOptionsStorage.ShowNameSuggestions, "textEditor.csharp.intellisense.showNameCompletionSuggestions"). Add(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, "textEditor.csharp.intellisense.showCompletionItemsFromUnimportedNamespaces"). Add(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, "textEditor.csharp.intellisense.enableArgumentCompletionSnippets"). - Add(CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, "textEditor.csharp.intellisense.showNewSnippetExperience"). + Add(CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, "textEditor.csharp.intellisense.showNewSnippetExperience"); + + private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_csharpIntellisenseExpectedSettings = + [ + (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( + CompletionOptionsStorage.TriggerOnTypingLetters, + title: "Show completion list after a character is typed", + order: 0, + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( + CompletionOptionsStorage.TriggerOnDeletion, + title: "Show completion list after a character is deleted", + order: 1, + customDefaultValue: true, + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, CreateBooleanOption( + CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, + "Highlight matching portions of completion list items", + order: 10, + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.ShowCompletionItemFilters, CreateBooleanOption( + CompletionViewOptionsStorage.ShowCompletionItemFilters, + title: "Show completion item filters", + order: 20, + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.SnippetsBehavior, CreateEnumOption( + CompletionOptionsStorage.SnippetsBehavior, + "Snippets behavior", + order: 30, + customDefaultValue: SnippetsRule.IncludeAfterTypingIdentifierQuestionTab, + enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], + enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], + customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 0}], + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( + CompletionOptionsStorage.EnterKeyBehavior, + "Enter key behavior", + order: 40, + customDefaultValue: EnterKeyRule.Always, + enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], + enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], + customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "always", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], + languageName: LanguageNames.VisualBasic)), + (CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, CreateBooleanOption( + CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, + title: "Show items from unimported namespaces", + order: 50, + languageName: LanguageNames.VisualBasic)), + (CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, CreateBooleanOption( + CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, + title: "Tab twice to insert arguments", + customDefaultValue: false, + order: 60, + languageName: LanguageNames.VisualBasic, + message: "Experimental feature")), + ]; + + [Fact] + public async Task CSharpCategoriesTest() + { + using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.csharpSettings.registration.json"); + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + var categories = jsonDocument!.Root["categories"]!.AsObject(); + var propertyToCategory = categories.ToDictionary(kvp => kvp.Key, kvp => kvp.Value.Deserialize()); + Assert.Equal(2, propertyToCategory.Count); + Assert.Equal("C#", propertyToCategory["textEditor.csharp"]!.Title); + Assert.Equal("IntelliSense", propertyToCategory["textEditor.csharp.intellisense"]!.Title); + Assert.Equal(Guids.CSharpOptionPageIntelliSenseIdString, propertyToCategory["textEditor.csharp.intellisense"]!.LegacyOptionPageId); + await VerifyTagAsync(jsonDocument.ToString()); + } #endregion @@ -163,7 +232,7 @@ private static async Task VerifyTagAsync(string registrationFile) using var streamReader = new StreamReader(pkgDefFileStream!); var pkgdefFile = await streamReader.ReadToEndAsync(); - var fileBytes = ASCIIEncoding.ASCII.GetBytes(registrationFile); + var fileBytes = Encoding.ASCII.GetBytes(registrationFile); var expectedTags = BitConverter.ToInt64(XxHash128.Hash(fileBytes).Take(8).ToArray(), 0).ToString("X16"); var regex = new Regex(""" "CacheTag"=qword:\w{16} @@ -178,10 +247,10 @@ private static UnifiedSettingsOption CreateBooleanOption( IOption2 onboardedOption, string title, int order, + string? languageName, bool? customDefaultValue = null, (IOption2 featureFlagOption, bool value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null, string? message = null) { var migration = new Migration { Pass = new Pass { Input = new Input(onboardedOption, languageName) } }; @@ -231,12 +300,12 @@ private static UnifiedSettingsEnumOption CreateEnumOption( string title, int order, string[] enumLabels, + string? languageName, T? customDefaultValue = default, T[]? enumValues = null, Map[]? customMaps = null, (IOption2 featureFlagOption, T value)? featureFlagAndExperimentValue = null, - (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, - string? languageName = null) where T : System.Enum + (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null) where T : Enum { var type = onboardedOption.Definition.Type; // If the option's type is nullable type, we use the original type in the registration file. From 93bd0752249621b9b4e04b516a735db5f866a176 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Fri, 20 Dec 2024 23:55:30 -0800 Subject: [PATCH 37/45] Add C# test --- .../csharpSettings.registration.json | 12 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 116 +++++++++++++----- 2 files changed, 99 insertions(+), 29 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json index c29f254cb33d0..e74d59bb1e44b 100644 --- a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json +++ b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json @@ -136,7 +136,7 @@ }, // CompletionOptionsStorage.EnterKeyBehavior "textEditor.csharp.intellisense.returnKeyCompletionBehavior": { - "title": "@Enter_key_behavior_colon;..\\Microsoft.VisualStudio.LanguageServices.dll", + "title": "@Enter_key_behavior;..\\Microsoft.VisualStudio.LanguageServices.dll", "type": "string", "enum": [ "never", "afterFullyTypedWord", "always" ], "enumItemLabels": [ "@Never_add_new_line_on_enter;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}", "@Only_add_new_line_on_enter_after_end_of_fully_typed_word;..\\Microsoft.VisualStudio.LanguageServices.dll", "@Always_add_new_line_on_enter;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" ], @@ -209,6 +209,11 @@ "type": "boolean", "default": false, "order": 90, + "messages": [ + { + "text": "@Experimental_feature;..\\Microsoft.VisualStudio.LanguageServices.dll" + } + ], "migration": { "pass": { "input": { @@ -223,6 +228,11 @@ "title": "@Show_new_snippet_experience_experimental;..\\Microsoft.VisualStudio.LanguageServices.CSharp.dll", "type": "boolean", "default": false, + "messages": [ + { + "text": "@Experimental_feature;..\\Microsoft.VisualStudio.LanguageServices.dll" + } + ], "alternateDefault": { // CompletionOptionsStorage.ShowNewSnippetExperienceFeatureFlag "flagName": "Roslyn.SnippetCompletion", diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 2cfd1cb7c1c66..240140af555fc 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Collections.Immutable; using System.IO; using System.IO.Hashing; @@ -18,6 +19,8 @@ using Microsoft.CodeAnalysis.Editor.CSharp.CompleteStatement; using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.LanguageServices; +using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; +using Roslyn.Test.Utilities; using Roslyn.Utilities; using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; @@ -50,52 +53,76 @@ public class UnifiedSettingsTests CompletionOptionsStorage.TriggerOnTypingLetters, title: "Show completion list after a character is typed", order: 0, - languageName: LanguageNames.VisualBasic)), + languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( CompletionOptionsStorage.TriggerOnDeletion, title: "Show completion list after a character is deleted", order: 1, - customDefaultValue: true, - languageName: LanguageNames.VisualBasic)), + customDefaultValue: false, + enableWhenOptionAndValue: (enableWhenOption: CompletionOptionsStorage.TriggerOnTypingLetters, whenValue: true), + languageName: LanguageNames.CSharp)), + (CompletionOptionsStorage.TriggerInArgumentLists, CreateBooleanOption( + CompletionOptionsStorage.TriggerInArgumentLists, + title: "Automatically show completion list in argument lists", + order: 10, + languageName: LanguageNames.CSharp)), (CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, CreateBooleanOption( CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, "Highlight matching portions of completion list items", - order: 10, - languageName: LanguageNames.VisualBasic)), + order: 20, + languageName: LanguageNames.CSharp)), (CompletionViewOptionsStorage.ShowCompletionItemFilters, CreateBooleanOption( CompletionViewOptionsStorage.ShowCompletionItemFilters, title: "Show completion item filters", - order: 20, - languageName: LanguageNames.VisualBasic)), + order: 30, + languageName: LanguageNames.CSharp)), + (CompleteStatementOptionsStorage.AutomaticallyCompleteStatementOnSemicolon, CreateBooleanOption( + CompleteStatementOptionsStorage.AutomaticallyCompleteStatementOnSemicolon, + title: "Automatically complete statement on semicolon", + order: 40, + languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.SnippetsBehavior, CreateEnumOption( CompletionOptionsStorage.SnippetsBehavior, "Snippets behavior", - order: 30, - customDefaultValue: SnippetsRule.IncludeAfterTypingIdentifierQuestionTab, + order: 50, + customDefaultValue: SnippetsRule.AlwaysInclude, enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], - customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 0}], - languageName: LanguageNames.VisualBasic)), + customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}], + languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( CompletionOptionsStorage.EnterKeyBehavior, "Enter key behavior", - order: 40, - customDefaultValue: EnterKeyRule.Always, + order: 60, + customDefaultValue: EnterKeyRule.Never, enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], - customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "always", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], - languageName: LanguageNames.VisualBasic)), + customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "never", Match = 0}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], + languageName: LanguageNames.CSharp)), + (CompletionOptionsStorage.ShowNameSuggestions, CreateBooleanOption( + CompletionOptionsStorage.ShowNameSuggestions, + title: "Show name suggestions", + order: 70, + languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, CreateBooleanOption( CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, title: "Show items from unimported namespaces", - order: 50, - languageName: LanguageNames.VisualBasic)), + order: 80, + languageName: LanguageNames.CSharp)), (CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, CreateBooleanOption( CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, title: "Tab twice to insert arguments", customDefaultValue: false, - order: 60, - languageName: LanguageNames.VisualBasic, + order: 90, + languageName: LanguageNames.CSharp, + message: "Experimental feature")), + (CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, CreateBooleanOption( + CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, + title: "Show new snippet experience", + customDefaultValue: false, + order: 100, + languageName: LanguageNames.CSharp, + featureFlagAndExperimentValue: (CompletionOptionsStorage.ShowNewSnippetExperienceFeatureFlag, true), message: "Experimental feature")), ]; @@ -113,6 +140,20 @@ public async Task CSharpCategoriesTest() await VerifyTagAsync(jsonDocument.ToString()); } + [Fact] + public async Task CSharpIntellisenseTest() + { + using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.csharpSettings.registration.json"); + var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); + foreach (var (option, _) in s_csharpIntellisenseExpectedSettings) + { + Assert.True(s_csharpUnifiedSettingsStorage.ContainsKey(option)); + } + + VerifyProperties(jsonDocument!, "textEditor.csharp.intellisense", s_csharpIntellisenseExpectedSettings); + await VerifyTagAsync(jsonDocument!.ToString()); + } + #endregion #region VisualBasicTest @@ -130,7 +171,7 @@ public async Task CSharpCategoriesTest() Add(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, "textEditor.basic.intellisense.enableArgumentCompletionSnippets"); /// - /// Dictionary containing the option to expected unified settings for VB intellisense page. + /// Array containing the option to expected unified settings for VB intellisense page. /// private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_visualBasicIntellisenseExpectedSettings = [ @@ -206,12 +247,22 @@ public async Task VisualBasicIntellisenseTest() { using var registrationFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicSettings.registration.json"); var jsonDocument = await JsonNode.ParseAsync(registrationFileStream!, documentOptions: new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }); - var expectedPrefix = "textEditor.basic.intellisense"; + foreach (var (option, _) in s_visualBasicIntellisenseExpectedSettings) + { + Assert.True(s_visualBasicUnifiedSettingsStorage.ContainsKey(option)); + } + + VerifyProperties(jsonDocument!, "textEditor.basic.intellisense", s_visualBasicIntellisenseExpectedSettings); + await VerifyTagAsync(jsonDocument!.ToString()); + } + + private static void VerifyProperties(JsonNode jsonDocument, string prefix, ImmutableArray<(IOption2, UnifiedSettingBase)> expectedOptionToSettings) + { var properties = jsonDocument!.Root["properties"]!.AsObject() - .Where(jsonObject => jsonObject.Key.StartsWith(expectedPrefix)) + .Where(jsonObject => jsonObject.Key.StartsWith(prefix)) .SelectAsArray(jsonObject => jsonObject.Value); Assert.Equal(s_visualBasicIntellisenseExpectedSettings.Length, properties.Length); - foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(s_visualBasicIntellisenseExpectedSettings, (actual, expected) => (actual, expected))) + foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(expectedOptionToSettings, (actual, expected) => (actual, expected))) { // We only have bool and enum option now. UnifiedSettingBase actualSetting = expectedOption.Definition.Type.IsEnum @@ -219,7 +270,6 @@ public async Task VisualBasicIntellisenseTest() : actualJson.Deserialize>()!; Assert.Equal(expectedSetting, actualSetting); } - await VerifyTagAsync(jsonDocument.ToString()); } #endregion @@ -247,7 +297,7 @@ private static UnifiedSettingsOption CreateBooleanOption( IOption2 onboardedOption, string title, int order, - string? languageName, + string languageName, bool? customDefaultValue = null, (IOption2 featureFlagOption, bool value)? featureFlagAndExperimentValue = null, (IOption2 enableWhenOption, object whenValue)? enableWhenOptionAndValue = null, @@ -264,7 +314,7 @@ private static UnifiedSettingsOption CreateBooleanOption( : null; var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" + ? $"config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}='{enableWhenOptionAndValue.Value.whenValue}'" : null; var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; @@ -300,7 +350,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( string title, int order, string[] enumLabels, - string? languageName, + string languageName, T? customDefaultValue = default, T[]? enumValues = null, Map[]? customMaps = null, @@ -327,7 +377,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( : null; var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{s_visualBasicUnifiedSettingsStorage[enableWhenOptionAndValue.Value.enableWhenOption]}='{enableWhenOptionAndValue.Value.whenValue}'" + ? $"config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}='{enableWhenOptionAndValue.Value.whenValue}'" : null; var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; @@ -347,5 +397,15 @@ private static UnifiedSettingsEnumOption CreateEnumOption( }; } + private static string GetUnifiedSettingsOptionValue(IOption2 option, string languageName) + { + return languageName switch + { + LanguageNames.CSharp => s_csharpUnifiedSettingsStorage[option], + LanguageNames.VisualBasic => s_visualBasicUnifiedSettingsStorage[option], + _ => throw ExceptionUtilities.UnexpectedValue(languageName) + }; + } + #endregion } From 6191f8cef11e6e95aea601f4dfc4229d3f37de0e Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Sat, 21 Dec 2024 00:42:56 -0800 Subject: [PATCH 38/45] correct strings --- .../CSharp/Impl/PackageRegistration.pkgdef | 2 +- .../csharpSettings.registration.json | 2 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef index b593987a392e8..81e69c3834119 100644 --- a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef @@ -198,4 +198,4 @@ [$RootKey$\SettingsManifests\{13c3bbb4-f18f-4111-9f54-a0fb010d9194}] @="Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage" "ManifestPath"="$PackageFolder$\UnifiedSettings\csharpSettings.registration.json" -"CacheTag"=qword:3AEFDB0DA1308654 +"CacheTag"=qword:3AEFDB0DA1308655 diff --git a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json index e74d59bb1e44b..0e1f0f4a18e03 100644 --- a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json +++ b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json @@ -100,7 +100,7 @@ "title": "@Snippets_behavior;..\\Microsoft.VisualStudio.LanguageServices.dll", "type": "string", "enum": [ "neverInclude", "alwaysInclude", "includeAfterTypingIdentifierQuestionTab" ], - "enumItemLabels": [ "@Never_include_snippets;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}", "@Always_include_snippets;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}", "@Include_snippets_when_Tab_is_typed_after_an_identifier;{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" ], + "enumItemLabels": [ "@Never_include_snippets;..\\Microsoft.VisualStudio.LanguageServices.dll", "@Always_include_snippets;..\\Microsoft.VisualStudio.LanguageServices.CSharp.dll", "@Include_snippets_when_Tab_is_typed_after_an_identifier;..\\Microsoft.VisualStudio.LanguageServices.CSharp.dll" ], "default": "alwaysInclude", "order": 50, "migration": { diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 240140af555fc..2a00d34a4a43b 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -50,10 +50,10 @@ public class UnifiedSettingsTests private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_csharpIntellisenseExpectedSettings = [ (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( - CompletionOptionsStorage.TriggerOnTypingLetters, - title: "Show completion list after a character is typed", - order: 0, - languageName: LanguageNames.CSharp)), + CompletionOptionsStorage.TriggerOnTypingLetters, + title: "Show completion list after a character is typed", + order: 0, + languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( CompletionOptionsStorage.TriggerOnDeletion, title: "Show completion list after a character is deleted", @@ -176,10 +176,10 @@ public async Task CSharpIntellisenseTest() private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_visualBasicIntellisenseExpectedSettings = [ (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( - CompletionOptionsStorage.TriggerOnTypingLetters, - title: "Show completion list after a character is typed", - order: 0, - languageName: LanguageNames.VisualBasic)), + CompletionOptionsStorage.TriggerOnTypingLetters, + title: "Show completion list after a character is typed", + order: 0, + languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.TriggerOnDeletion, CreateBooleanOption( CompletionOptionsStorage.TriggerOnDeletion, title: "Show completion list after a character is deleted", @@ -261,7 +261,7 @@ private static void VerifyProperties(JsonNode jsonDocument, string prefix, Immut var properties = jsonDocument!.Root["properties"]!.AsObject() .Where(jsonObject => jsonObject.Key.StartsWith(prefix)) .SelectAsArray(jsonObject => jsonObject.Value); - Assert.Equal(s_visualBasicIntellisenseExpectedSettings.Length, properties.Length); + Assert.Equal(expectedOptionToSettings.Length, properties.Length); foreach (var (actualJson, (expectedOption, expectedSetting)) in properties.Zip(expectedOptionToSettings, (actual, expected) => (actual, expected))) { // We only have bool and enum option now. @@ -314,7 +314,7 @@ private static UnifiedSettingsOption CreateBooleanOption( : null; var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}='{enableWhenOptionAndValue.Value.whenValue}'" + ? $"${{config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}}}=='{enableWhenOptionAndValue.Value.whenValue.ToString().ToCamelCase()}'" : null; var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; @@ -377,7 +377,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( : null; var enableWhen = enableWhenOptionAndValue is not null - ? $"config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}='{enableWhenOptionAndValue.Value.whenValue}'" + ? $"${{config:{GetUnifiedSettingsOptionValue(enableWhenOptionAndValue.Value.enableWhenOption, languageName)}}}=='{enableWhenOptionAndValue.Value.whenValue.ToString().ToCamelCase()}'" : null; var expectedDefault = customDefaultValue ?? onboardedOption.Definition.DefaultValue; From dfd977d5cc113b98c731213e4854586678e41916 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 30 Dec 2024 15:01:33 -0800 Subject: [PATCH 39/45] Correct strings --- src/VisualStudio/CSharp/Impl/CSharpVSResources.resx | 5 ++++- .../Impl/Options/IntelliSenseOptionPageControl.xaml | 2 +- .../CSharp/Impl/Options/IntelliSenseOptionPageStrings.cs | 4 ++-- .../CSharp/Impl/xlf/CSharpVSResources.cs.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.de.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.es.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.fr.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.it.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.ja.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.ko.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.pl.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.ru.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.tr.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf | 9 +++++++-- .../CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf | 9 +++++++-- .../Test.Next/UnifiedSettings/UnifiedSettingsTests.cs | 4 ++-- 17 files changed, 100 insertions(+), 32 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx index 7301b82f0e069..e88da7e866b92 100644 --- a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx +++ b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx @@ -449,9 +449,12 @@ In other binary operators: && || ?? and or 'and' and 'or' are C# keywords and should not be localized - + Show name s_uggestions + + Show name suggestions + In relational operators: < > <= >= is as == != 'is' and 'as' are C# keywords and should not be localized diff --git a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml index 20871e782a672..e1072c383a688 100644 --- a/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/IntelliSenseOptionPageControl.xaml @@ -68,7 +68,7 @@ + Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Show_name_s_uggestions}" /> CSharpVSResources.Include_snippets_when_Tab_is_typed_after_an_identifier; - public static string Option_Show_name_suggestions - => CSharpVSResources.Show_name_suggestions; + public static string Option_Show_name_s_uggestions + => CSharpVSResources.Show_name_s_uggestions; public static string Option_Show_items_from_unimported_namespaces => ServicesVSResources.Show_items_from_unimported_namespaces; diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf index b8cd4986633dc..c527b39240640 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf @@ -177,6 +177,11 @@ Zobrazit nápovědy pro výrazy new + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Zobrazit nové prostředí fragmentů kódu (experimentální) @@ -698,8 +703,8 @@ - Show name s_uggestions - Zobrazovat návr_hy názvů + Show name suggestions + Zobrazovat návr_hy názvů diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf index 878ef1343afbb..91fdd3590c060 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf @@ -177,6 +177,11 @@ Hinweise für new-Ausdrücke anzeigen + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Neue Ausschnittsoberfläche anzeigen (experimentell) @@ -698,8 +703,8 @@ - Show name s_uggestions - Namensv_orschläge anzeigen + Show name suggestions + Namensv_orschläge anzeigen diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf index cc2bcbb4fe33f..50ac722713b6f 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf @@ -177,6 +177,11 @@ Mostrar sugerencias para las expresiones "new" + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Mostrar nueva experiencia de fragmento de código (experimental) @@ -698,8 +703,8 @@ - Show name s_uggestions - Mostrar s_ugerencias de nombres + Show name suggestions + Mostrar s_ugerencias de nombres diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf index 7e1f51ad4c9ff..d6cfb79970929 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf @@ -177,6 +177,11 @@ Afficher les indicateurs pour les expressions 'new' + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Afficher une nouvelle expérience d’extrait de code (expérimental) @@ -698,8 +703,8 @@ - Show name s_uggestions - Afficher les s_uggestions de nom + Show name suggestions + Afficher les s_uggestions de nom diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf index 23cf1c4bed483..4f98aea9c6286 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf @@ -177,6 +177,11 @@ Mostra suggerimenti per le espressioni 'new' + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Mostra nuova esperienza del frammento (sperimentale) @@ -698,8 +703,8 @@ - Show name s_uggestions - Mostra s_uggerimenti per nomi + Show name suggestions + Mostra s_uggerimenti per nomi diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf index 82256fd0203ef..28a85be1f06b6 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf @@ -177,6 +177,11 @@ 'new' 式のヒントを表示する + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) 新しいスニペット エクスペリエンスの表示 (試験段階) @@ -698,8 +703,8 @@ - Show name s_uggestions - 名前の提案を表示(_U) + Show name suggestions + 名前の提案を表示(_U) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf index 5dbdf090294a4..a223c47e8ef98 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf @@ -177,6 +177,11 @@ 'new' 식에 대한 힌트 표시 + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) 새 코드 조각 환경 표시(실험적) @@ -698,8 +703,8 @@ - Show name s_uggestions - 이름 제안 표시(_U) + Show name suggestions + 이름 제안 표시(_U) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf index 6e17b3ae9c869..59e6e96958363 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf @@ -177,6 +177,11 @@ Pokaż wskazówki dla wyrażeń „new” + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Pokaż nowe środowisko fragmentu kodu (eksperymentalne) @@ -698,8 +703,8 @@ - Show name s_uggestions - Pokaż s_ugestie dotyczące nazwy + Show name suggestions + Pokaż s_ugestie dotyczące nazwy diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf index 2e7b71b033df0..38bd4b3013fe0 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf @@ -177,6 +177,11 @@ Mostrar as dicas para as expressões 'new' + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Mostrar nova experiência de snippet de código (experimental) @@ -698,8 +703,8 @@ - Show name s_uggestions - Mostrar s_ugestões de nomes + Show name suggestions + Mostrar s_ugestões de nomes diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf index e9cc93d237f6d..f175bcb184481 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf @@ -177,6 +177,11 @@ Отображать подсказки для выражений "new" + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Показывать новый интерфейс фрагмента кода (экспериментальная функция) @@ -698,8 +703,8 @@ - Show name s_uggestions - Показывать в_арианты имен + Show name suggestions + Показывать в_арианты имен diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf index beb13710653f7..0a2d43934b0ee 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf @@ -177,6 +177,11 @@ 'new' ifadeleri için ipuçlarını göster + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) Yeni kod parçacığı deneyimini göster (deneysel) @@ -698,8 +703,8 @@ - Show name s_uggestions - Ad ö_nerilerini göster + Show name suggestions + Ad ö_nerilerini göster diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf index 99004eeac0975..d1f7ad4453f14 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf @@ -177,6 +177,11 @@ 显示 "new" 表达式的提示 + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) 显示新的代码片段体验(试验) @@ -698,8 +703,8 @@ - Show name s_uggestions - 显示名称建议(_U) + Show name suggestions + 显示名称建议(_U) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf index 11befe3ddd2d2..f49c187491da9 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf @@ -177,6 +177,11 @@ 顯示 'new' 運算式的提示 + + Show name s_uggestions + Show name s_uggestions + + Show new snippet experience (experimental) 顯示新的程式碼片段體驗 (實驗性) @@ -698,8 +703,8 @@ - Show name s_uggestions - 顯示名稱建議(_U) + Show name suggestions + 顯示名稱建議(_U) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 2a00d34a4a43b..92dba192d552e 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -88,7 +88,7 @@ public class UnifiedSettingsTests customDefaultValue: SnippetsRule.AlwaysInclude, enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], - customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}], + customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "alwaysInclude", Match = 0}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}], languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( CompletionOptionsStorage.EnterKeyBehavior, @@ -97,7 +97,7 @@ public class UnifiedSettingsTests customDefaultValue: EnterKeyRule.Never, enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], - customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "never", Match = 0}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], + customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "never", Match = 0}, new Map { Result = "always", Match = 2}, new Map { Result = "afterFullyTypedWord", Match = 3}], languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.ShowNameSuggestions, CreateBooleanOption( CompletionOptionsStorage.ShowNameSuggestions, From 483c4a801f9967bda15ba9362e777f35f7795bb2 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 30 Dec 2024 15:37:44 -0800 Subject: [PATCH 40/45] Correct pkgdef --- .../CSharp/Impl/CSharpVSResources.resx | 3 +++ .../CSharp/Impl/PackageRegistration.pkgdef | 2 +- .../csharpSettings.registration.json | 2 +- .../CSharp/Impl/xlf/CSharpVSResources.cs.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.de.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.es.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.fr.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.it.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.ja.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.ko.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.pl.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.ru.xlf | 5 +++++ .../CSharp/Impl/xlf/CSharpVSResources.tr.xlf | 5 +++++ .../Impl/xlf/CSharpVSResources.zh-Hans.xlf | 5 +++++ .../Impl/xlf/CSharpVSResources.zh-Hant.xlf | 5 +++++ .../TestModel/AlternativeDefault.cs | 2 ++ .../TestModel/UnifiedSettingsOption.cs | 4 ++-- .../UnifiedSettings/UnifiedSettingsTests.cs | 16 ++++++++-------- 19 files changed, 82 insertions(+), 12 deletions(-) diff --git a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx index e88da7e866b92..1294054572933 100644 --- a/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx +++ b/src/VisualStudio/CSharp/Impl/CSharpVSResources.resx @@ -536,6 +536,9 @@ Show new snippet experience (experimental) + + Show new snippet experience + Allow blank line after token in conditional expression diff --git a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef index 81e69c3834119..1a5637a51aad2 100644 --- a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef @@ -198,4 +198,4 @@ [$RootKey$\SettingsManifests\{13c3bbb4-f18f-4111-9f54-a0fb010d9194}] @="Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService.CSharpPackage" "ManifestPath"="$PackageFolder$\UnifiedSettings\csharpSettings.registration.json" -"CacheTag"=qword:3AEFDB0DA1308655 +"CacheTag"=qword:18C11F0A543B8AD0 diff --git a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json index 0e1f0f4a18e03..627bd2ab30446 100644 --- a/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json +++ b/src/VisualStudio/CSharp/Impl/UnifiedSettings/csharpSettings.registration.json @@ -225,7 +225,7 @@ }, // CompletionOptionsStorage.ShowNewSnippetExperienceUserOption "textEditor.csharp.intellisense.showNewSnippetExperience": { - "title": "@Show_new_snippet_experience_experimental;..\\Microsoft.VisualStudio.LanguageServices.CSharp.dll", + "title": "@Show_new_snippet_experience;..\\Microsoft.VisualStudio.LanguageServices.CSharp.dll", "type": "boolean", "default": false, "messages": [ diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf index c527b39240640..e1c4cc4776bb8 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.cs.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Zobrazit nové prostředí fragmentů kódu (experimentální) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf index 91fdd3590c060..dd26b273bb22c 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.de.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Neue Ausschnittsoberfläche anzeigen (experimentell) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf index 50ac722713b6f..f1a6af39bdd90 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.es.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Mostrar nueva experiencia de fragmento de código (experimental) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf index d6cfb79970929..1c01ddbc6d47e 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.fr.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Afficher une nouvelle expérience d’extrait de code (expérimental) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf index 4f98aea9c6286..cb563ea25c5b9 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.it.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Mostra nuova esperienza del frammento (sperimentale) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf index 28a85be1f06b6..4ddb98d5b905e 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ja.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) 新しいスニペット エクスペリエンスの表示 (試験段階) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf index a223c47e8ef98..4869b58f2b810 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ko.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) 새 코드 조각 환경 표시(실험적) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf index 59e6e96958363..3c8a0c83b66b0 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pl.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Pokaż nowe środowisko fragmentu kodu (eksperymentalne) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf index 38bd4b3013fe0..87455a313f37c 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.pt-BR.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Mostrar nova experiência de snippet de código (experimental) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf index f175bcb184481..8337be2b11d50 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.ru.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Показывать новый интерфейс фрагмента кода (экспериментальная функция) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf index 0a2d43934b0ee..9400db37331ff 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.tr.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) Yeni kod parçacığı deneyimini göster (deneysel) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf index d1f7ad4453f14..6e6d46a78e19c 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hans.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) 显示新的代码片段体验(试验) diff --git a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf index f49c187491da9..97b2e8f4ade82 100644 --- a/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf +++ b/src/VisualStudio/CSharp/Impl/xlf/CSharpVSResources.zh-Hant.xlf @@ -182,6 +182,11 @@ Show name s_uggestions + + Show new snippet experience + Show new snippet experience + + Show new snippet experience (experimental) 顯示新的程式碼片段體驗 (實驗性) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs index 9862b6c608603..dc5de0685dd5d 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/AlternativeDefault.cs @@ -11,8 +11,10 @@ namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; internal record AlternativeDefault { + [JsonPropertyName("flagName")] public string FlagName { get; init; } + [JsonPropertyName("default")] public T Default { get; init; } [JsonConstructor] diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs index 90b9c673b5e59..78b7d80ba7752 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingsOption.cs @@ -11,6 +11,6 @@ internal record UnifiedSettingsOption : UnifiedSettingBase [JsonPropertyName("default")] public required T Default { get; init; } - [JsonPropertyName("alternativeDefault")] - public AlternativeDefault? AlternativeDefault { get; init; } + [JsonPropertyName("alternateDefault")] + public AlternativeDefault? AlternateDefault { get; init; } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 92dba192d552e..21c6fa9e76301 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -137,7 +137,7 @@ public async Task CSharpCategoriesTest() Assert.Equal("C#", propertyToCategory["textEditor.csharp"]!.Title); Assert.Equal("IntelliSense", propertyToCategory["textEditor.csharp.intellisense"]!.Title); Assert.Equal(Guids.CSharpOptionPageIntelliSenseIdString, propertyToCategory["textEditor.csharp.intellisense"]!.LegacyOptionPageId); - await VerifyTagAsync(jsonDocument.ToString()); + await VerifyTagAsync(jsonDocument.ToString(), "Roslyn.VisualStudio.Next.UnitTests.csharpPackageRegistration.pkgdef"); } [Fact] @@ -151,7 +151,7 @@ public async Task CSharpIntellisenseTest() } VerifyProperties(jsonDocument!, "textEditor.csharp.intellisense", s_csharpIntellisenseExpectedSettings); - await VerifyTagAsync(jsonDocument!.ToString()); + await VerifyTagAsync(jsonDocument!.ToString(), "Roslyn.VisualStudio.Next.UnitTests.csharpPackageRegistration.pkgdef"); } #endregion @@ -239,7 +239,7 @@ public async Task VisualBasicCategoriesTest() Assert.Equal("Visual Basic", propertyToCategory["textEditor.basic"]!.Title); Assert.Equal("IntelliSense", propertyToCategory["textEditor.basic.intellisense"]!.Title); Assert.Equal(Guids.VisualBasicOptionPageIntelliSenseIdString, propertyToCategory["textEditor.basic.intellisense"]!.LegacyOptionPageId); - await VerifyTagAsync(jsonDocument.ToString()); + await VerifyTagAsync(jsonDocument.ToString(), "Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); } [Fact] @@ -253,7 +253,7 @@ public async Task VisualBasicIntellisenseTest() } VerifyProperties(jsonDocument!, "textEditor.basic.intellisense", s_visualBasicIntellisenseExpectedSettings); - await VerifyTagAsync(jsonDocument!.ToString()); + await VerifyTagAsync(jsonDocument!.ToString(), "Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); } private static void VerifyProperties(JsonNode jsonDocument, string prefix, ImmutableArray<(IOption2, UnifiedSettingBase)> expectedOptionToSettings) @@ -276,9 +276,9 @@ private static void VerifyProperties(JsonNode jsonDocument, string prefix, Immut #region Helpers - private static async Task VerifyTagAsync(string registrationFile) + private static async Task VerifyTagAsync(string registrationFile, string pkgdefFileName) { - using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.Next.UnitTests.visualBasicPackageRegistration.pkgdef"); + using var pkgDefFileStream = typeof(UnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream(pkgdefFileName); using var streamReader = new StreamReader(pkgDefFileStream!); var pkgdefFile = await streamReader.ReadToEndAsync(); @@ -339,7 +339,7 @@ private static UnifiedSettingsOption CreateBooleanOption( Order = order, EnableWhen = enableWhen, Migration = migration, - AlternativeDefault = alternativeDefault, + AlternateDefault = alternativeDefault, Default = (bool)expectedDefault, Messages = message is null ? null : [new Message { Text = message }], }; @@ -392,7 +392,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( Order = order, EnableWhen = enableWhen, Migration = migration, - AlternativeDefault = alternativeDefault, + AlternateDefault = alternativeDefault, Default = expectedDefault.ToString().ToCamelCase(), }; } From 2e8bad9fb362afd1742c30522a8dfd084ea617f1 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 30 Dec 2024 16:02:03 -0800 Subject: [PATCH 41/45] Fix formatting --- .../TestModel/ResourceStringArrayConverter.cs | 2 +- .../UnifiedSettings/UnifiedSettingsTests.cs | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs index 26450871d1330..49121b16e7931 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringArrayConverter.cs @@ -25,7 +25,7 @@ public override string[] Read(ref Utf8JsonReader reader, Type typeToConvert, Jso if (reader.TokenType == JsonTokenType.String) { var value = reader.GetString()!; - builder.Add(Utilities.EvalResource(value)); + builder.Add(Utilities.EvalResource(value)!); } else { diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 21c6fa9e76301..ee90775234f15 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.Collections.Immutable; using System.IO; using System.IO.Hashing; @@ -19,8 +18,6 @@ using Microsoft.CodeAnalysis.Editor.CSharp.CompleteStatement; using Microsoft.CodeAnalysis.Options; using Microsoft.VisualStudio.LanguageServices; -using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; -using Roslyn.Test.Utilities; using Roslyn.Utilities; using Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; using Xunit; @@ -88,7 +85,7 @@ public class UnifiedSettingsTests customDefaultValue: SnippetsRule.AlwaysInclude, enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], - customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "alwaysInclude", Match = 0}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}], + customMaps: [new Map { Result = "neverInclude", Match = 1 }, new Map { Result = "alwaysInclude", Match = 2 }, new Map { Result = "alwaysInclude", Match = 0 }, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3 }], languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( CompletionOptionsStorage.EnterKeyBehavior, @@ -97,7 +94,7 @@ public class UnifiedSettingsTests customDefaultValue: EnterKeyRule.Never, enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], - customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "never", Match = 0}, new Map { Result = "always", Match = 2}, new Map { Result = "afterFullyTypedWord", Match = 3}], + customMaps: [new Map { Result = "never", Match = 1 }, new Map { Result = "never", Match = 0 }, new Map { Result = "always", Match = 2}, new Map { Result = "afterFullyTypedWord", Match = 3 }], languageName: LanguageNames.CSharp)), (CompletionOptionsStorage.ShowNameSuggestions, CreateBooleanOption( CompletionOptionsStorage.ShowNameSuggestions, @@ -203,7 +200,7 @@ public async Task CSharpIntellisenseTest() customDefaultValue: SnippetsRule.IncludeAfterTypingIdentifierQuestionTab, enumLabels: ["Never include snippets", "Always include snippets", "Include snippets when ?-Tab is typed after an identifier"], enumValues: [SnippetsRule.NeverInclude, SnippetsRule.AlwaysInclude, SnippetsRule.IncludeAfterTypingIdentifierQuestionTab], - customMaps: [new Map { Result = "neverInclude", Match = 1}, new Map { Result = "alwaysInclude", Match = 2}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3}, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 0}], + customMaps: [new Map { Result = "neverInclude", Match = 1 }, new Map { Result = "alwaysInclude", Match = 2 }, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 3 }, new Map { Result = "includeAfterTypingIdentifierQuestionTab", Match = 0 }], languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.EnterKeyBehavior, CreateEnumOption( CompletionOptionsStorage.EnterKeyBehavior, @@ -212,7 +209,7 @@ public async Task CSharpIntellisenseTest() customDefaultValue: EnterKeyRule.Always, enumLabels: ["Never add new line on enter", "Only add new line on enter after end of fully typed word", "Always add new line on enter"], enumValues: [EnterKeyRule.Never, EnterKeyRule.AfterFullyTypedWord, EnterKeyRule.Always], - customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "always", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3}], + customMaps: [new Map { Result = "never", Match = 1}, new Map { Result = "always", Match = 2}, new Map { Result = "always", Match = 0}, new Map { Result = "afterFullyTypedWord", Match = 3 }], languageName: LanguageNames.VisualBasic)), (CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, CreateBooleanOption( CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, @@ -368,7 +365,7 @@ private static UnifiedSettingsEnumOption CreateEnumOption( EnumIntegerToString = new EnumIntegerToString { Input = new Input(onboardedOption, languageName), - Map = customMaps ?? [.. expectedEnumValues.Select(value => new Map { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value)})] + Map = customMaps ?? [.. expectedEnumValues.Select(value => new Map { Result = value.ToString().ToCamelCase(), Match = Convert.ToInt32(value) })] } }; From 1abb24efe0ca9ac487113d33fb0c12d14c25e029 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Mon, 30 Dec 2024 16:15:54 -0800 Subject: [PATCH 42/45] Delete dead code --- .../VisualBasicUnifiedSettingsTests.vb | 93 ------------------- ...io.LanguageServices.Test.Utilities2.vbproj | 2 - 2 files changed, 95 deletions(-) delete mode 100644 src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb diff --git a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb b/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb deleted file mode 100644 index d9c52299b9329..0000000000000 --- a/src/VisualStudio/Core/Test/UnifiedSettings/VisualBasicUnifiedSettingsTests.vb +++ /dev/null @@ -1,93 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports System.Collections.Immutable -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Completion -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings - -Namespace Roslyn.VisualStudio.VisualBasic.UnitTests.UnifiedSettings - Public Class VisualBasicUnifiedSettingsTests - Inherits UnifiedSettingsTests - - Friend Overrides ReadOnly Property OnboardedOptions As ImmutableArray(Of IOption2) - Get - Return ImmutableArray.Create(Of IOption2)( - CompletionOptionsStorage.TriggerOnTypingLetters, - CompletionOptionsStorage.TriggerOnDeletion, - CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, - CompletionViewOptionsStorage.ShowCompletionItemFilters, - CompletionOptionsStorage.SnippetsBehavior, - CompletionOptionsStorage.EnterKeyBehavior, - CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, - CompletionViewOptionsStorage.EnableArgumentCompletionSnippets - ) - End Get - End Property - - Friend Overrides Function GetEnumOptionValues([option] As IOption2) As Object() - Dim allValues = [Enum].GetValues([option].Type).Cast(Of Object) - If [option].Equals(CompletionOptionsStorage.SnippetsBehavior) Then - 'SnippetsRule.Default is used as a stub value, overridden per language at runtime. - ' It is not shown in the option page - Return allValues.Where(Function(value) Not value.Equals(SnippetsRule.Default)).ToArray() - ElseIf [option].Equals(CompletionOptionsStorage.EnterKeyBehavior) Then - ' EnterKeyRule.Default is used as a stub value, overridden per language at runtime. - ' It Is Not shown in the option page - Return allValues.Where(Function(value) Not value.Equals(EnterKeyRule.Default)).ToArray() - End If - - Return MyBase.GetEnumOptionValues([option]) - End Function - - Friend Overrides Function GetOptionsDefaultValue([option] As IOption2) As Object - ' The default values of some options are set at runtime. option.defaultValue is just a dummy value in this case. - ' However, in unified settings we always set the correct value in registration.json. - If [option].Equals(CompletionOptionsStorage.SnippetsBehavior) Then - ' CompletionOptionsStorage.SnippetsBehavior's default value is SnippetsRule.Default. - ' It's overridden differently per-language at runtime. - Return SnippetsRule.IncludeAfterTypingIdentifierQuestionTab - ElseIf [option].Equals(CompletionOptionsStorage.EnterKeyBehavior) Then - ' CompletionOptionsStorage.EnterKeyBehavior's default value is EnterKeyBehavior.Default. - ' It's overridden differently per-language at runtime. - Return EnterKeyRule.Always - ElseIf [option].Equals(CompletionOptionsStorage.TriggerOnDeletion) Then - ' CompletionOptionsStorage.TriggerOnDeletion's default value is null. - ' It's enabled by default for Visual Basic - Return True - ElseIf [option].Equals(CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces) Then - ' CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces's default value is null - ' It's enabled by default for Visual Basic - Return True - ElseIf [option].Equals(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets) Then - ' CompletionViewOptionsStorage.EnableArgumentCompletionSnippets' default value is null - ' It's disabled by default for Visual Basic - Return False - End If - - Return MyBase.GetOptionsDefaultValue([option]) - End Function - - ' - 'Public Async Function CategoriesTest() As Task - ' Using registrationFileStream = GetType(VisualBasicUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("visualBasicSettings.registration.json") - ' Using reader = New StreamReader(registrationFileStream) - ' Dim registrationFile = Await reader.ReadToEndAsync() - ' Dim registrationJsonObject = JObject.Parse(registrationFile, New JsonLoadSettings() With {.CommentHandling = CommentHandling.Ignore}) - ' Dim categories = registrationJsonObject.Property("categories") - ' Dim nameToCategories = categories.Value.Children(Of JProperty).ToDictionary( - ' Function(jProperty) jProperty.Name, - ' Function(jProperty) jProperty.Value.ToObject(Of UnifiedSettingsCategory)) - - ' Assert.True(nameToCategories.ContainsKey("textEditor.basic")) - ' Assert.Equal("Visual Basic", nameToCategories("textEditor.basic").Title) - - ' Assert.True(nameToCategories.ContainsKey("textEditor.basic.intellisense")) - ' Assert.Equal("IntelliSense", nameToCategories("textEditor.basic.intellisense").Title) - ' End Using - ' End Using - 'End Function - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj index a74a7f6977dc3..6ca1ded5756a1 100644 --- a/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj +++ b/src/VisualStudio/TestUtilities2/Microsoft.VisualStudio.LanguageServices.Test.Utilities2.vbproj @@ -9,8 +9,6 @@ false true - - From 2f867e6272c6573f425714137157f5c6a02939f9 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 31 Dec 2024 11:13:01 -0800 Subject: [PATCH 43/45] Add comment --- .../Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index ee90775234f15..60fe570b63e87 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -44,6 +44,9 @@ public class UnifiedSettingsTests Add(CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, "textEditor.csharp.intellisense.enableArgumentCompletionSnippets"). Add(CompletionOptionsStorage.ShowNewSnippetExperienceUserOption, "textEditor.csharp.intellisense.showNewSnippetExperience"); + /// + /// Array containing the option to expected unified settings for C# intellisense page. + /// private static readonly ImmutableArray<(IOption2, UnifiedSettingBase)> s_csharpIntellisenseExpectedSettings = [ (CompletionOptionsStorage.TriggerOnTypingLetters, CreateBooleanOption( From 7ea23ce2da65a5c8f1b86f94c9e1b6025accefb0 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Tue, 31 Dec 2024 11:16:08 -0800 Subject: [PATCH 44/45] File scope ns --- .../TestModel/ResourceStringConverter.cs | 26 +++++++++---------- .../TestModel/UnifiedSettingBase.cs | 1 + 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs index 34bd431dae33c..403f6904347db 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/ResourceStringConverter.cs @@ -6,24 +6,22 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel +namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; +internal class ResourceStringConverter : JsonConverter { - internal class ResourceStringConverter : JsonConverter + public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + if (reader.TokenType == JsonTokenType.String) { - if (reader.TokenType == JsonTokenType.String) - { - var locReference = reader.GetString()!; - return Utilities.EvalResource(locReference); - } - - throw new NotImplementedException(); + var locReference = reader.GetString()!; + return Utilities.EvalResource(locReference); } - public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); + } + + public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) + { + throw new NotImplementedException(); } } diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs index ef8419a21d390..9528726891695 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/TestModel/UnifiedSettingBase.cs @@ -7,6 +7,7 @@ using Roslyn.Utilities; namespace Roslyn.VisualStudio.Next.UnitTests.UnifiedSettings.TestModel; + internal abstract record UnifiedSettingBase { [JsonPropertyName("title")] From 87d6ec99d8634eb6f2b5d035c8e9dbd784202661 Mon Sep 17 00:00:00 2001 From: Shen Chen Date: Thu, 2 Jan 2025 12:01:44 -0800 Subject: [PATCH 45/45] Remove dead code --- .../CSharpUnifiedSettingsTests.cs | 119 --------- .../UnifiedSettings/UnifiedSettingsTests.cs | 2 +- .../UnifiedSettings/UnifiedSettingsTests.vb | 228 ------------------ ...iedSettingsTests_UnifiedSettingsStorage.vb | 58 ----- 4 files changed, 1 insertion(+), 406 deletions(-) delete mode 100644 src/VisualStudio/CSharp/Test/UnifiedSettings/CSharpUnifiedSettingsTests.cs delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb delete mode 100644 src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests_UnifiedSettingsStorage.vb diff --git a/src/VisualStudio/CSharp/Test/UnifiedSettings/CSharpUnifiedSettingsTests.cs b/src/VisualStudio/CSharp/Test/UnifiedSettings/CSharpUnifiedSettingsTests.cs deleted file mode 100644 index cd9d0faf9bdc3..0000000000000 --- a/src/VisualStudio/CSharp/Test/UnifiedSettings/CSharpUnifiedSettingsTests.cs +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Immutable; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Completion; -using Microsoft.CodeAnalysis.Editor.CSharp.CompleteStatement; -using Microsoft.CodeAnalysis.Options; -using Microsoft.VisualStudio.LanguageServices; -using Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings; -using Newtonsoft.Json.Linq; -using Xunit; - -namespace Roslyn.VisualStudio.CSharp.UnitTests.UnifiedSettings -{ - public class CSharpUnifiedSettingsTests : UnifiedSettingsTests - { - internal override ImmutableArray OnboardedOptions => ImmutableArray.Create( - CompletionOptionsStorage.TriggerOnTypingLetters, - CompletionOptionsStorage.TriggerOnDeletion, - CompletionOptionsStorage.TriggerInArgumentLists, - CompletionViewOptionsStorage.HighlightMatchingPortionsOfCompletionListItems, - CompletionViewOptionsStorage.ShowCompletionItemFilters, - CompleteStatementOptionsStorage.AutomaticallyCompleteStatementOnSemicolon, - CompletionOptionsStorage.SnippetsBehavior, - CompletionOptionsStorage.EnterKeyBehavior, - CompletionOptionsStorage.ShowNameSuggestions, - CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces, - CompletionViewOptionsStorage.EnableArgumentCompletionSnippets, - CompletionOptionsStorage.ShowNewSnippetExperienceUserOption - ); - - internal override object[] GetEnumOptionValues(IOption2 option) - { - var allValues = Enum.GetValues(option.Type).Cast(); - if (option == CompletionOptionsStorage.SnippetsBehavior) - { - // SnippetsRule.Default is used as a stub value, overridden per language at runtime. - // It is not shown in the option page - return allValues.Where(value => !value.Equals(SnippetsRule.Default)).ToArray(); - } - else if (option == CompletionOptionsStorage.EnterKeyBehavior) - { - // EnterKeyRule.Default is used as a stub value, overridden per language at runtime. - // It is not shown in the option page - return allValues.Where(value => !value.Equals(EnterKeyRule.Default)).ToArray(); - } - - return base.GetEnumOptionValues(option); - } - - internal override object GetOptionsDefaultValue(IOption2 option) - { - // The default values of some options are set at runtime. option.defaultValue is just a dummy value in this case. - // However, in unified settings we always set the correct value in registration.json. - if (option == CompletionOptionsStorage.SnippetsBehavior) - { - // CompletionOptionsStorage.SnippetsBehavior's default value is SnippetsRule.Default. - // It's overridden differently per-language at runtime. - return SnippetsRule.AlwaysInclude; - } - else if (option == CompletionOptionsStorage.EnterKeyBehavior) - { - // CompletionOptionsStorage.EnterKeyBehavior's default value is EnterKeyBehavior.Default. - // It's overridden differently per-language at runtime. - return EnterKeyRule.Never; - } - else if (option == CompletionOptionsStorage.TriggerOnDeletion) - { - // CompletionOptionsStorage.TriggerOnDeletion's default value is null. - // It's disabled by default for C# - return false; - } - else if (option == CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces) - { - // CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces's default value is null - // It's enabled by default for C# - return true; - } - else if (option == CompletionViewOptionsStorage.EnableArgumentCompletionSnippets) - { - // CompletionViewOptionsStorage.EnableArgumentCompletionSnippets' default value is null - // It's disabled by default for C# - return false; - } - else if (option == CompletionOptionsStorage.ShowNewSnippetExperienceUserOption) - { - // CompletionOptionsStorage.ShowNewSnippetExperienceUserOption's default value is null. - // It's in experiment, so disabled by default. - return false; - } - - return base.GetOptionsDefaultValue(option); - } - - [Fact] - public async Task IntelliSensePageTests() - { - using var registrationFileStream = typeof(CSharpUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.CSharp.UnitTests.csharpSettings.registration.json"); - using var reader = new StreamReader(registrationFileStream); - var registrationFile = await reader.ReadToEndAsync().ConfigureAwait(false); - var registrationJsonObject = JObject.Parse(registrationFile, new JsonLoadSettings() { CommentHandling = CommentHandling.Ignore }); - var categoriesTitle = registrationJsonObject.SelectToken($"$.categories['textEditor.csharp'].title")!; - Assert.Equal("C#", actual: categoriesTitle.ToString()); - var optionPageId = registrationJsonObject.SelectToken("$.categories['textEditor.csharp.intellisense'].legacyOptionPageId"); - Assert.Equal(Guids.CSharpOptionPageIntelliSenseIdString, optionPageId!.ToString()); - using var pkgdefFileStream = typeof(CSharpUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.CSharp.UnitTests.PackageRegistration.pkgdef"); - using var pkgdefReader = new StreamReader(pkgdefFileStream); - var pkgdefFile = await pkgdefReader.ReadToEndAsync().ConfigureAwait(false); - TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath: "textEditor.csharp.intellisense", languageName: LanguageNames.CSharp, pkgdefFile); - } - } -} diff --git a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs index 60fe570b63e87..37eeb37486dd6 100644 --- a/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs +++ b/src/VisualStudio/Core/Test.Next/UnifiedSettings/UnifiedSettingsTests.cs @@ -283,7 +283,7 @@ private static async Task VerifyTagAsync(string registrationFile, string pkgdefF var pkgdefFile = await streamReader.ReadToEndAsync(); var fileBytes = Encoding.ASCII.GetBytes(registrationFile); - var expectedTags = BitConverter.ToInt64(XxHash128.Hash(fileBytes).Take(8).ToArray(), 0).ToString("X16"); + var expectedTags = BitConverter.ToInt64([.. XxHash128.Hash(fileBytes).Take(8)], 0).ToString("X16"); var regex = new Regex(""" "CacheTag"=qword:\w{16} """); diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb deleted file mode 100644 index ecf8ba700f9bf..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests.vb +++ /dev/null @@ -1,228 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports System.Collections.Immutable -Imports System.IO.Hashing -Imports System.Text -Imports System.Text.RegularExpressions -Imports Microsoft.CodeAnalysis -Imports Microsoft.CodeAnalysis.Options -Imports Microsoft.VisualStudio.LanguageServices.Options -Imports Microsoft.VisualStudio.LanguageServices.Options.VisualStudioOptionStorage -Imports Newtonsoft.Json.Linq -Imports Roslyn.Test.Utilities -Imports Roslyn.Utilities - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings - Partial Public MustInherit Class UnifiedSettingsTests - ' Onboarded options in Unified Settings registration file - Friend MustOverride ReadOnly Property OnboardedOptions As ImmutableArray(Of IOption2) - - ' Override this method to if the option use different default value. - Friend Overridable Function GetOptionsDefaultValue([option] As IOption2) As Object - Return [option].DefaultValue - End Function - - ' Override this method to specify all possible enum values in option page. - Friend Overridable Function GetEnumOptionValues([option] As IOption2) As Object() - Dim type = [option].Definition.Type - Assert.True(type.IsEnum) - Return [Enum].GetValues(type).Cast(Of Object).AsArray() - End Function - - Protected Sub TestUnifiedSettingsCategory(registrationJsonObject As JObject, categoryBasePath As String, languageName As String, pkdDefFile As String) - Dim actualAllSettings = registrationJsonObject.SelectToken($"$.properties").Children.OfType(Of JProperty). - Where(Function(setting) setting.Name.StartsWith(categoryBasePath)). - Select(Function(setting) setting.Name). - OrderBy(Function(name) name). - ToArray() - - Dim expectedAllSettings = OnboardedOptions.Select(Function(onboardedOption) s_unifiedSettingsStorage(onboardedOption.Definition.ConfigName).GetUnifiedSettingsPath(languageName)). - OrderBy(Function(name) name). - ToArray() - Assert.Equal(expectedAllSettings, actualAllSettings) - - For Each onboardedOption In OnboardedOptions - Dim optionName = onboardedOption.Definition.ConfigName - Dim settingStorage As UnifiedSettingsStorage = Nothing - If s_unifiedSettingsStorage.TryGetValue(optionName, settingStorage) Then - Dim unifiedSettingsPath = settingStorage.GetUnifiedSettingsPath(languageName) - VerifyType(registrationJsonObject, unifiedSettingsPath, onboardedOption) - - Dim expectedDefaultValue = GetOptionsDefaultValue(onboardedOption) - Dim actualDefaultValue = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingsPath}').default") - Assert.Equal(expectedDefaultValue.ToString().ToCamelCase(), actualDefaultValue.ToString().ToCamelCase()) - - If onboardedOption.Type.IsEnum Then - ' Enum settings contains special setup. - VerifyEnum(registrationJsonObject, unifiedSettingsPath, onboardedOption, languageName) - Else - VerifySettings(registrationJsonObject, unifiedSettingsPath, onboardedOption, languageName) - End If - Else - ' Can't find the option in the storage dictionary - Throw ExceptionUtilities.UnexpectedValue(optionName) - End If - Next - - Dim registrationFileBytes = ASCIIEncoding.ASCII.GetBytes(registrationJsonObject.ToString()) - Dim hash = XxHash128.Hash(registrationFileBytes) - Dim tagBytes = hash.Take(8).ToArray() - Dim expectedCacheTagValue = BitConverter.ToInt64(tagBytes, 0).ToString("X16") - - Dim regexExp = New Regex("""CacheTag""=qword:\w{16}") - Dim match = regexExp.Match(pkdDefFile, 0).Value - Dim actual = match.Substring(match.Length - 16) - ' Please change the CacheTag value in pkddef if you modify the unified settings regirstration file - Assert.Equal(expectedCacheTagValue, actual) - End Sub - - Private Shared Sub VerifySettings(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2, languageName As String) - VerifyMigration(registrationJsonObject, unifiedSettingPath, [option], languageName) - End Sub - - Private Sub VerifyEnum(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2, languageName As String) - Dim actualEnumValues = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingPath}').enum").Select(Function(token) token.ToString()).OrderBy(Function(value) value) - Dim expectedEnumValues = GetEnumOptionValues([option]).Select(Function(value) value.ToString().ToCamelCase()).OrderBy(Function(value) value) - AssertEx.Equal(expectedEnumValues, actualEnumValues) - VerifyEnumMigration(registrationJsonObject, unifiedSettingPath, [option], languageName) - End Sub - - Private Shared Sub VerifyType(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2) - Dim actualType = registrationJsonObject.SelectToken($"$.properties['{unifiedSettingPath}'].type") - Dim expectedType = [option].Definition.Type - If expectedType.IsEnum Then - ' Enum is string in json - Assert.Equal("string", actualType.ToString()) - Else - Dim expectedTypeName = ConvertTypeNameToJsonType([option].Definition.Type) - Assert.Equal(expectedTypeName, actualType.ToString()) - End If - End Sub - - Private Shared Function ConvertTypeNameToJsonType(optionType As Type) As String - Dim underlyingType = Nullable.GetUnderlyingType(optionType) - ' If the type is Nullable type, its mapping type in unified setting page would be the normal type - ' These options would need to change to non-nullable form - ' See https://github.com/dotnet/roslyn/issues/69367 - If underlyingType Is Nothing Then - Return optionType.Name.ToCamelCase() - Else - Return underlyingType.Name.ToCamelCase() - End If - End Function - - Private Sub VerifyEnumMigration(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2, languageName As String) - Dim actualMigration = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingPath}').migration") - Dim migrationProperty = DirectCast(actualMigration.Children().Single(), JProperty) - Dim migrationType = migrationProperty.Name - Assert.Equal("enumIntegerToString", migrationType) - - ' Verify input node and map node - Dim input = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingPath}').migration.enumIntegerToString.input") - VerifyInput(input, [option], languageName) - VerifyEnumToIntegerMappings(registrationJsonObject, unifiedSettingPath, [option]) - End Sub - - Private Shared Sub VerifyMigration(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2, languageName As String) - Dim actualMigration = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingPath}').migration") - ' Get the single property under migration - Dim migrationProperty = DirectCast(actualMigration.Children().Single(), JProperty) - Dim migrationType = migrationProperty.Name - If migrationType = "pass" Then - ' Verify input node - Dim input = registrationJsonObject.SelectToken($"$.properties('{unifiedSettingPath}').migration.pass.input") - VerifyInput(input, [option], languageName) - Else - ' Need adding more migration types if new type is added - Throw ExceptionUtilities.UnexpectedValue(migrationType) - End If - End Sub - - ' Verify input property under migration - Private Shared Sub VerifyInput(input As JToken, [option] As IOption2, languageName As String) - Dim store = input.SelectToken("store").ToString() - Dim path = input.SelectToken("path").ToString() - Dim configName = [option].Definition.ConfigName - Dim visualStudioStorage = Storages(configName) - If TypeOf visualStudioStorage Is VisualStudioOptionStorage.RoamingProfileStorage Then - Dim roamingProfileStorage = DirectCast(visualStudioStorage, VisualStudioOptionStorage.RoamingProfileStorage) - Assert.Equal("SettingsManager", store) - Assert.Equal(roamingProfileStorage.Key.Replace("%LANGUAGE%", GetSubstituteLanguage(languageName)), path) - Else - ' Not supported yet - Throw ExceptionUtilities.Unreachable - End If - End Sub - - Private Shared Function GetSubstituteLanguage(languageName As String) As String - Select Case languageName - Case LanguageNames.CSharp - Return "CSharp" - Case LanguageNames.VisualBasic - Return "VisualBasic" - Case Else - Return languageName - End Select - End Function - - Private Sub VerifyEnumToIntegerMappings(registrationJsonObject As JObject, unifiedSettingPath As String, [option] As IOption2) - ' Here we are going to verify a structure like this: - ' "map": [ - ' { - ' "result": "neverInclude", - ' "match": 1 - ' }, - ' // '0' matches to SnippetsRule.Default. Means the behavior is decided by language. - ' // '2' matches to SnippetsRule.AlwaysInclude. It's the default behavior for C# - ' // Put both mapping here, so it's possible for unified setting to load '0' from the storage. - ' // Put '2' in front, so unified settings would persist '2' to storage when 'alwaysInclude' is selected. - ' { - ' "result": "alwaysInclude", - ' "match": 2 - ' }, - ' { - ' "result": "alwaysInclude", - ' "match": 0 - ' }, - ' { - ' "result": "includeAfterTypingIdentifierQuestionTab", - ' "match": 3 - ' } - ' ] - Dim actualMappings = CType(registrationJsonObject.SelectToken(String.Format("$.properties['{0}'].migration.enumIntegerToString.map", unifiedSettingPath)), JArray).Select(Function(mapping) (mapping("result").ToString(), Integer.Parse(mapping("match").ToString()))).ToArray() - - Dim enumValues = [option].Type.GetEnumValues().Cast(Of Object).ToDictionary( - keySelector:=Function(enumValue) enumValue.ToString().ToCamelCase(), - elementSelector:=Function(enumValue) - Dim actualDefaultValue = GetOptionsDefaultValue([option]) - If actualDefaultValue.Equals(enumValue) Then - ' This value is the real default value at runtime. - ' So map it to both default value and its own value. - ' Like 'alwaysInclude' in the above example, it would map to both 0 and 2. - Return New Integer() {CInt(enumValue), CInt([option].DefaultValue)} - End If - - Return New Integer() {CInt(enumValue)} - End Function - ) - - For Each tuple In actualMappings - Dim result = tuple.Item1 - Dim match = tuple.Item2 - Dim acceptableValues = enumValues(result) - Assert.Contains(match, acceptableValues) - Next - - ' If the default value of the enum is a stub value, verify the real value mapping is put in font of the default value mapping. - ' It makes sure the default value would be converted to the real value by unified settings engine. - Dim realDefaultValue = GetOptionsDefaultValue([option]) - Dim indexOfTheRealDefaultMapping = Array.IndexOf(actualMappings, (realDefaultValue.ToString().ToCamelCase(), CInt(realDefaultValue))) - Assert.NotEqual(-1, indexOfTheRealDefaultMapping) - Dim indexOfTheDefaultMapping = Array.IndexOf(actualMappings, (realDefaultValue.ToString().ToCamelCase(), CInt([option].DefaultValue))) - Assert.NotEqual(-1, indexOfTheDefaultMapping) - Assert.True(indexOfTheRealDefaultMapping < indexOfTheDefaultMapping) - End Sub - End Class -End Namespace diff --git a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests_UnifiedSettingsStorage.vb b/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests_UnifiedSettingsStorage.vb deleted file mode 100644 index b253bc0db5914..0000000000000 --- a/src/VisualStudio/TestUtilities2/UnifiedSettings/UnifiedSettingsTests_UnifiedSettingsStorage.vb +++ /dev/null @@ -1,58 +0,0 @@ -' Licensed to the .NET Foundation under one or more agreements. -' The .NET Foundation licenses this file to you under the MIT license. -' See the LICENSE file in the project root for more information. - -Imports Microsoft.CodeAnalysis - -Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings - Partial Public Class UnifiedSettingsTests - - ' Mapping from the config name to its path in Unified Settings registration file - Private Shared ReadOnly s_unifiedSettingsStorage As New Dictionary(Of String, UnifiedSettingsStorage)() From { - {"dotnet_trigger_completion_on_typing_letters", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.triggerCompletionOnTypingLetters")}, - {"dotnet_trigger_completion_on_deletion", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.triggerCompletionOnDeletion")}, - {"dotnet_trigger_completion_in_argument_lists", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.triggerCompletionInArgumentLists")}, - {"dotnet_highlight_matching_portions_of_completion_list_items", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.highlightMatchingPortionsOfCompletionListItems")}, - {"dotnet_show_completion_item_filters", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.showCompletionItemFilters")}, - {"csharp_complete_statement_on_semicolon", New UnifiedSettingsStorage("textEditor.csharp.intellisense.completeStatementOnSemicolon")}, - {"dotnet_snippets_behavior", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.snippetsBehavior")}, - {"dotnet_return_key_completion_behavior", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.returnKeyCompletionBehavior")}, - {"dotnet_show_name_completion_suggestions", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.showNameCompletionSuggestions")}, - {"dotnet_show_completion_items_from_unimported_namespaces", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.showCompletionItemsFromUnimportedNamespaces")}, - {"dotnet_enable_argument_completion_snippets", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.enableArgumentCompletionSnippets")}, - {"dotnet_show_new_snippet_experience", New UnifiedSettingsStorage("textEditor.%LANGUAGE%.intellisense.showNewSnippetExperience")} - } - - Friend NotInheritable Class UnifiedSettingsStorage - Private Const LanguagePlaceholder As String = "%LANGUAGE%" - - ' C# name used in Unified Settings path. - Private Const csharpKey As String = "csharp" - - ' Visual Basic name used in Unified Settings path. - Private Const visualBasicKey As String = "basic" - - ' Unified settings base path, might contains %LANGAUGE% if it maps to two per-language different setting. - Public Property UnifiedSettingsBasePath As String - - Public Sub New(unifiedSettingsPath As String) - UnifiedSettingsBasePath = unifiedSettingsPath - End Sub - - Public Function GetUnifiedSettingsPath(language As String) As String - If Not UnifiedSettingsBasePath.Contains(LanguagePlaceholder) Then - Return UnifiedSettingsBasePath - End If - - Select Case language - Case LanguageNames.CSharp - Return UnifiedSettingsBasePath.Replace(LanguagePlaceholder, csharpKey) - Case LanguageNames.VisualBasic - Return UnifiedSettingsBasePath.Replace(LanguagePlaceholder, visualBasicKey) - Case Else - Throw New Exception("Unexpected language value") - End Select - End Function - End Class - End Class -End Namespace