From 75986e601a09b86ca81f0b077f94c3bf0348b880 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Mon, 30 Sep 2024 22:53:34 +1000 Subject: [PATCH 01/13] added prop snippet --- ...stractCSharpAutoPropertySnippetProvider.cs | 7 ++ .../Snippets/CSharpProprSnippetProvider.cs | 45 ++++++++++++ ...tCSharpAutoPropertySnippetProviderTests.cs | 6 +- .../CSharpProprSnippetProviderTests.cs | 70 +++++++++++++++++++ .../Core/Portable/FeaturesResources.resx | 3 + .../Snippets/CommonSnippetIdentifiers.cs | 1 + .../Portable/xlf/FeaturesResources.cs.xlf | 5 ++ .../Portable/xlf/FeaturesResources.de.xlf | 5 ++ .../Portable/xlf/FeaturesResources.es.xlf | 5 ++ .../Portable/xlf/FeaturesResources.fr.xlf | 5 ++ .../Portable/xlf/FeaturesResources.it.xlf | 5 ++ .../Portable/xlf/FeaturesResources.ja.xlf | 5 ++ .../Portable/xlf/FeaturesResources.ko.xlf | 5 ++ .../Portable/xlf/FeaturesResources.pl.xlf | 5 ++ .../Portable/xlf/FeaturesResources.pt-BR.xlf | 5 ++ .../Portable/xlf/FeaturesResources.ru.xlf | 5 ++ .../Portable/xlf/FeaturesResources.tr.xlf | 5 ++ .../xlf/FeaturesResources.zh-Hans.xlf | 5 ++ .../xlf/FeaturesResources.zh-Hant.xlf | 5 ++ 19 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs create mode 100644 src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs diff --git a/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs index 9e6a532dd26f2..5ec434c90ec0e 100644 --- a/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs @@ -58,6 +58,8 @@ protected override async Task GenerateSnippetSyntaxAs modifiers = SyntaxTokenList.Create(PublicKeyword); } + modifiers = modifiers.AddRange(GetAdditionalPropertyModifiers(syntaxContext)); + return SyntaxFactory.PropertyDeclaration( attributeLists: default, modifiers: modifiers, @@ -87,4 +89,9 @@ protected override ImmutableArray GetPlaceHolderLocationsLis var node = root.FindNode(TextSpan.FromBounds(position, position)); return node.GetAncestorOrThis(); } + + protected virtual SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) + { + return []; + } } diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs new file mode 100644 index 0000000000000..5d69bec62c1b4 --- /dev/null +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -0,0 +1,45 @@ +// 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.Composition; +using System.Threading; +using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editing; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.Snippets; +using Microsoft.CodeAnalysis.Snippets.SnippetProviders; + +using static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTokens; + +namespace Microsoft.CodeAnalysis.CSharp.Snippets; + +[ExportSnippetProvider(nameof(ISnippetProvider), LanguageNames.CSharp), Shared] +[method: ImportingConstructor] +[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] +internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertySnippetProvider +{ + public override string Identifier => CommonSnippetIdentifiers.RequiredProperty; + + public override string Description => FeaturesResources.required_property; + + protected override AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator, CancellationToken cancellationToken) + { + // Having a property with `set` accessor in a readonly struct leads to a compiler error. + // So if user executes snippet inside a readonly struct the right thing to do is to not generate `set` accessor at all + if (syntaxContext.ContainingTypeDeclaration is StructDeclarationSyntax structDeclaration && + syntaxContext.SemanticModel.GetDeclaredSymbol(structDeclaration, cancellationToken) is { IsReadOnly: true }) + { + return null; + } + + return base.GenerateSetAccessorDeclaration(syntaxContext, generator, cancellationToken); + } + + protected override SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) + { + return [RequiredKeyword]; + } +} diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index 8dbe4ef2d7abb..222e629ea18a2 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -13,6 +13,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; [Trait(Traits.Feature, Traits.Features.Snippets)] public abstract class AbstractCSharpAutoPropertySnippetProviderTests : AbstractCSharpSnippetProviderTests { + protected virtual string AdditionalPropertyModifiers => string.Empty; + protected abstract string DefaultPropertyBlockText { get; } [Fact] @@ -152,7 +154,7 @@ class Program { {{modifier}} $$ } - """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + """, $$"""{{AdditionalPropertyModifiers}}{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); } protected async Task VerifyPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyMarkup) @@ -163,5 +165,5 @@ protected async Task VerifyPropertyAsync([StringSyntax(PredefinedEmbeddedLanguag } protected Task VerifyDefaultPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyName = "MyProperty") - => VerifyPropertyAsync(markup, $$"""public {|0:int|} {|1:{{propertyName}}|} {{DefaultPropertyBlockText}}"""); + => VerifyPropertyAsync(markup, $$"""public {{AdditionalPropertyModifiers}}{|0:int|} {|1:{{propertyName}}|} {{DefaultPropertyBlockText}}"""); } diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs new file mode 100644 index 0000000000000..f564711946cf3 --- /dev/null +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -0,0 +1,70 @@ +// 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.Threading.Tasks; + +namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; + +public sealed class CSharpProprSnippetProviderTests : AbstractCSharpAutoPropertySnippetProviderTests +{ + protected override string SnippetIdentifier => "propr"; + + protected override string AdditionalPropertyModifiers => "required "; + + protected override string DefaultPropertyBlockText => "{ get; set; }"; + + public override async Task InsertSnippetInReadonlyStructTest() + { + // Ensure we don't generate redundant `set` accessor when executed in readonly struct + await VerifyPropertyAsync(""" + readonly struct MyStruct + { + $$ + } + """, "public required {|0:int|} {|1:MyProperty|} { get; }"); + } + + public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration() + { + // Ensure we don't generate redundant `set` accessor when executed in readonly struct + await VerifyPropertyAsync(""" + partial struct MyStruct + { + $$ + } + + readonly partial struct MyStruct + { + } + """, "public required {|0:int|} {|1:MyProperty|} { get; }"); + } + + public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration_MissingPartialModifier() + { + // Even though there is no `partial` modifier on the first declaration + // compiler still treats the whole type as partial since it is more likely that + // the user's intent was to have a partial type and they just forgot the modifier. + // Thus we still recognize that as `readonly` context and don't generate a setter + await VerifyPropertyAsync(""" + struct MyStruct + { + $$ + } + + readonly partial struct MyStruct + { + } + """, "public required {|0:int|} {|1:MyProperty|} { get; }"); + } + + public override async Task InsertSnippetInInterfaceTest() + { + await VerifyDefaultPropertyAsync(""" + interface MyInterface + { + $$ + } + """); + } +} diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 5cec87490ebac..2a19820c2b9ea 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -3171,4 +3171,7 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Symbol search + + required property + \ No newline at end of file diff --git a/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs b/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs index 1167581c3f826..06a5ce383c0a9 100644 --- a/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs +++ b/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs @@ -13,5 +13,6 @@ internal static class CommonSnippetIdentifiers public const string ConsoleWriteLine = "cw"; public const string Constructor = "ctor"; public const string Property = "prop"; + public const string RequiredProperty = "propr"; public const string GetOnlyProperty = "propg"; } diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index d9626f8e62387..1ed996476dfea 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -4200,6 +4200,11 @@ Chcete pokračovat? přístupový objekt události + + required property + požadovaná vlastnost + + rfc1123 date/time datum a čas rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index efa5ca40625b9..8fa576b220e94 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -4200,6 +4200,11 @@ Möchten Sie fortfahren? Ereignisaccessor + + required property + required property + + rfc1123 date/time RFC1123-Datum/Uhrzeit diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index e9402b2dd1524..15b6496ff6da7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? descriptor de acceso de eventos + + required property + required property + + rfc1123 date/time fecha y hora de rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 15f3753c083b5..3b368a513e415 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -4200,6 +4200,11 @@ Voulez-vous continuer ? accesseur d'événement + + required property + required property + + rfc1123 date/time date/heure (rfc1123) diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index c4f231f0df7c4..38e6c3f420425 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -4200,6 +4200,11 @@ Continuare? funzione di accesso eventi + + required property + required property + + rfc1123 date/time Data/ora RFC 1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index 9d7a5edd64985..d802e2975fea9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? イベント アクセサー + + required property + required property + + rfc1123 date/time rfc1123 日付/時刻 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 1252d1891c69e..34f25690d2ff4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? 이벤트 접근자 + + required property + required property + + rfc1123 date/time rfc1123 날짜/시간 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 815c94748be90..00072729b608e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -4200,6 +4200,11 @@ Czy chcesz kontynuować? metoda dostępu do zdarzeń + + required property + required property + + rfc1123 date/time data/godzina zgodna z rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 4e98f15df7c74..265ea4605b00b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -4200,6 +4200,11 @@ Deseja continuar? acessador de evento + + required property + required property + + rfc1123 date/time data/hora rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index f83c487da8209..27bb08f18ce3c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? метод доступа к событию + + required property + required property + + rfc1123 date/time дата и время в формате RFC1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 29932cae82242..1a9d275edb2ed 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -4200,6 +4200,11 @@ Devam etmek istiyor musunuz? olay erişeni + + required property + required property + + rfc1123 date/time rfc1123 tarih/saat diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 86a6fe05a210f..1de0656a463f7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? 事件访问器 + + required property + required property + + rfc1123 date/time rfc1123 日期/时间 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 95bdd64c6f401..85fa99b0af3ab 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -4200,6 +4200,11 @@ Do you want to continue? 事件存取子 + + required property + required property + + rfc1123 date/time rfc1123 日期/時間 From f3b0e1abf0d126029a0c012c3b3c2b60ab388872 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Mon, 30 Sep 2024 23:05:07 +1000 Subject: [PATCH 02/13] updated xlf files --- src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 8fa576b220e94..3f25fd66960c3 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -4202,7 +4202,7 @@ Möchten Sie fortfahren? required property - required property + Erforderliche eigenschaft diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 15b6496ff6da7..dfad10de86233 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + propiedad requerida diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 3b368a513e415..44fbe39dd62ed 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -4202,7 +4202,7 @@ Voulez-vous continuer ? required property - required property + propriété requise diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 38e6c3f420425..afa4a4903cc32 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -4202,7 +4202,7 @@ Continuare? required property - required property + proprietà richiesta diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index d802e2975fea9..07f0926fffedc 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + 必須プロパティ diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 34f25690d2ff4..0ae672fd24dc4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + 필수 속성 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 00072729b608e..5d0b00b3a7588 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -4202,7 +4202,7 @@ Czy chcesz kontynuować? required property - required property + wymagana właściwość diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 265ea4605b00b..0c0ba72a1f0f0 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -4202,7 +4202,7 @@ Deseja continuar? required property - required property + propriedade obrigatória diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 27bb08f18ce3c..4ec8d647f65dd 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + Обязательное свойство diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 1a9d275edb2ed..b3692ff3158d7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -4202,7 +4202,7 @@ Devam etmek istiyor musunuz? required property - required property + gerekli özellik diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 1de0656a463f7..2fee92299a293 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + 必需属性 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 85fa99b0af3ab..fc81fd24b1b07 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - required property + 必需屬性 From 802696ada539a4bec8600e5d1200bf5439959647 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Wed, 2 Oct 2024 20:36:01 +1000 Subject: [PATCH 03/13] test fixes --- .../Snippets/CSharpProprSnippetProvider.cs | 29 ++++++++++++- ...tCSharpAutoPropertySnippetProviderTests.cs | 18 +------- .../CSharpPropSnippetProviderTests.cs | 13 ++++++ .../CSharpPropgSnippetProviderTests.cs | 13 ++++++ .../CSharpPropiSnippetProviderTests.cs | 13 ++++++ .../CSharpProprSnippetProviderTests.cs | 41 ++++++++++++++++++- 6 files changed, 108 insertions(+), 19 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index 5d69bec62c1b4..57c684f515b7a 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -4,6 +4,7 @@ using System; using System.Composition; +using System.Linq; using System.Threading; using Microsoft.CodeAnalysis.CSharp.Extensions.ContextQuery; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -11,7 +12,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Snippets; using Microsoft.CodeAnalysis.Snippets.SnippetProviders; - +using Roslyn.Utilities; using static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTokens; namespace Microsoft.CodeAnalysis.CSharp.Snippets; @@ -24,6 +25,32 @@ internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertyS public override string Identifier => CommonSnippetIdentifiers.RequiredProperty; public override string Description => FeaturesResources.required_property; + + protected override bool IsValidSnippetLocationCore(SnippetContext context, CancellationToken cancellationToken) + { + if(!base.IsValidSnippetLocationCore(context, cancellationToken)) + return false; + + var syntaxContext = (CSharpSyntaxContext)context.SyntaxContext; + var precedingModifiers = syntaxContext.PrecedingModifiers; + + if (syntaxContext.PrecedingModifiers.IsEmpty()) + return true; + + // "private" and "private protected" modifiers are NOT valid for required property + if (precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.PrivateKeyword)) + return false; + + // "protected internal" modifiers are valid for required property + if(precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) + return true; + + // "protected" and "private protected" modifiers are NOT valid for required property + if(precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.ProtectedKeyword)) + return false; + + return true; + } protected override AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator, CancellationToken cancellationToken) { diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index 222e629ea18a2..d4968e15539e6 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -13,8 +13,6 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; [Trait(Traits.Feature, Traits.Features.Snippets)] public abstract class AbstractCSharpAutoPropertySnippetProviderTests : AbstractCSharpSnippetProviderTests { - protected virtual string AdditionalPropertyModifiers => string.Empty; - protected abstract string DefaultPropertyBlockText { get; } [Fact] @@ -145,18 +143,6 @@ public Program() """); } - [Theory] - [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) - { - await VerifyPropertyAsync($$""" - class Program - { - {{modifier}} $$ - } - """, $$"""{{AdditionalPropertyModifiers}}{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); - } - protected async Task VerifyPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyMarkup) { TestFileMarkupParser.GetPosition(markup, out var code, out var position); @@ -164,6 +150,6 @@ protected async Task VerifyPropertyAsync([StringSyntax(PredefinedEmbeddedLanguag await VerifySnippetAsync(markup, expectedCode); } - protected Task VerifyDefaultPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyName = "MyProperty") - => VerifyPropertyAsync(markup, $$"""public {{AdditionalPropertyModifiers}}{|0:int|} {|1:{{propertyName}}|} {{DefaultPropertyBlockText}}"""); + protected virtual Task VerifyDefaultPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyName = "MyProperty") + => VerifyPropertyAsync(markup, $$"""public {|0:int|} {|1:{{propertyName}}|} {{DefaultPropertyBlockText}}"""); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs index 903f9d6a2b942..3b095929102d5 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; +using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; @@ -65,4 +66,16 @@ interface MyInterface } """); } + + [Theory] + [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] + public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifyPropertyAsync($$""" + class Program + { + {{modifier}} $$ + } + """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + } } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs index d4413d32e9bc5..088f605c8705c 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; +using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; @@ -66,4 +67,16 @@ interface MyInterface } """, "public {|0:int|} {|1:MyProperty|} { get; }"); } + + [Theory] + [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] + public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifyPropertyAsync($$""" + class Program + { + {{modifier}} $$ + } + """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + } } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs index 880dcf3a70927..970ed48c84033 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading.Tasks; +using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; @@ -59,4 +60,16 @@ interface MyInterface } """); } + + [Theory] + [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] + public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifyPropertyAsync($$""" + class Program + { + {{modifier}} $$ + } + """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + } } diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs index f564711946cf3..9a6e038bf7744 100644 --- a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -2,7 +2,10 @@ // 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.Threading.Tasks; +using Roslyn.Test.Utilities; +using Xunit; namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Snippets; @@ -10,10 +13,9 @@ public sealed class CSharpProprSnippetProviderTests : AbstractCSharpAutoProperty { protected override string SnippetIdentifier => "propr"; - protected override string AdditionalPropertyModifiers => "required "; - protected override string DefaultPropertyBlockText => "{ get; set; }"; + [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest() { // Ensure we don't generate redundant `set` accessor when executed in readonly struct @@ -25,6 +27,7 @@ readonly struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } + [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration() { // Ensure we don't generate redundant `set` accessor when executed in readonly struct @@ -40,6 +43,7 @@ readonly partial struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } + [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration_MissingPartialModifier() { // Even though there is no `partial` modifier on the first declaration @@ -58,6 +62,7 @@ readonly partial struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } + [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInInterfaceTest() { await VerifyDefaultPropertyAsync(""" @@ -67,4 +72,36 @@ interface MyInterface } """); } + + [Theory, WorkItem("https://github.com/dotnet/roslyn/issues/75128")] + [InlineData("public")] + [InlineData("internal")] + [InlineData("protected internal")] + public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifyPropertyAsync($$""" + class Program + { + {{modifier}} $$ + } + """, + $$"""required {|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + } + + [Theory, WorkItem("https://github.com/dotnet/roslyn/issues/75128")] + [InlineData("private")] + [InlineData("protected")] + [InlineData("private protected")] + public async Task DoNotInsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifySnippetIsAbsentAsync($$""" + class Program + { + {{modifier}} $$ + } + """); + } + + protected override Task VerifyDefaultPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyName = "MyProperty") + => VerifyPropertyAsync(markup, $$"""public required {|0:int|} {|1:{{propertyName}}|} {{DefaultPropertyBlockText}}"""); } From 960eb852211a6aa6664f321c616c1a91dbc1165e Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Wed, 2 Oct 2024 21:01:25 +1000 Subject: [PATCH 04/13] fixed spacing --- .../CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs | 2 +- .../CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs index 088f605c8705c..eef272be2309c 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs @@ -67,7 +67,7 @@ interface MyInterface } """, "public {|0:int|} {|1:MyProperty|} { get; }"); } - + [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) diff --git a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs index 970ed48c84033..9187527937bcd 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs @@ -60,7 +60,7 @@ interface MyInterface } """); } - + [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) From 2fc79135cccc8b622e9607bb7deb138e6d22565d Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sat, 5 Oct 2024 11:58:06 +1000 Subject: [PATCH 05/13] reverted localization --- src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 2 +- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index 1ed996476dfea..d7ac9cba50f70 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -4202,7 +4202,7 @@ Chcete pokračovat? required property - požadovaná vlastnost + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 3f25fd66960c3..8fa576b220e94 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -4202,7 +4202,7 @@ Möchten Sie fortfahren? required property - Erforderliche eigenschaft + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index dfad10de86233..15b6496ff6da7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - propiedad requerida + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 44fbe39dd62ed..3b368a513e415 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -4202,7 +4202,7 @@ Voulez-vous continuer ? required property - propriété requise + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index afa4a4903cc32..38e6c3f420425 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -4202,7 +4202,7 @@ Continuare? required property - proprietà richiesta + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index 07f0926fffedc..d802e2975fea9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - 必須プロパティ + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 0ae672fd24dc4..34f25690d2ff4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - 필수 속성 + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 5d0b00b3a7588..00072729b608e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -4202,7 +4202,7 @@ Czy chcesz kontynuować? required property - wymagana właściwość + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 0c0ba72a1f0f0..265ea4605b00b 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -4202,7 +4202,7 @@ Deseja continuar? required property - propriedade obrigatória + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 4ec8d647f65dd..27bb08f18ce3c 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - Обязательное свойство + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index b3692ff3158d7..1a9d275edb2ed 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -4202,7 +4202,7 @@ Devam etmek istiyor musunuz? required property - gerekli özellik + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 2fee92299a293..1de0656a463f7 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - 必需属性 + required property diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index fc81fd24b1b07..85fa99b0af3ab 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -4202,7 +4202,7 @@ Do you want to continue? required property - 必需屬性 + required property From e735e941855a2045b3a9b55950db872f94b5a6f6 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sat, 5 Oct 2024 12:01:00 +1000 Subject: [PATCH 06/13] moved snipped name to CSharpSnippetIdentifiers --- .../CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs | 2 +- .../CSharp/Portable/Snippets/CSharpSnippetIdentifiers.cs | 1 + src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index 57c684f515b7a..e20d40a782de0 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -22,7 +22,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Snippets; [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertySnippetProvider { - public override string Identifier => CommonSnippetIdentifiers.RequiredProperty; + public override string Identifier => CSharpSnippetIdentifiers.RequiredProperty; public override string Description => FeaturesResources.required_property; diff --git a/src/Features/CSharp/Portable/Snippets/CSharpSnippetIdentifiers.cs b/src/Features/CSharp/Portable/Snippets/CSharpSnippetIdentifiers.cs index f2c39f292e8d3..406a380e2ca8a 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpSnippetIdentifiers.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpSnippetIdentifiers.cs @@ -18,6 +18,7 @@ internal static class CSharpSnippetIdentifiers public const string ReversedFor = "forr"; public const string ForEach = "foreach"; public const string InitOnlyProperty = "propi"; + public const string RequiredProperty = "propr"; public const string If = "if"; public const string Interface = "interface"; public const string Lock = "lock"; diff --git a/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs b/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs index 06a5ce383c0a9..1167581c3f826 100644 --- a/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs +++ b/src/Features/Core/Portable/Snippets/CommonSnippetIdentifiers.cs @@ -13,6 +13,5 @@ internal static class CommonSnippetIdentifiers public const string ConsoleWriteLine = "cw"; public const string Constructor = "ctor"; public const string Property = "prop"; - public const string RequiredProperty = "propr"; public const string GetOnlyProperty = "propg"; } From f60a8671f3ce2c0c3c12e2b47cd8c4fa4894eec6 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sat, 5 Oct 2024 12:26:41 +1000 Subject: [PATCH 07/13] addressed PR comments --- .../Portable/Snippets/CSharpProprSnippetProvider.cs | 12 ++++++------ ...AbstractCSharpAutoPropertySnippetProviderTests.cs | 10 ++++++++++ .../Snippets/CSharpPropSnippetProviderTests.cs | 10 +--------- .../Snippets/CSharpPropgSnippetProviderTests.cs | 10 +--------- .../Snippets/CSharpPropiSnippetProviderTests.cs | 10 +--------- .../Snippets/CSharpProprSnippetProviderTests.cs | 5 ++--- 6 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index e20d40a782de0..89b34145d2d3c 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -25,30 +25,30 @@ internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertyS public override string Identifier => CSharpSnippetIdentifiers.RequiredProperty; public override string Description => FeaturesResources.required_property; - + protected override bool IsValidSnippetLocationCore(SnippetContext context, CancellationToken cancellationToken) { if(!base.IsValidSnippetLocationCore(context, cancellationToken)) return false; - + var syntaxContext = (CSharpSyntaxContext)context.SyntaxContext; var precedingModifiers = syntaxContext.PrecedingModifiers; - + if (syntaxContext.PrecedingModifiers.IsEmpty()) return true; // "private" and "private protected" modifiers are NOT valid for required property if (precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.PrivateKeyword)) return false; - + // "protected internal" modifiers are valid for required property if(precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) return true; - + // "protected" and "private protected" modifiers are NOT valid for required property if(precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.ProtectedKeyword)) return false; - + return true; } diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index d4968e15539e6..7e6c76acac309 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -143,6 +143,16 @@ public Program() """); } + public virtual async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + { + await VerifyPropertyAsync($$""" + class Program + { + {{modifier}} $$ + } + """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + } + protected async Task VerifyPropertyAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup, string propertyMarkup) { TestFileMarkupParser.GetPosition(markup, out var code, out var position); diff --git a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs index 3b095929102d5..f97ec6181b25c 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs @@ -69,13 +69,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) - { - await VerifyPropertyAsync($$""" - class Program - { - {{modifier}} $$ - } - """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); - } + public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs index eef272be2309c..997eb917ef81e 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs @@ -70,13 +70,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) - { - await VerifyPropertyAsync($$""" - class Program - { - {{modifier}} $$ - } - """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); - } + public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs index 9187527937bcd..92df7ddb6750e 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs @@ -63,13 +63,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) - { - await VerifyPropertyAsync($$""" - class Program - { - {{modifier}} $$ - } - """, $$"""{|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); - } + public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs index 9a6e038bf7744..c2b9e19676635 100644 --- a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -77,15 +77,14 @@ interface MyInterface [InlineData("public")] [InlineData("internal")] [InlineData("protected internal")] - public async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + public override async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) { await VerifyPropertyAsync($$""" class Program { {{modifier}} $$ } - """, - $$"""required {|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); + """, $$"""required {|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); } [Theory, WorkItem("https://github.com/dotnet/roslyn/issues/75128")] From 031024891cd518af90f8e6d41bf140894b0eb62c Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sat, 5 Oct 2024 12:41:46 +1000 Subject: [PATCH 08/13] handled interface case --- .../Portable/Snippets/CSharpProprSnippetProvider.cs | 4 ++++ .../AbstractCSharpAutoPropertySnippetProviderTests.cs | 11 +++++++++++ .../Snippets/CSharpProprSnippetProviderTests.cs | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index 89b34145d2d3c..4b29d7719d37a 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -34,6 +34,10 @@ protected override bool IsValidSnippetLocationCore(SnippetContext context, Cance var syntaxContext = (CSharpSyntaxContext)context.SyntaxContext; var precedingModifiers = syntaxContext.PrecedingModifiers; + // The required modifier can't be applied to members of an interface + if (syntaxContext.ContainingTypeDeclaration is InterfaceDeclarationSyntax) + return false; + if (syntaxContext.PrecedingModifiers.IsEmpty()) return true; diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index 7e6c76acac309..d722a896f8d4a 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -67,6 +67,17 @@ record MyRecord """); } + [Fact] + public async Task InsertSnippetInRecordStructTest() + { + await VerifyDefaultPropertyAsync(""" + record struct MyRecordStruct + { + $$ + } + """); + } + [Fact] public async Task InsertSnippetInStructTest() { diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs index c2b9e19676635..46337d06ad205 100644 --- a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -65,7 +65,7 @@ readonly partial struct MyStruct [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInInterfaceTest() { - await VerifyDefaultPropertyAsync(""" + await VerifySnippetIsAbsentAsync(""" interface MyInterface { $$ From 4640ff998253ca51960479a3caedd8894904a848 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sat, 5 Oct 2024 15:50:31 +1000 Subject: [PATCH 09/13] fix formatting --- .../CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index 4b29d7719d37a..580f30e59ae80 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -28,7 +28,7 @@ internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertyS protected override bool IsValidSnippetLocationCore(SnippetContext context, CancellationToken cancellationToken) { - if(!base.IsValidSnippetLocationCore(context, cancellationToken)) + if (!base.IsValidSnippetLocationCore(context, cancellationToken)) return false; var syntaxContext = (CSharpSyntaxContext)context.SyntaxContext; @@ -46,11 +46,11 @@ protected override bool IsValidSnippetLocationCore(SnippetContext context, Cance return false; // "protected internal" modifiers are valid for required property - if(precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) + if (precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) return true; // "protected" and "private protected" modifiers are NOT valid for required property - if(precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.ProtectedKeyword)) + if (precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.ProtectedKeyword)) return false; return true; From 79b5e328260f3073f031cdd79221ef61b4af947b Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sun, 6 Oct 2024 04:36:35 +1000 Subject: [PATCH 10/13] fixed PR comments --- ...stractCSharpAutoPropertySnippetProvider.cs | 7 ++--- .../Snippets/CSharpProprSnippetProvider.cs | 15 +++-------- ...tCSharpAutoPropertySnippetProviderTests.cs | 26 +++++++------------ .../CSharpPropSnippetProviderTests.cs | 4 +-- .../CSharpPropgSnippetProviderTests.cs | 4 +-- .../CSharpPropiSnippetProviderTests.cs | 4 +-- .../CSharpProprSnippetProviderTests.cs | 6 ++--- 7 files changed, 24 insertions(+), 42 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs index 5ec434c90ec0e..71db65b2cab5a 100644 --- a/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/AbstractCSharpAutoPropertySnippetProvider.cs @@ -30,6 +30,8 @@ internal abstract class AbstractCSharpAutoPropertySnippetProvider : AbstractProp protected virtual AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator, CancellationToken cancellationToken) => (AccessorDeclarationSyntax)generator.SetAccessorDeclaration(); + protected virtual SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) => []; + protected override bool IsValidSnippetLocationCore(SnippetContext context, CancellationToken cancellationToken) { return context.SyntaxContext.SyntaxTree.IsMemberDeclarationContext(context.Position, (CSharpSyntaxContext)context.SyntaxContext, @@ -89,9 +91,4 @@ protected override ImmutableArray GetPlaceHolderLocationsLis var node = root.FindNode(TextSpan.FromBounds(position, position)); return node.GetAncestorOrThis(); } - - protected virtual SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) - { - return []; - } } diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index 580f30e59ae80..a88ca7e09a3a5 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -26,6 +26,8 @@ internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertyS public override string Description => FeaturesResources.required_property; + protected override SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) => [RequiredKeyword]; + protected override bool IsValidSnippetLocationCore(SnippetContext context, CancellationToken cancellationToken) { if (!base.IsValidSnippetLocationCore(context, cancellationToken)) @@ -41,16 +43,12 @@ protected override bool IsValidSnippetLocationCore(SnippetContext context, Cance if (syntaxContext.PrecedingModifiers.IsEmpty()) return true; - // "private" and "private protected" modifiers are NOT valid for required property - if (precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.PrivateKeyword)) - return false; - // "protected internal" modifiers are valid for required property if (precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) return true; - // "protected" and "private protected" modifiers are NOT valid for required property - if (precedingModifiers.Any(syntaxKind => syntaxKind == SyntaxKind.ProtectedKeyword)) + // "private", "private protected", "protected" and "private protected" modifiers are NOT valid for required property + if (precedingModifiers.Any(syntaxKind => syntaxKind is SyntaxKind.PrivateKeyword or SyntaxKind.ProtectedKeyword)) return false; return true; @@ -68,9 +66,4 @@ protected override bool IsValidSnippetLocationCore(SnippetContext context, Cance return base.GenerateSetAccessorDeclaration(syntaxContext, generator, cancellationToken); } - - protected override SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) - { - return [RequiredKeyword]; - } } diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index d722a896f8d4a..181f6980a64ac 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -56,22 +56,14 @@ class MyClass """); } - [Fact] - public async Task InsertSnippetInRecordTest() + [Theory] + [InlineData("record")] + [InlineData("record struct")] + [InlineData("record class")] + public async Task InsertSnippetInRecordTest(string text) { - await VerifyDefaultPropertyAsync(""" - record MyRecord - { - $$ - } - """); - } - - [Fact] - public async Task InsertSnippetInRecordStructTest() - { - await VerifyDefaultPropertyAsync(""" - record struct MyRecordStruct + await VerifyDefaultPropertyAsync($$""" + {{text}} MyRecord { $$ } @@ -101,7 +93,7 @@ struct MyStruct // This case might produce non-default results for different snippets (e.g. no `set` accessor in 'propg' snippet), // so it is tested separately for all of them [Fact] - public abstract Task InsertSnippetInInterfaceTest(); + public abstract Task VerifySnippetInInterfaceTest(); [Fact] public async Task InsertSnippetNamingTest() @@ -154,7 +146,7 @@ public Program() """); } - public virtual async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + public virtual async Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) { await VerifyPropertyAsync($$""" class Program diff --git a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs index f97ec6181b25c..09410a56fa2e1 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs @@ -57,7 +57,7 @@ readonly partial struct MyStruct """, "public {|0:int|} {|1:MyProperty|} { get; }"); } - public override async Task InsertSnippetInInterfaceTest() + public override async Task VerifySnippetInInterfaceTest() { await VerifyDefaultPropertyAsync(""" interface MyInterface @@ -69,5 +69,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs index 997eb917ef81e..6a84644153e91 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs @@ -57,7 +57,7 @@ readonly partial struct MyStruct """, "public {|0:int|} {|1:MyProperty|} { get; }"); } - public override async Task InsertSnippetInInterfaceTest() + public override async Task VerifySnippetInInterfaceTest() { // Ensure we don't generate redundant `set` accessor when executed in interface await VerifyPropertyAsync(""" @@ -70,5 +70,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs index 92df7ddb6750e..e992e7de837c9 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs @@ -51,7 +51,7 @@ readonly partial struct MyStruct """); } - public override async Task InsertSnippetInInterfaceTest() + public override async Task VerifySnippetInInterfaceTest() { await VerifyDefaultPropertyAsync(""" interface MyInterface @@ -63,5 +63,5 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs index 46337d06ad205..60b468598483e 100644 --- a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -63,7 +63,7 @@ readonly partial struct MyStruct } [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] - public override async Task InsertSnippetInInterfaceTest() + public override async Task VerifySnippetInInterfaceTest() { await VerifySnippetIsAbsentAsync(""" interface MyInterface @@ -77,7 +77,7 @@ interface MyInterface [InlineData("public")] [InlineData("internal")] [InlineData("protected internal")] - public override async Task InsertSnippetAfterAccessibilityModifierTest(string modifier) + public override async Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) { await VerifyPropertyAsync($$""" class Program @@ -91,7 +91,7 @@ class Program [InlineData("private")] [InlineData("protected")] [InlineData("private protected")] - public async Task DoNotInsertSnippetAfterAccessibilityModifierTest(string modifier) + public async Task NoSnippetAfterWrongAccessibilityModifierTest(string modifier) { await VerifySnippetIsAbsentAsync($$""" class Program From 5b6fa6e7917ff1bd198511e86e024357bab4ce25 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sun, 6 Oct 2024 06:03:12 +1000 Subject: [PATCH 11/13] fixed PR comments --- .../Portable/Snippets/CSharpProprSnippetProvider.cs | 3 --- .../AbstractCSharpAutoPropertySnippetProviderTests.cs | 4 ++-- .../Snippets/CSharpProprSnippetProviderTests.cs | 8 ++------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index a88ca7e09a3a5..d608d29f688f5 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -40,9 +40,6 @@ protected override bool IsValidSnippetLocationCore(SnippetContext context, Cance if (syntaxContext.ContainingTypeDeclaration is InterfaceDeclarationSyntax) return false; - if (syntaxContext.PrecedingModifiers.IsEmpty()) - return true; - // "protected internal" modifiers are valid for required property if (precedingModifiers.IsSupersetOf([SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword])) return true; diff --git a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs index 181f6980a64ac..81c5812d9be3a 100644 --- a/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/AbstractCSharpAutoPropertySnippetProviderTests.cs @@ -60,10 +60,10 @@ class MyClass [InlineData("record")] [InlineData("record struct")] [InlineData("record class")] - public async Task InsertSnippetInRecordTest(string text) + public async Task InsertSnippetInRecordTest(string recordType) { await VerifyDefaultPropertyAsync($$""" - {{text}} MyRecord + {{recordType}} MyRecord { $$ } diff --git a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs index 60b468598483e..5f75aef2b5a01 100644 --- a/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpProprSnippetProviderTests.cs @@ -15,7 +15,6 @@ public sealed class CSharpProprSnippetProviderTests : AbstractCSharpAutoProperty protected override string DefaultPropertyBlockText => "{ get; set; }"; - [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest() { // Ensure we don't generate redundant `set` accessor when executed in readonly struct @@ -27,7 +26,6 @@ readonly struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } - [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration() { // Ensure we don't generate redundant `set` accessor when executed in readonly struct @@ -43,7 +41,6 @@ readonly partial struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } - [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task InsertSnippetInReadonlyStructTest_ReadonlyModifierInOtherPartialDeclaration_MissingPartialModifier() { // Even though there is no `partial` modifier on the first declaration @@ -62,7 +59,6 @@ readonly partial struct MyStruct """, "public required {|0:int|} {|1:MyProperty|} { get; }"); } - [WorkItem("https://github.com/dotnet/roslyn/issues/75128")] public override async Task VerifySnippetInInterfaceTest() { await VerifySnippetIsAbsentAsync(""" @@ -73,7 +69,7 @@ interface MyInterface """); } - [Theory, WorkItem("https://github.com/dotnet/roslyn/issues/75128")] + [Theory] [InlineData("public")] [InlineData("internal")] [InlineData("protected internal")] @@ -87,7 +83,7 @@ class Program """, $$"""required {|0:int|} {|1:MyProperty|} {{DefaultPropertyBlockText}}"""); } - [Theory, WorkItem("https://github.com/dotnet/roslyn/issues/75128")] + [Theory] [InlineData("private")] [InlineData("protected")] [InlineData("private protected")] From 39df1b45d4c8083d5c6ae44f53b26c9c38c3e126 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Sun, 6 Oct 2024 07:02:22 +1000 Subject: [PATCH 12/13] fixed PR comments --- .../CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs | 3 ++- .../CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs | 3 ++- .../CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs index 09410a56fa2e1..5b13ab35d4a6e 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropSnippetProviderTests.cs @@ -69,5 +69,6 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) + => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs index 6a84644153e91..2f4a46a5ea84d 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropgSnippetProviderTests.cs @@ -70,5 +70,6 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) + => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } diff --git a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs index e992e7de837c9..38ab037b43245 100644 --- a/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs +++ b/src/Features/CSharpTest/Snippets/CSharpPropiSnippetProviderTests.cs @@ -63,5 +63,6 @@ interface MyInterface [Theory] [MemberData(nameof(CommonSnippetTestData.AllAccessibilityModifiers), MemberType = typeof(CommonSnippetTestData))] - public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); + public override Task InsertSnippetAfterAllowedAccessibilityModifierTest(string modifier) + => base.InsertSnippetAfterAllowedAccessibilityModifierTest(modifier); } From c28226f94ea61740c32aa892ef33ebedddd62a58 Mon Sep 17 00:00:00 2001 From: Victor Pogor Date: Mon, 7 Oct 2024 10:40:41 +1000 Subject: [PATCH 13/13] moved required prop key in CSharpFeaturesResources --- src/Features/CSharp/Portable/CSharpFeaturesResources.resx | 3 +++ .../CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs | 3 +-- .../CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf | 5 +++++ .../CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf | 5 +++++ src/Features/Core/Portable/FeaturesResources.resx | 3 --- src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.de.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.es.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.it.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf | 5 ----- src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf | 5 ----- 29 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx index e14e82032ac9c..9840f4ec58e31 100644 --- a/src/Features/CSharp/Portable/CSharpFeaturesResources.resx +++ b/src/Features/CSharp/Portable/CSharpFeaturesResources.resx @@ -619,4 +619,7 @@ do-while loop {Locked="do"}{Locked="while"} "do" and "while" are C# keywords and should not be localized. + + required property + \ No newline at end of file diff --git a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs index d608d29f688f5..d1444d0fa1984 100644 --- a/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs +++ b/src/Features/CSharp/Portable/Snippets/CSharpProprSnippetProvider.cs @@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Snippets; using Microsoft.CodeAnalysis.Snippets.SnippetProviders; -using Roslyn.Utilities; using static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTokens; namespace Microsoft.CodeAnalysis.CSharp.Snippets; @@ -24,7 +23,7 @@ internal sealed class CSharpProprSnippetProvider() : AbstractCSharpAutoPropertyS { public override string Identifier => CSharpSnippetIdentifiers.RequiredProperty; - public override string Description => FeaturesResources.required_property; + public override string Description => CSharpFeaturesResources.required_property; protected override SyntaxToken[] GetAdditionalPropertyModifiers(CSharpSyntaxContext? syntaxContext) => [RequiredKeyword]; diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf index 7c277d113addf..a52b85765ae30 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.cs.xlf @@ -432,6 +432,11 @@ struktura záznamu + + required property + required property + + reversed for loop obrácená smyčka typu for diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf index 43abdee07e7c8..1a1367d42d040 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.de.xlf @@ -432,6 +432,11 @@ Datensatzstruktur + + required property + required property + + reversed for loop reversed for-Schleife diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf index fb1506e889134..c93710402b6aa 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf @@ -432,6 +432,11 @@ registro de estructuras + + required property + required property + + reversed for loop bucle for invertido diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf index c3660c23351bb..343234c206710 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.fr.xlf @@ -432,6 +432,11 @@ struct d’enregistrement + + required property + required property + + reversed for loop boucle for inversée diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf index d781f9904657c..c80b27b78ea29 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.it.xlf @@ -432,6 +432,11 @@ struct di record + + required property + required property + + reversed for loop invertito for loop diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf index 261bbf1413967..f52983cb5b515 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ja.xlf @@ -432,6 +432,11 @@ レコード構造体 + + required property + required property + + reversed for loop 逆 for ループ diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf index 5bc2e5b7bcf2e..d9ecd34b88674 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ko.xlf @@ -432,6 +432,11 @@ 레코드 구조체 + + required property + required property + + reversed for loop for 루프 대해 반전 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf index af1a6a9a74558..e42d24a561225 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pl.xlf @@ -432,6 +432,11 @@ struktura rekordów + + required property + required property + + reversed for loop odwrócona pętla for diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf index 8a38cb15bb1ec..9a67ba4d06d54 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.pt-BR.xlf @@ -432,6 +432,11 @@ registrar struct + + required property + required property + + reversed for loop loop for invertido diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf index fba75ab606895..b22d9ae9aa674 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.ru.xlf @@ -432,6 +432,11 @@ структура записей + + required property + required property + + reversed for loop перевернутый for цикла diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf index ee5a5cf4b1dcb..dbbe9998b322c 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.tr.xlf @@ -432,6 +432,11 @@ kayıt yapısı + + required property + required property + + reversed for loop ters for döngüsü diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf index 241b9c403b1b2..5ce1d189d6f4c 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hans.xlf @@ -432,6 +432,11 @@ 记录结构 + + required property + required property + + reversed for loop 反转的 for 循环 diff --git a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf index 645b87cd0be55..bb5d3d9f4a30b 100644 --- a/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf +++ b/src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.zh-Hant.xlf @@ -432,6 +432,11 @@ 記錄結構 + + required property + required property + + reversed for loop 反轉 for 迴圈 diff --git a/src/Features/Core/Portable/FeaturesResources.resx b/src/Features/Core/Portable/FeaturesResources.resx index 2a19820c2b9ea..5cec87490ebac 100644 --- a/src/Features/Core/Portable/FeaturesResources.resx +++ b/src/Features/Core/Portable/FeaturesResources.resx @@ -3171,7 +3171,4 @@ Zero-width positive lookbehind assertions are typically used at the beginning of Symbol search - - required property - \ No newline at end of file diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf index d7ac9cba50f70..d9626f8e62387 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.cs.xlf @@ -4200,11 +4200,6 @@ Chcete pokračovat? přístupový objekt události - - required property - required property - - rfc1123 date/time datum a čas rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf index 8fa576b220e94..efa5ca40625b9 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.de.xlf @@ -4200,11 +4200,6 @@ Möchten Sie fortfahren? Ereignisaccessor - - required property - required property - - rfc1123 date/time RFC1123-Datum/Uhrzeit diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf index 15b6496ff6da7..e9402b2dd1524 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.es.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? descriptor de acceso de eventos - - required property - required property - - rfc1123 date/time fecha y hora de rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf index 3b368a513e415..15f3753c083b5 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.fr.xlf @@ -4200,11 +4200,6 @@ Voulez-vous continuer ? accesseur d'événement - - required property - required property - - rfc1123 date/time date/heure (rfc1123) diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf index 38e6c3f420425..c4f231f0df7c4 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.it.xlf @@ -4200,11 +4200,6 @@ Continuare? funzione di accesso eventi - - required property - required property - - rfc1123 date/time Data/ora RFC 1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf index d802e2975fea9..9d7a5edd64985 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ja.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? イベント アクセサー - - required property - required property - - rfc1123 date/time rfc1123 日付/時刻 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf index 34f25690d2ff4..1252d1891c69e 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ko.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? 이벤트 접근자 - - required property - required property - - rfc1123 date/time rfc1123 날짜/시간 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf index 00072729b608e..815c94748be90 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pl.xlf @@ -4200,11 +4200,6 @@ Czy chcesz kontynuować? metoda dostępu do zdarzeń - - required property - required property - - rfc1123 date/time data/godzina zgodna z rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf index 265ea4605b00b..4e98f15df7c74 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.pt-BR.xlf @@ -4200,11 +4200,6 @@ Deseja continuar? acessador de evento - - required property - required property - - rfc1123 date/time data/hora rfc1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf index 27bb08f18ce3c..f83c487da8209 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.ru.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? метод доступа к событию - - required property - required property - - rfc1123 date/time дата и время в формате RFC1123 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf index 1a9d275edb2ed..29932cae82242 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.tr.xlf @@ -4200,11 +4200,6 @@ Devam etmek istiyor musunuz? olay erişeni - - required property - required property - - rfc1123 date/time rfc1123 tarih/saat diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf index 1de0656a463f7..86a6fe05a210f 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hans.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? 事件访问器 - - required property - required property - - rfc1123 date/time rfc1123 日期/时间 diff --git a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf index 85fa99b0af3ab..95bdd64c6f401 100644 --- a/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf +++ b/src/Features/Core/Portable/xlf/FeaturesResources.zh-Hant.xlf @@ -4200,11 +4200,6 @@ Do you want to continue? 事件存取子 - - required property - required property - - rfc1123 date/time rfc1123 日期/時間