Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to make sure option names won't change #69319

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static ImmutableArray<ConfigurationItem> GenerateGlobalConfigurationItem
/// Example:Full name of <see cref="ImplementTypeOptionsStorage.InsertionBehavior"/> would be:
/// implement_type.dotnet_insertion_behavior
/// </remarks>
private static string GenerateFullNameForOption(IOption2 option)
internal static string GenerateFullNameForOption(IOption2 option)
{
var optionGroupName = GenerateOptionGroupName(option);
// All options send to the client should have group name and config name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ internal partial class DidChangeConfigurationNotificationHandler
ImplementTypeOptionsStorage.PropertyGenerationBehavior,
// Completion
CompletionOptionsStorage.ShowNameSuggestions,
CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a duplicate (See line 31)

CompletionOptionsStorage.ProvideRegexCompletions,
CompletionOptionsStorage.ShowItemsFromUnimportedNamespaces,
QuickInfoOptionsStorage.ShowRemarksInQuickInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -104,6 +105,48 @@ public class A { }";
VerifyValuesInServer(server.TestWorkspace, clientCallbackTarget.MockClientSideValues);
}

[Fact]
public void VerifyLspClientOptionNames()
{
var actualNames = DidChangeConfigurationNotificationHandler.SupportedOptions.Select(
DidChangeConfigurationNotificationHandler.GenerateFullNameForOption).ToArray();
// These options are persist in the LSP client. Please make sure also modify the LSP client code if these strings are changed.
var expectedNames = new[]
{
"symbol_search.dotnet_search_reference_assemblies",
Copy link
Member

Choose a reason for hiding this comment

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

Should we have this sorted and use one of our sort-ignoring Assert functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's possible

"implement_type.dotnet_insertion_behavior",
"implement_type.dotnet_property_generation_behavior",
"completion.dotnet_show_name_completion_suggestions",
"completion.dotnet_provide_regex_completions",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be something like dotnet.completion.provideRegexCompletions? Or am I misunderstanding what this test is trying to do?

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 the test here is just to make sure the option name + option group doesn't get changed. (because these strings would be used in the client, if it only gets changed in server client-side storage would be broken)

For completion.dotnet_provide_regex_completions is created from option group + . + option name.
Client would parse the string, and reorder it to dotnet.completion.provideRegexCompletions

"completion.dotnet_show_completion_items_from_unimported_namespaces",
"quick_info.dotnet_show_remarks_in_quick_info",
"navigation.dotnet_navigate_to_decompiled_sources",
"highlighting.dotnet_highlight_related_json_components",
"highlighting.dotnet_highlight_related_regex_components",
"inlay_hints.dotnet_enable_inlay_hints_for_parameters",
"inlay_hints.dotnet_enable_inlay_hints_for_literal_parameters",
"inlay_hints.dotnet_enable_inlay_hints_for_indexer_parameters",
"inlay_hints.dotnet_enable_inlay_hints_for_object_creation_parameters",
"inlay_hints.dotnet_enable_inlay_hints_for_other_parameters",
"inlay_hints.dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix",
"inlay_hints.dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent",
"inlay_hints.dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name",
"inlay_hints.csharp_enable_inlay_hints_for_types",
"inlay_hints.csharp_enable_inlay_hints_for_implicit_variable_types",
"inlay_hints.csharp_enable_inlay_hints_for_lambda_parameter_types",
"inlay_hints.csharp_enable_inlay_hints_for_implicit_object_creation",
"code_style.formatting.indentation_and_spacing.tab_width",
"code_style.formatting.indentation_and_spacing.indent_size",
"code_style.formatting.indentation_and_spacing.indent_style",
"code_style.formatting.new_line.end_of_line",
"code_style.formatting.new_line.insert_final_newline",
"background_analysis.dotnet_analyzer_diagnostics_scope",
"background_analysis.dotnet_compiler_diagnostics_scope"
};

Assert.Equal(expectedNames, actualNames);
}

private static void VerifyValuesInServer(TestWorkspace workspace, List<string> expectedValues)
{
var globalOptionService = workspace.GetService<IGlobalOptionService>();
Expand Down