From b7520648ce34948733f2c90a26ad40d4ab4af38f Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 18 Jun 2024 11:09:09 -0700 Subject: [PATCH 1/5] wip --- .../InlineHints/CSharpInlineTypeHintsService.cs | 14 ++++++++++++++ .../InlineHints/AbstractInlineTypeHintsService.cs | 5 ++++- .../Portable/InlineHints/InlineTypeHintsOptions.cs | 1 + .../Features/Options/InlineHintsOptionsStorage.cs | 6 ++++++ ...eConfigurationNotificationHandler_OptionList.cs | 1 + .../Handler/InlayHint/InlayHintRefreshQueue.cs | 3 ++- .../Impl/Options/AdvancedOptionPageControl.xaml | 3 +++ .../Impl/Options/AdvancedOptionPageControl.xaml.cs | 2 ++ .../Impl/Options/AdvancedOptionPageStrings.cs | 3 +++ src/VisualStudio/Core/Def/ServicesVSResources.resx | 3 +++ .../Core/Def/xlf/ServicesVSResources.cs.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.de.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.es.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.fr.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.it.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.ja.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.ko.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.pl.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.pt-BR.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.ru.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.tr.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.zh-Hans.xlf | 5 +++++ .../Core/Def/xlf/ServicesVSResources.zh-Hant.xlf | 5 +++++ 23 files changed, 104 insertions(+), 2 deletions(-) diff --git a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs index c6c11c5cf76f1..21d31b1b19132 100644 --- a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs +++ b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs @@ -30,6 +30,7 @@ public CSharpInlineTypeHintsService() bool forImplicitVariableTypes, bool forLambdaParameterTypes, bool forImplicitObjectCreation, + bool forCollectionExpressions, CancellationToken cancellationToken) { if (forImplicitVariableTypes || displayAllOverride) @@ -101,6 +102,19 @@ public CSharpInlineTypeHintsService() } } + if (forCollectionExpressions || displayAllOverride) + { + if (node is CollectionExpressionSyntax collectionExpression) + { + var type = semanticModel.GetTypeInfo(collectionExpression, cancellationToken).Type; + if (IsValidType(type)) + { + var span = new TextSpan(collectionExpression.OpenBracketToken.SpanStart, 0); + return new(type, span, new TextChange(span, " " + type.ToDisplayString(s_minimalTypeStyle)), leadingSpace: true); + } + } + } + return null; } diff --git a/src/Features/Core/Portable/InlineHints/AbstractInlineTypeHintsService.cs b/src/Features/Core/Portable/InlineHints/AbstractInlineTypeHintsService.cs index afa31bfc38840..b97e07e7cfc2a 100644 --- a/src/Features/Core/Portable/InlineHints/AbstractInlineTypeHintsService.cs +++ b/src/Features/Core/Portable/InlineHints/AbstractInlineTypeHintsService.cs @@ -25,6 +25,7 @@ internal abstract class AbstractInlineTypeHintsService : IInlineTypeHintsService bool forImplicitVariableTypes, bool forLambdaParameterTypes, bool forImplicitObjectCreation, + bool forCollectionExpressions, CancellationToken cancellationToken); public async Task> GetInlineHintsAsync( @@ -42,7 +43,8 @@ public async Task> GetInlineHintsAsync( var forImplicitVariableTypes = enabledForTypes && options.ForImplicitVariableTypes; var forLambdaParameterTypes = enabledForTypes && options.ForLambdaParameterTypes; var forImplicitObjectCreation = enabledForTypes && options.ForImplicitObjectCreation; - if (!forImplicitVariableTypes && !forLambdaParameterTypes && !forImplicitObjectCreation && !displayAllOverride) + var forCollectionExpressions = enabledForTypes && options.ForCollectionExpressions; + if (!forImplicitVariableTypes && !forLambdaParameterTypes && !forImplicitObjectCreation && !forCollectionExpressions && !displayAllOverride) return []; var anonymousTypeService = document.GetRequiredLanguageService(); @@ -59,6 +61,7 @@ public async Task> GetInlineHintsAsync( forImplicitVariableTypes, forLambdaParameterTypes, forImplicitObjectCreation, + forCollectionExpressions, cancellationToken); if (hintOpt == null) continue; diff --git a/src/Features/Core/Portable/InlineHints/InlineTypeHintsOptions.cs b/src/Features/Core/Portable/InlineHints/InlineTypeHintsOptions.cs index 55eed2ab3a0fa..337eeb1cc5e4b 100644 --- a/src/Features/Core/Portable/InlineHints/InlineTypeHintsOptions.cs +++ b/src/Features/Core/Portable/InlineHints/InlineTypeHintsOptions.cs @@ -13,6 +13,7 @@ internal readonly record struct InlineTypeHintsOptions [DataMember] public bool ForImplicitVariableTypes { get; init; } = true; [DataMember] public bool ForLambdaParameterTypes { get; init; } = true; [DataMember] public bool ForImplicitObjectCreation { get; init; } = true; + [DataMember] public bool ForCollectionExpressions { get; init; } = true; public InlineTypeHintsOptions() { diff --git a/src/LanguageServer/Protocol/Features/Options/InlineHintsOptionsStorage.cs b/src/LanguageServer/Protocol/Features/Options/InlineHintsOptionsStorage.cs index fbb6760f3e92d..1c7d753152b10 100644 --- a/src/LanguageServer/Protocol/Features/Options/InlineHintsOptionsStorage.cs +++ b/src/LanguageServer/Protocol/Features/Options/InlineHintsOptionsStorage.cs @@ -37,6 +37,7 @@ public static InlineTypeHintsOptions GetInlineTypeHintsOptions(this IGlobalOptio ForImplicitVariableTypes = globalOptions.GetOption(ForImplicitVariableTypes, language), ForLambdaParameterTypes = globalOptions.GetOption(ForLambdaParameterTypes, language), ForImplicitObjectCreation = globalOptions.GetOption(ForImplicitObjectCreation, language), + ForCollectionExpressions = globalOptions.GetOption(ForCollectionExpressions, language), }; // Note: inlay hints is the term used in LSP, we Want to use the LSP name when communicate with the LSP client. @@ -105,5 +106,10 @@ public static InlineTypeHintsOptions GetInlineTypeHintsOptions(this IGlobalOptio new("csharp_enable_inlay_hints_for_implicit_object_creation", defaultValue: InlineTypeHintsOptions.Default.ForImplicitObjectCreation, group: s_inlayHintOptionGroup); + + public static readonly PerLanguageOption2 ForCollectionExpressions = + new("csharp_enable_inlay_hints_for_collection_expressions", + defaultValue: InlineTypeHintsOptions.Default.ForCollectionExpressions, + group: s_inlayHintOptionGroup); } } diff --git a/src/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs b/src/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs index 0309744c859e2..b5e15a8ebe982 100644 --- a/src/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs +++ b/src/LanguageServer/Protocol/Handler/Configuration/DidChangeConfigurationNotificationHandler_OptionList.cs @@ -43,6 +43,7 @@ internal partial class DidChangeConfigurationNotificationHandler InlineHintsOptionsStorage.ForImplicitVariableTypes, InlineHintsOptionsStorage.ForLambdaParameterTypes, InlineHintsOptionsStorage.ForImplicitObjectCreation, + InlineHintsOptionsStorage.ForCollectionExpressions, FormattingOptions2.TabSize, FormattingOptions2.IndentationSize, FormattingOptions2.UseTabs, diff --git a/src/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs b/src/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs index 887de0f1b7321..898757acd7052 100644 --- a/src/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs +++ b/src/LanguageServer/Protocol/Handler/InlayHint/InlayHintRefreshQueue.cs @@ -45,7 +45,8 @@ private void OnOptionChanged(object? sender, OptionChangedEventArgs e) option.Equals(InlineHintsOptionsStorage.EnabledForTypes) || option.Equals(InlineHintsOptionsStorage.ForImplicitVariableTypes) || option.Equals(InlineHintsOptionsStorage.ForLambdaParameterTypes) || - option.Equals(InlineHintsOptionsStorage.ForImplicitObjectCreation))) + option.Equals(InlineHintsOptionsStorage.ForImplicitObjectCreation) || + option.Equals(InlineHintsOptionsStorage.ForCollectionExpressions))) { EnqueueRefreshNotification(documentUri: null); } diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml index 2c36e6160d267..82cedfd390e2b 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml @@ -375,6 +375,9 @@ + diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs index 97420ed39698e..856ea19ad8860 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageControl.xaml.cs @@ -192,6 +192,7 @@ public AdvancedOptionPageControl(OptionStore optionStore, IComponentModel compon BindToOption(ShowHintsForVariablesWithInferredTypes, InlineHintsOptionsStorage.ForImplicitVariableTypes, LanguageNames.CSharp); BindToOption(ShowHintsForLambdaParameterTypes, InlineHintsOptionsStorage.ForLambdaParameterTypes, LanguageNames.CSharp); BindToOption(ShowHintsForImplicitObjectCreation, InlineHintsOptionsStorage.ForImplicitObjectCreation, LanguageNames.CSharp); + BindToOption(ShowHintsForCollectionExpressions, InlineHintsOptionsStorage.ForCollectionExpressions, LanguageNames.CSharp); // Inheritance Margin // Leave the null converter here to make sure if the option value is get from the storage (if it is null), the feature will be enabled @@ -244,6 +245,7 @@ private void UpdateInlineHintsOptions() ShowHintsForVariablesWithInferredTypes.IsEnabled = enabledForTypes; ShowHintsForLambdaParameterTypes.IsEnabled = enabledForTypes; ShowHintsForImplicitObjectCreation.IsEnabled = enabledForTypes; + ShowHintsForCollectionExpressions.IsEnabled = enabledForTypes; } private void DisplayInlineParameterNameHints_Checked(object sender, RoutedEventArgs e) diff --git a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs index 5c55c8b3cceea..bef3bb0d94931 100644 --- a/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs +++ b/src/VisualStudio/CSharp/Impl/Options/AdvancedOptionPageStrings.cs @@ -126,6 +126,9 @@ public static string Option_Show_hints_for_lambda_parameter_types public static string Option_Show_hints_for_implicit_object_creation => ServicesVSResources.Show_hints_for_implicit_object_creation; + public static string Option_Show_hints_for_collection_expressions + => ServicesVSResources.Show_hints_for_collection_expressions; + public static string Option_Display_diagnostics_inline_experimental => ServicesVSResources.Display_diagnostics_inline_experimental; diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index 98b39446ba210..bba55ff1ad8dc 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1936,4 +1936,7 @@ Additional information: {1} Prefer static anonymous functions + + Show hints for collection expressions + \ 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 8c868bf5d3962..5aa8afbe4d426 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Zobrazit nápovědy pro všechno ostatní diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index 9d52afe126846..ba98c975270bd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Hinweise für alles andere anzeigen diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index 79782eed35c1e..33248aaaf1e68 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Mostrar sugerencias para todo lo demás diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index dc18a73e70632..f7f28edd2623d 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Afficher les indicateurs pour tout le reste diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index 077d209781b7d..78c3cfcb7f4b7 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Mostra suggerimenti per tutto il resto diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 29512ddd33bc4..e616d221c95bd 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else その他すべてのヒントを表示する diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index 178b6df549c1d..f38245fe20558 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else 다른 모든 항목에 대한 힌트 표시 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index be395078288e4..d0913b62e556e 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Pokaż wskazówki dla wszystkich innych elementów diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 25d424549122b..19421e122bbaf 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Mostrar as dicas para tudo diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index 2d0406b10f9ba..15eb48e5b3135 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Отображать подсказки для всех остальных элементов diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 35417d153dc19..77efc7b89d548 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else Diğer her şey için ipuçlarını göster diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index 56f9038fb5ad5..28ca0a43c72eb 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else 显示其他所有内容的提示 diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index d43c7673ab4c2..d3044f6b44db6 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -1362,6 +1362,11 @@ Show guides for comments and preprocessor regions + + Show hints for collection expressions + Show hints for collection expressions + + Show hints for everything else 顯示所有其他項目的提示 From 582fc533f4213a8716206b6e8d6e4a37cb831665 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 18 Jun 2024 11:41:47 -0700 Subject: [PATCH 2/5] fix --- .../Core/InlineHints/InlineHintsDataTaggerProvider.cs | 3 ++- .../Portable/InlineHints/CSharpInlineTypeHintsService.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/InlineHints/InlineHintsDataTaggerProvider.cs b/src/EditorFeatures/Core/InlineHints/InlineHintsDataTaggerProvider.cs index 113e4e37f2d5c..76f1ab0e43683 100644 --- a/src/EditorFeatures/Core/InlineHints/InlineHintsDataTaggerProvider.cs +++ b/src/EditorFeatures/Core/InlineHints/InlineHintsDataTaggerProvider.cs @@ -70,7 +70,8 @@ protected override ITaggerEventSource CreateEventSource(ITextView textView, ITex option.Equals(InlineHintsOptionsStorage.EnabledForTypes) || option.Equals(InlineHintsOptionsStorage.ForImplicitVariableTypes) || option.Equals(InlineHintsOptionsStorage.ForLambdaParameterTypes) || - option.Equals(InlineHintsOptionsStorage.ForImplicitObjectCreation))); + option.Equals(InlineHintsOptionsStorage.ForImplicitObjectCreation) || + option.Equals(InlineHintsOptionsStorage.ForCollectionExpressions))); } protected override void AddSpansToTag(ITextView? textView, ITextBuffer subjectBuffer, ref TemporaryArray result) diff --git a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs index 21d31b1b19132..3313cd75e7757 100644 --- a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs +++ b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs @@ -106,7 +106,8 @@ public CSharpInlineTypeHintsService() { if (node is CollectionExpressionSyntax collectionExpression) { - var type = semanticModel.GetTypeInfo(collectionExpression, cancellationToken).Type; + var x = semanticModel.GetTypeInfo(collectionExpression, cancellationToken); + var type = x.ConvertedType; if (IsValidType(type)) { var span = new TextSpan(collectionExpression.OpenBracketToken.SpanStart, 0); From 33d8ca92b3bd4af56c7c9785bba847b74e99eb57 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 18 Jun 2024 11:54:45 -0700 Subject: [PATCH 3/5] undo --- .../Portable/InlineHints/CSharpInlineTypeHintsService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs index 3313cd75e7757..2125fa138883c 100644 --- a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs +++ b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs @@ -106,8 +106,7 @@ public CSharpInlineTypeHintsService() { if (node is CollectionExpressionSyntax collectionExpression) { - var x = semanticModel.GetTypeInfo(collectionExpression, cancellationToken); - var type = x.ConvertedType; + var type = semanticModel.GetTypeInfo(collectionExpression, cancellationToken).ConvertedType; if (IsValidType(type)) { var span = new TextSpan(collectionExpression.OpenBracketToken.SpanStart, 0); From 2fd889c889f2115712f6973a838e37ecdd625860 Mon Sep 17 00:00:00 2001 From: akhera99 Date: Tue, 18 Jun 2024 12:59:20 -0700 Subject: [PATCH 4/5] remove space --- .../CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs index 2125fa138883c..521b3e2940959 100644 --- a/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs +++ b/src/Features/CSharp/Portable/InlineHints/CSharpInlineTypeHintsService.cs @@ -110,7 +110,7 @@ public CSharpInlineTypeHintsService() if (IsValidType(type)) { var span = new TextSpan(collectionExpression.OpenBracketToken.SpanStart, 0); - return new(type, span, new TextChange(span, " " + type.ToDisplayString(s_minimalTypeStyle)), leadingSpace: true); + return new(type, span, new TextChange(span, type.ToDisplayString(s_minimalTypeStyle)), leadingSpace: true); } } } From b26105c6584ecdebab8e6e0c64b733aa8e385d3f Mon Sep 17 00:00:00 2001 From: akhera99 Date: Wed, 19 Jun 2024 15:19:21 -0700 Subject: [PATCH 5/5] fix testss --- .../DidChangeConfigurationNotificationHandlerTest.cs | 1 + src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs b/src/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs index 319d303d1d507..ea13825ac98b0 100644 --- a/src/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs +++ b/src/LanguageServer/ProtocolUnitTests/Configuration/DidChangeConfigurationNotificationHandlerTest.cs @@ -133,6 +133,7 @@ public void VerifyLspClientOptionNames() "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", + "inlay_hints.csharp_enable_inlay_hints_for_collection_expressions", "code_style.formatting.indentation_and_spacing.tab_width", "code_style.formatting.indentation_and_spacing.indent_size", "code_style.formatting.indentation_and_spacing.indent_style", diff --git a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs index 6c18a932809de..75e0e4065feab 100644 --- a/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs +++ b/src/VisualStudio/Core/Def/Options/VisualStudioOptionStorage.cs @@ -330,6 +330,7 @@ public bool TryFetch(LocalUserRegistryOptionPersister persister, OptionKey2 opti {"dotnet_enable_inlay_hints_for_parameters", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints")}, {"csharp_enable_inlay_hints_for_types", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineTypeHints")}, {"csharp_enable_inlay_hints_for_implicit_object_creation", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitObjectCreation")}, + {"csharp_enable_inlay_hints_for_collection_expressions", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForCollectionExpressions")}, {"csharp_enable_inlay_hints_for_implicit_variable_types", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForImplicitVariableTypes")}, {"dotnet_enable_inlay_hints_for_indexer_parameters", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineParameterNameHints.ForArrayIndexers")}, {"csharp_enable_inlay_hints_for_lambda_parameter_types", new RoamingProfileStorage("TextEditor.%LANGUAGE%.Specific.InlineTypeHints.ForLambdaParameterTypes")},