diff --git a/src/EditorFeatures/CSharpTest/ChangeSignature/AddParameterTests.Delegates.cs b/src/EditorFeatures/CSharpTest/ChangeSignature/AddParameterTests.Delegates.cs index 1b11bc5e8a32bdf6974b635e84c5869b43d13209..9c97cb90af3f2b6499a5af7a488f60fc6b1d8b7b 100644 --- a/src/EditorFeatures/CSharpTest/ChangeSignature/AddParameterTests.Delegates.cs +++ b/src/EditorFeatures/CSharpTest/ChangeSignature/AddParameterTests.Delegates.cs @@ -845,6 +845,53 @@ void B() C2.D d = new C2.D(M); d(12345); } +}"; + await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode); + } + + [WpfFact, Trait(Traits.Feature, Traits.Features.ChangeSignature)] + public async Task TestAddParameter_Delegates_Relaxation_ParameterlessFunctionToFunction() + { + var markup = @" +class C0 +{ + delegate int $$MyFunc(int x, string y, bool z); + + class C + { + public void M() + { + MyFunc f = Test(); + } + + private MyFunc Test() + { + return null; + } + } +}"; + var updatedSignature = new[] { + new AddedParameterOrExistingIndex(2), + new AddedParameterOrExistingIndex(new AddedParameter("int", "newIntegerParameter", "12345")), + new AddedParameterOrExistingIndex(1) + }; + var expectedUpdatedCode = @" +class C0 +{ + delegate int MyFunc(bool z, int newIntegerParameter, string y); + + class C + { + public void M() + { + MyFunc f = Test(); + } + + private MyFunc Test() + { + return null; + } + } }"; await TestChangeSignatureViaCommandAsync(LanguageNames.CSharp, markup, updatedSignature: updatedSignature, expectedUpdatedInvocationDocumentCode: expectedUpdatedCode); } diff --git a/src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb b/src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb index f73ba06aa77582d5ebba3e5658cae9bcb639250e..ca6428b268f721bead0bc22ab1c9b7863da7f550 100644 --- a/src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb +++ b/src/Features/VisualBasic/Portable/ChangeSignature/VisualBasicChangeSignatureService.vb @@ -432,11 +432,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature End Function Private Function PermuteDeclaration(Of T As SyntaxNode)( - list As SeparatedSyntaxList(Of T), + parameterList As SeparatedSyntaxList(Of T), updatedSignature As SignatureChange, createNewParameterMethod As Func(Of AddedParameter, T)) As SeparatedSyntaxList(Of T) Dim originalParameterSymbols = updatedSignature.OriginalConfiguration.ToListOfParameters().Select(Function(p) p.Symbol).ToArray() Dim reorderedParameters = updatedSignature.UpdatedConfiguration.ToListOfParameters() + Dim numSeparatorsToSkip = originalParameterSymbols.Length - reorderedParameters.Count + + ' The parameter list could be empty if dealing with delegates. + If parameterList.IsEmpty() Then + Return SyntaxFactory.SeparatedList(parameterList, GetSeparators(parameterList, numSeparatorsToSkip)) + End If + Dim numAddedParameters = 0 Dim newParameters = New List(Of T) @@ -444,18 +451,17 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ChangeSignature Dim existingParam = TryCast(newParam, ExistingParameter) If existingParam IsNot Nothing Then Dim pos = originalParameterSymbols.IndexOf(existingParam.Symbol) - Dim param = list(pos) + Dim param = parameterList(pos) newParameters.Add(param) Else ' Added parameter - numAddedParameters = numAddedParameters + 1 + numAddedParameters += 1 Dim newParameter = createNewParameterMethod(DirectCast(newParam, AddedParameter)) newParameters.Add(newParameter) End If Next - Dim numSeparatorsToSkip = originalParameterSymbols.Length - reorderedParameters.Count - Return SyntaxFactory.SeparatedList(newParameters, GetSeparators(list, numSeparatorsToSkip)) + Return SyntaxFactory.SeparatedList(newParameters, GetSeparators(parameterList, numSeparatorsToSkip)) End Function Private Shared Function CreateNewArgumentSyntax(addedParameter As AddedParameter) As ArgumentSyntax diff --git a/src/VisualStudio/CSharp/Impl/ChangeSignature/CSharpChangeSignatureLanguageService.cs b/src/VisualStudio/CSharp/Impl/ChangeSignature/CSharpChangeSignatureLanguageService.cs index 3d03705a40bd2d38085403a1f6b229461cc95e0c..669b0bedcad08b1cfdc01c39d8c8c93a0f1478d7 100644 --- a/src/VisualStudio/CSharp/Impl/ChangeSignature/CSharpChangeSignatureLanguageService.cs +++ b/src/VisualStudio/CSharp/Impl/ChangeSignature/CSharpChangeSignatureLanguageService.cs @@ -3,6 +3,8 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature; using Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls; @@ -14,9 +16,9 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.ChangeSignature { [ExportLanguageService(typeof(IChangeSignatureLanguageService), LanguageNames.CSharp), Shared] - internal class CSharpChangeSignatureLanguageService : ChangeSignatureLanguageService, IChangeSignatureLanguageService + internal class CSharpChangeSignatureLanguageService : ChangeSignatureLanguageService { - public async Task CreateViewModelsAsync( + public override async Task CreateViewModelsAsync( string[] rolesCollectionType, string[] rolesCollectionName, int insertPosition, @@ -42,11 +44,13 @@ ITrackingSpan[] CreateTrackingSpans(IProjectionSnapshot snapshot) } } - public void GeneratePreviewGrammar(AddedParameterViewModel addedParameterViewModel, List displayParts) + public override void GeneratePreviewGrammar(AddedParameterViewModel addedParameterViewModel, List displayParts) { displayParts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, addedParameterViewModel.Type)); displayParts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.Space, null, " ")); displayParts.Add(new SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, null, addedParameterViewModel.Parameter)); ; } + + public override bool IsTypeNameValid(string typeName) => !SyntaxFactory.ParseTypeName(typeName).ContainsDiagnostics; } } diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AbstractChangeSignatureLanguageService.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AbstractChangeSignatureLanguageService.cs index 9f145770db09f64cb09819bdbd7770d0aaa8ea9a..8a4782aae1279c73bc6e8d08d4b3e8d018d8f12b 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AbstractChangeSignatureLanguageService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AbstractChangeSignatureLanguageService.cs @@ -2,6 +2,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Projection; @@ -22,6 +23,7 @@ internal abstract class AbstractChangeSignatureLanguageService : IChangeSignatur CancellationToken cancellationToken); public abstract void GeneratePreviewGrammar(ChangeSignatureDialogViewModel.AddedParameterViewModel addedParameterViewModel, List displayParts); public abstract IContentType GetContentType(IContentTypeRegistryService contentTypeRegistryService); + public abstract bool IsTypeNameValid(string typeName); protected ITrackingSpan[] CreateTrackingSpansHelper(IProjectionSnapshot snapshot, int contextPoint, int spaceBetweenTypeAndName) { diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs index a68fb2bf9c8b3c6dc445956599df77246a8f25c7..2084e2510024e7d6b3f23a2060eb727215cf2597 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialog.xaml.cs @@ -5,6 +5,7 @@ using Microsoft.VisualStudio.PlatformUI; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Notification; namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature @@ -17,6 +18,7 @@ internal partial class AddParameterDialog : DialogWindow public readonly AddParameterDialogViewModel ViewModel; private readonly IntellisenseTextBoxViewModel _typeIntellisenseTextBoxView; private readonly IntellisenseTextBoxViewModel _nameIntellisenseTextBoxView; + private readonly Document _document; public string OK { get { return ServicesVSResources.OK; } } public string Cancel { get { return ServicesVSResources.Cancel; } } @@ -32,13 +34,15 @@ internal partial class AddParameterDialog : DialogWindow public AddParameterDialog( IntellisenseTextBoxViewModel typeIntellisenseTextBoxViewModel, IntellisenseTextBoxViewModel nameIntellisenseTextBoxViewModel, - INotificationService notificationService) + INotificationService notificationService, + Document document) { // The current implementation supports Add only. // The dialog should be initialized the other way if called for Edit. ViewModel = new AddParameterDialogViewModel(notificationService); _typeIntellisenseTextBoxView = typeIntellisenseTextBoxViewModel; _nameIntellisenseTextBoxView = nameIntellisenseTextBoxViewModel; + _document = document; this.Loaded += AddParameterDialog_Loaded; DataContext = ViewModel; @@ -61,7 +65,7 @@ private void OK_Click(object sender, RoutedEventArgs e) ViewModel.TypeName = ((IntellisenseTextBox)TypeContentControl.Content).Text; ViewModel.ParameterName = ((IntellisenseTextBox)NameContentControl.Content).Text; - if (ViewModel.TrySubmit()) + if (ViewModel.TrySubmit(_document)) { DialogResult = true; } @@ -94,9 +98,11 @@ private void TypeNameContentControl_PreviewKeyDown(object sender, KeyEventArgs e { // Do nothing. This case is handled in parent control KeyDown events. } - else if (typeNameTextBox.ContainerName.Equals("NameContentControl") && e.Key == Key.Space) + else if (e.Key == Key.Space && + (typeNameTextBox.ContainerName.Equals("NameContentControl") || + (typeNameTextBox.ContainerName.Equals("TypeContentControl") && _document.Project.Language.Equals(LanguageNames.CSharp)))) { - // Do nothing. We disallow spaces in the name field for both C# and VB. + // Do nothing. We disallow spaces in the name field for both C# and VB, and in the type field for C#. e.Handled = true; } else diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs index 08583fef5dead2d87b51bb4d7fddff38af90611f..f18652f361948147f41d2054c651bab8db35201b 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/AddParameterDialogViewModel.cs @@ -1,6 +1,9 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Notification; +using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.VisualStudio.LanguageServices.Implementation.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature @@ -20,11 +23,23 @@ public AddParameterDialogViewModel(INotificationService notificationService) public string TypeName { get; set; } - internal bool TrySubmit() + internal bool TrySubmit(Document document) { if (string.IsNullOrEmpty(ParameterName) || string.IsNullOrEmpty(TypeName)) { - SendFailureNotification("A type and name must be provided."); + SendFailureNotification(ServicesVSResources.A_type_and_name_must_be_provided); + return false; + } + + if (!IsParameterTypeValid(TypeName, document)) + { + SendFailureNotification(ServicesVSResources.Parameter_type_contains_invalid_characters); + return false; + } + + if (!IsParameterNameValid(ParameterName, document)) + { + SendFailureNotification(ServicesVSResources.Parameter_name_contains_invalid_characters); return false; } @@ -35,5 +50,17 @@ private void SendFailureNotification(string message) { _notificationService.SendNotification(message, severity: NotificationSeverity.Information); } + + private bool IsParameterTypeValid(string typeName, Document document) + { + var languageService = document.GetLanguageService(); + return languageService.IsTypeNameValid(typeName); + } + + private bool IsParameterNameValid(string identifierName, Document document) + { + var languageService = document.GetLanguageService(); + return languageService.IsValidIdentifier(identifierName); + } } } diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureLanguageService.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureLanguageService.cs index f305108667787351a99e9f0253ff4b32d70dd0b9..b02b919a7886dde28f3a0a95cc080d12fd533633 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureLanguageService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/ChangeSignatureLanguageService.cs @@ -1,10 +1,20 @@ -using Microsoft.VisualStudio.Text; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls; +using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Projection; +using Microsoft.VisualStudio.Utilities; namespace Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature { - internal class ChangeSignatureLanguageService + internal abstract class ChangeSignatureLanguageService : IChangeSignatureLanguageService { + public abstract Task CreateViewModelsAsync(string[] rolesCollectionType, string[] rolesCollectionName, int insertPosition, Document document, string documentText, IContentType contentType, IntellisenseTextBoxViewModelFactory intellisenseTextBoxViewModelFactory, CancellationToken cancellationToken); + public abstract void GeneratePreviewGrammar(ChangeSignatureDialogViewModel.AddedParameterViewModel addedParameterViewModel, List displayParts); + public abstract bool IsTypeNameValid(string typeName); + protected ITrackingSpan[] CreateTrackingSpansHelper(IProjectionSnapshot snapshot, int contextPoint, int spaceBetweenTypeAndName) { // Get the previous span/text. diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/IChangeSignatureLanguageService.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/IChangeSignatureLanguageService.cs index 1b8641657502c9b4a5e43fe2c082cfd4f32c1e1a..3428dd9a76948a4dc4c2dc9406882703d91dbccc 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/IChangeSignatureLanguageService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/IChangeSignatureLanguageService.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Host; using Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls; using Microsoft.VisualStudio.Utilities; @@ -24,5 +25,7 @@ internal interface IChangeSignatureLanguageService : ILanguageService CancellationToken cancellationToken); void GeneratePreviewGrammar(AddedParameterViewModel addedParameterViewModel, List displayParts); + + bool IsTypeNameValid(string typeName); } } diff --git a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs index 4b21b21be535f8c9bf5340e9acf8ba23f7fd2c31..f6a0350faeb3cfa03c44a6196ea0c6568e949181 100644 --- a/src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs +++ b/src/VisualStudio/Core/Def/Implementation/ChangeSignature/VisualStudioChangeSignatureOptionsService.cs @@ -115,7 +115,7 @@ public AddedParameterResult GetAddedParameter(Document document, int insertPosit _intellisenseTextBoxViewModelFactory, cancellationToken).ConfigureAwait(false); - return new AddParameterDialog(viewModels[0], viewModels[1], document.Project.Solution.Workspace.Services.GetService()); + return new AddParameterDialog(viewModels[0], viewModels[1], document.Project.Solution.Workspace.Services.GetService(), document); } } } diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs index 804b2db21990dd9eea4e23a5e1589b5c057c3944..61639eebd8cd22eb5cd9814a00fb87cd37d49774 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs +++ b/src/VisualStudio/Core/Def/ServicesVSResources.Designer.cs @@ -144,6 +144,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to A type and name must be provided.. + /// + internal static string A_type_and_name_must_be_provided { + get { + return ResourceManager.GetString("A_type_and_name_must_be_provided", resourceCulture); + } + } + /// /// Looks up a localized string similar to _Access:. /// @@ -2307,6 +2316,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to Parameter name contains invalid character(s).. + /// + internal static string Parameter_name_contains_invalid_characters { + get { + return ResourceManager.GetString("Parameter_name_contains_invalid_characters", resourceCulture); + } + } + /// /// Looks up a localized string similar to Parameter preferences:. /// @@ -2316,6 +2334,15 @@ internal class ServicesVSResources { } } + /// + /// Looks up a localized string similar to Parameter type contains invalid character(s).. + /// + internal static string Parameter_type_contains_invalid_characters { + get { + return ResourceManager.GetString("Parameter_type_contains_invalid_characters", resourceCulture); + } + } + /// /// Looks up a localized string similar to Parameters:. /// diff --git a/src/VisualStudio/Core/Def/ServicesVSResources.resx b/src/VisualStudio/Core/Def/ServicesVSResources.resx index e8afdc5963e01ee151191d4e39e088d005c7864e..34fd7b1e0f9a5c5065b0350433f142af63aa1a9a 100644 --- a/src/VisualStudio/Core/Def/ServicesVSResources.resx +++ b/src/VisualStudio/Core/Def/ServicesVSResources.resx @@ -1064,9 +1064,15 @@ I agree to all of the foregoing: Avoid unused value assignments + + Parameter name contains invalid character(s). + Parameter preferences: + + Parameter type contains invalid character(s). + Non-public methods @@ -1178,6 +1184,9 @@ I agree to all of the foregoing: A new namespace will be created + + A type and name must be provided. + Rename {0} to {1} diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf index 6c18de0640052c5ed2d7253cb7da85b2a048710a..84313a87d2a3b6c2cdda82e323478bcbcbbd7098 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.cs.xlf @@ -12,6 +12,11 @@ Vytvoří se nový obor názvů. + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Předvolby parametrů: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Předvolby závorek: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf index a1e9bde6bd4cc2f0b221e8e5f46fd7d5a2d75199..eb621b03000b840c21bb8bcef8cc10bc1d228183 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.de.xlf @@ -12,6 +12,11 @@ Ein neuer Namespace wird erstellt. + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Parametereinstellungen: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Voreinstellungen für Klammern: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf index af045ee04d9cdc90e0bd0bdaeafe674298fb23ff..66e8f7eb03cc2e924cbe940b8379cbb76e2882b2 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.es.xlf @@ -12,6 +12,11 @@ Se creará un espacio de nombres + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Preferencias de parámetros: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Preferencias de paréntesis: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf index 24e75c0ca20460da16559a7c9919ae17d72c86cb..8851944d2367fa10baebb0553455083322d7bad8 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.fr.xlf @@ -12,6 +12,11 @@ Un espace de noms va être créé + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Préférences relatives aux paramètres : + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Préférences relatives aux parenthèses : diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf index c1290b1089493dc4a4f1597b74d139122206b8d0..9666ce4ccdfe6c1a14fe35af249e0b40cf1d013b 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.it.xlf @@ -12,6 +12,11 @@ Verrà creato un nuovo spazio dei nomi + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Preferenze per parametri: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Preferenze per parentesi: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf index 88effc0cdc124484a1b0e362074c2af87b52a033..912862c56f35c4b4ec3ea2a55a20a45f318ee240 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ja.xlf @@ -12,6 +12,11 @@ 新しい名前空間が作成されます + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: パラメーターの優先順位: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: かっこの優先順位: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf index b7b569767b8a1fe707e82d5dc23c9a4e12c3f41d..748f7dce4c0fd6271a786ba5c241966557f4b687 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ko.xlf @@ -12,6 +12,11 @@ 새 네임스페이스가 만들어집니다. + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: 매개 변수 기본 설정: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: 괄호 기본 설정: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf index c8c9a47b363a5a2ed11f3d576f1667f63f5ccd64..a298d68970daade83dc927844938dcf6a48bd026 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pl.xlf @@ -12,6 +12,11 @@ Zostanie utworzona nowa przestrzeń nazw + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Preferencje dotyczące parametrów: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Preferencje dotyczące nawiasów: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf index 6ddfc81d95c5f67c95fba49de16f3f382b0cc8a4..437a97ca0fd9616812303b84a2994ebcfbfdcad9 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.pt-BR.xlf @@ -12,6 +12,11 @@ Um namespace será criado + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Preferências de parâmetro: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Preferências de parênteses: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf index b26945852fe12b82f32b3a2980e6a5bd4a9716a3..05a7736279e23f0870bdd37c3eb97dd4f2ed5884 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.ru.xlf @@ -12,6 +12,11 @@ Будет создано пространство имен + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Предпочтения для параметров: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Параметры круглых скобок: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf index 82c6e26ea95377fc6c7c72726144a17a31db33dc..3f48603b6b7e8a494a174aeb1b3100de35118f9f 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.tr.xlf @@ -12,6 +12,11 @@ Yeni bir ad alanı oluşturulacak + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: Parametre tercihleri: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: Parantez tercihleri: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf index e2ef5a4f7d8ab7e1cacca99b816be6243b019923..5097221ef357539f7c1a88fc3a4305d4cfdca326 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hans.xlf @@ -12,6 +12,11 @@ 将创建一个新的命名空间 + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: 参数首选项: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: 括号首选项: diff --git a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf index ffda1c78f5cb329fbca1bf62d929a35e52f6d6c9..3b29f5cb04a618ea751a767ded3354e066b88979 100644 --- a/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf +++ b/src/VisualStudio/Core/Def/xlf/ServicesVSResources.zh-Hant.xlf @@ -12,6 +12,11 @@ 將會建立新的命名空間 + + A type and name must be provided. + A type and name must be provided. + + _Add _Add @@ -437,11 +442,21 @@ Parameter name: + + Parameter name contains invalid character(s). + Parameter name contains invalid character(s). + + Parameter preferences: 參數喜好設定: + + Parameter type contains invalid character(s). + Parameter type contains invalid character(s). + + Parentheses preferences: 括號喜好設定: diff --git a/src/VisualStudio/VisualBasic/Impl/ChangeSignature/VisualBasicChangeSignatureLanguageService.vb b/src/VisualStudio/VisualBasic/Impl/ChangeSignature/VisualBasicChangeSignatureLanguageService.vb index 1e7cdcf799aa66b4b2e4237f624dbefb4979a80a..24387084b904abf67758c510fca40442bf3e2c0e 100644 --- a/src/VisualStudio/VisualBasic/Impl/ChangeSignature/VisualBasicChangeSignatureLanguageService.vb +++ b/src/VisualStudio/VisualBasic/Impl/ChangeSignature/VisualBasicChangeSignatureLanguageService.vb @@ -3,7 +3,9 @@ Imports System.Composition Imports System.Threading Imports Microsoft.CodeAnalysis +Imports Microsoft.CodeAnalysis.CSharp.Syntax Imports Microsoft.CodeAnalysis.Host.Mef +Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.VisualStudio.LanguageServices.Implementation.ChangeSignature Imports Microsoft.VisualStudio.LanguageServices.Implementation.IntellisenseControls Imports Microsoft.VisualStudio.Text @@ -14,13 +16,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ChangeSignature Friend Class VisualBasicChangeSignatureLanguageService Inherits ChangeSignatureLanguageService - Implements IChangeSignatureLanguageService - Public Async Function CreateViewModelsAsync(rolesCollectionType() As String, + Public Overrides Async Function CreateViewModelsAsync(rolesCollectionType() As String, rolesCollectionName() As String, insertPosition As Integer, document As Document, documentText As String, contentType As IContentType, intellisenseTextBoxViewModelFactory As IntellisenseTextBoxViewModelFactory, - cancellationToken As CancellationToken) As Task(Of IntellisenseTextBoxViewModel()) Implements IChangeSignatureLanguageService.CreateViewModelsAsync + cancellationToken As CancellationToken) As Task(Of IntellisenseTextBoxViewModel()) Dim rolesCollections = {rolesCollectionName, rolesCollectionType} ' We insert '[]' so that we're always able to generate the type even if the name field is empty. @@ -38,9 +39,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ChangeSignature cancellationToken).ConfigureAwait(False) End Function - Public Sub GeneratePreviewGrammar(addedParameterViewModel As ChangeSignatureDialogViewModel.AddedParameterViewModel, displayParts As List(Of SymbolDisplayPart)) Implements IChangeSignatureLanguageService.GeneratePreviewGrammar + Public Overrides Sub GeneratePreviewGrammar(addedParameterViewModel As ChangeSignatureDialogViewModel.AddedParameterViewModel, displayParts As List(Of SymbolDisplayPart)) displayParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.ParameterName, Nothing, addedParameterViewModel.Parameter)) displayParts.Add(New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, " As " + addedParameterViewModel.Type)) End Sub + + Public Overrides Function IsTypeNameValid(typeName As String) As Boolean + Return Not SyntaxFactory.ParseTypeName(typeName).ContainsDiagnostics + End Function End Class End Namespace