Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef
Original file line number Diff line number Diff line change
Expand Up @@ -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:08DC1824DFE0117B
"CacheTag"=qword:CE76341698AB8CD3
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(RepoRoot)\src\VisualStudio\CSharp\Impl\UnifiedSettings\csharpSettings.registration.json" />
<EmbeddedResource Include="$(RepoRoot)\src\VisualStudio\CSharp\Impl\PackageRegistration.pkgdef" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ internal override object GetOptionsDefaultValue(IOption2 option)
[Fact]
public async Task IntelliSensePageTests()
{
var registrationFileStream = typeof(CSharpUnifiedSettingsTests).GetTypeInfo().Assembly.GetManifestResourceStream("Roslyn.VisualStudio.CSharp.UnitTests.csharpSettings.registration.json");
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());
TestUnifiedSettingsCategory(registrationJsonObject, categoryBasePath: "textEditor.csharp.intellisense", languageName: LanguageNames.CSharp);
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="$(RepoRoot)\src\VisualStudio\VisualBasic\Impl\UnifiedSettings\visualBasicSettings.registration.json" />
<EmbeddedResource Include="$(RepoRoot)\src\VisualStudio\VisualBasic\Impl\PackageRegistration.pkgdef" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
' 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
Imports System.Reflection
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Completion
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.VisualStudio.LanguageServices
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings
Imports Newtonsoft.Json.Linq

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

<Fact>
Public Async Function IntelliSensePageTests() 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)
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
End Using
End Using
End Using
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
' 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
Expand All @@ -28,7 +31,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings
Return [Enum].GetValues(type).Cast(Of Object).AsArray()
End Function

Protected Sub TestUnifiedSettingsCategory(registrationJsonObject As JObject, categoryBasePath As String, languageName As String)
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).
Expand Down Expand Up @@ -62,6 +65,17 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.UnifiedSettings
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)
Expand Down
9 changes: 0 additions & 9 deletions src/VisualStudio/VisualBasic/Impl/BasicVSResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,6 @@
<data name="Never_add_new_line_on_enter" xml:space="preserve">
<value>_Never add new line on enter</value>
</data>
<data name="Always_include_snippets" xml:space="preserve">
<value>Always include snippets</value>
</data>
<data name="Include_snippets_when_Tab_is_typed_after_an_identifier" xml:space="preserve">
<value>Include snippets when ?-Tab is typed after an identifier</value>
</data>
<data name="Never_include_snippets" xml:space="preserve">
<value>Never include snippets</value>
</data>
<data name="Snippets_behavior" xml:space="preserve">
<value>Snippets behavior</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic
<ProvideLanguageEditorOptionPage(GetType(CodeStylePage), "Basic", "Code Style", "General", "#111", 10161)>
<ProvideLanguageEditorOptionPage(GetType(NamingStylesOptionPage), "Basic", "Code Style", "Naming", "#110", 10162)>
<ProvideLanguageEditorOptionPage(GetType(IntelliSenseOptionPage), "Basic", Nothing, "IntelliSense", "#112", 312)>
<ProvideSettingsManifest(PackageRelativeManifestFile:="UnifiedSettings\visualBasicSettings.registration.json")>
<Guid(Guids.VisualBasicPackageIdString)>
Friend NotInheritable Class VisualBasicPackage
Inherits AbstractPackage(Of VisualBasicPackage, VisualBasicLanguageService)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<DeployExtension>false</DeployExtension>
</PropertyGroup>
<ItemGroup>
<Content Include="UnifiedSettings\visualBasicSettings.registration.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
</ItemGroup>
<ItemGroup Label="PkgDef">
<PkgDefInstalledProduct Include="{574fc912-f74f-4b4e-92c3-f695c208a2bb}" Name="Microsoft Visual Basic" DisplayName="#113" ProductDetails="#114" />
<!-- Cannot load in background until the VisualBasicPackage constructor has no more UI dependencies -->
Expand Down Expand Up @@ -44,12 +50,12 @@
</ItemGroup>
<ItemGroup>
<Import Include="Roslyn.Utilities" />
<Import Include="System.Threading.Tasks"/>
<Import Include="System.Threading.Tasks" />
<Import Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="BasicVSResources.resx" GenerateSource="true" Namespace="Microsoft.VisualStudio.LanguageServices.VisualBasic" />
<EmbeddedResource Update="VSPackage.resx">
<EmbeddedResource Update="VSPackage.resx" GenerateSource="true">
<MergeWithCTO>true</MergeWithCTO>
<ManifestResourceName>VSPackage</ManifestResourceName>
<SubType>Designer</SubType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
End Sub

Private Sub SetEnterKeyDefaultBehavior()
Dim snippetValue = Me.OptionStore.GetOption(CompletionOptionsStorage.EnterKeyBehavior, LanguageNames.VisualBasic)
If snippetValue = SnippetsRule.Default Then
Dim enterKeyRule = Me.OptionStore.GetOption(CompletionOptionsStorage.EnterKeyBehavior, LanguageNames.VisualBasic)
If enterKeyRule = EnterKeyRule.Default Then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so in the previous code
snippetValue is EnterKeyRule but compared to a SnippetsRule.Default
Here change it to the correct type EnterKeyRule
(Complier think it's OK, emm? )
But since they all default to value 0, so no functional change in fact.

Always_add_new_line_on_enter.IsChecked = True
End If
End Sub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
BasicVSResources.Snippets_behavior

Public ReadOnly Property Option_Never_include_snippets As String =
BasicVSResources.Never_include_snippets
VSPackage.Never_include_snippets

Public ReadOnly Property Option_Always_include_snippets As String =
BasicVSResources.Always_include_snippets
VSPackage.Always_include_snippets

Public ReadOnly Property Option_Include_snippets_when_question_Tab_is_typed_after_an_identifier As String =
BasicVSResources.Include_snippets_when_Tab_is_typed_after_an_identifier
VSPackage.Include_snippets_when_Tab_is_typed_after_an_identifier

Public ReadOnly Property Option_Show_items_from_unimported_namespaces As String =
BasicVSResources.Show_items_from_unimported_namespaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,11 @@
"Indent Style"=dword:00000002

[$RootKey$\VB Editor\Roslyn]
"DisplayLineSeparators"=dword:00000001
"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
[$RootKey$\SettingsManifests\{574fc912-f74f-4b4e-92c3-f695c208a2bb}]
@="Microsoft.VisualStudio.LanguageServices.VisualBasic.VisualBasicPackage"
"ManifestPath"="$PackageFolder$\UnifiedSettings\visualBasicSettings.registration.json"
"CacheTag"=qword:5DE8496A8900B809
Loading