diff --git a/code/src/Wizard/Steps/ConsumerFeatures/NewConsumerFeature/NewConsumerFeatureViewModel.cs b/code/src/Wizard/Steps/ConsumerFeatures/NewConsumerFeature/NewConsumerFeatureViewModel.cs index 6e1fa6c9c..a6000d793 100644 --- a/code/src/Wizard/Steps/ConsumerFeatures/NewConsumerFeature/NewConsumerFeatureViewModel.cs +++ b/code/src/Wizard/Steps/ConsumerFeatures/NewConsumerFeature/NewConsumerFeatureViewModel.cs @@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature { SetProperty(ref _itemName, value); - var validationResult = Naming.Validate(_selectedNames, value); - - HandleValidation(validationResult); + Validate(value); OnPropertyChanged(nameof(OkCommand)); } @@ -126,6 +124,19 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures.NewConsumerFeature } } + private void Validate(string value) + { + //TODO: CREATE VALIDATION ERROR CLASS + if (!TemplateSelected.MultipleInstances) + { + throw new Exception(Strings.ValidationError_RenameNotAllowed); + } + + var validationResult = Naming.Validate(_selectedNames, value); + + HandleValidation(validationResult); + } + private bool IsValid() => _isValid; } } diff --git a/code/src/Wizard/Steps/ConsumerFeatures/Strings.Designer.cs b/code/src/Wizard/Steps/ConsumerFeatures/Strings.Designer.cs index fb32f475a..4345e0cc5 100644 --- a/code/src/Wizard/Steps/ConsumerFeatures/Strings.Designer.cs +++ b/code/src/Wizard/Steps/ConsumerFeatures/Strings.Designer.cs @@ -159,6 +159,15 @@ namespace Microsoft.Templates.Wizard.Steps.ConsumerFeatures { } } + /// + /// Looks up a localized string similar to Cannot set a custom name. + /// + public static string ValidationError_RenameNotAllowed { + get { + return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name is reserved. /// diff --git a/code/src/Wizard/Steps/ConsumerFeatures/Strings.resx b/code/src/Wizard/Steps/ConsumerFeatures/Strings.resx index 322301d03..00a799837 100644 --- a/code/src/Wizard/Steps/ConsumerFeatures/Strings.resx +++ b/code/src/Wizard/Steps/ConsumerFeatures/Strings.resx @@ -150,6 +150,9 @@ Name cannot be empty + + Cannot set a custom name + Name is reserved diff --git a/code/src/Wizard/Steps/DevFeatures/NewDevFeature/NewDevFeatureViewModel.cs b/code/src/Wizard/Steps/DevFeatures/NewDevFeature/NewDevFeatureViewModel.cs index 6388c92cd..86a177d2d 100644 --- a/code/src/Wizard/Steps/DevFeatures/NewDevFeature/NewDevFeatureViewModel.cs +++ b/code/src/Wizard/Steps/DevFeatures/NewDevFeature/NewDevFeatureViewModel.cs @@ -58,9 +58,7 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature { SetProperty(ref _itemName, value); - var validationResult = Naming.Validate(_selectedNames, value); - - HandleValidation(validationResult); + Validate(value); OnPropertyChanged(nameof(OkCommand)); } @@ -125,6 +123,19 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures.NewDevFeature } } + private void Validate(string value) + { + //TODO: CREATE VALIDATION ERROR CLASS + if (!TemplateSelected.MultipleInstances) + { + throw new Exception(Strings.ValidationError_RenameNotAllowed); + } + + var validationResult = Naming.Validate(_selectedNames, value); + + HandleValidation(validationResult); + } + private bool IsValid() => _isValid; } } diff --git a/code/src/Wizard/Steps/DevFeatures/Strings.Designer.cs b/code/src/Wizard/Steps/DevFeatures/Strings.Designer.cs index 90283b07e..e7de5c4f5 100644 --- a/code/src/Wizard/Steps/DevFeatures/Strings.Designer.cs +++ b/code/src/Wizard/Steps/DevFeatures/Strings.Designer.cs @@ -159,6 +159,15 @@ namespace Microsoft.Templates.Wizard.Steps.DevFeatures { } } + /// + /// Looks up a localized string similar to Cannot set a custom name. + /// + public static string ValidationError_RenameNotAllowed { + get { + return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name is reserved. /// diff --git a/code/src/Wizard/Steps/DevFeatures/Strings.resx b/code/src/Wizard/Steps/DevFeatures/Strings.resx index cf0af7e91..f8cf88d45 100644 --- a/code/src/Wizard/Steps/DevFeatures/Strings.resx +++ b/code/src/Wizard/Steps/DevFeatures/Strings.resx @@ -150,6 +150,9 @@ Name cannot be empty + + Cannot set a custom name + Name is reserved diff --git a/code/src/Wizard/Steps/Pages/NewPage/NewPageViewModel.cs b/code/src/Wizard/Steps/Pages/NewPage/NewPageViewModel.cs index fe572a95a..5a200ac90 100644 --- a/code/src/Wizard/Steps/Pages/NewPage/NewPageViewModel.cs +++ b/code/src/Wizard/Steps/Pages/NewPage/NewPageViewModel.cs @@ -56,15 +56,13 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage { SetProperty(ref _itemName, value); - var validationResult = Naming.Validate(_selectedNames, value); - - HandleValidation(validationResult); + Validate(value); OnPropertyChanged(nameof(OkCommand)); } } - //TODO: MAKE THIS METHOD TRULY ASYNC + //TODO: MAKE THIS METHOD TRULY ASYNC public async Task InitializeAsync() { Templates.Clear(); @@ -114,6 +112,19 @@ namespace Microsoft.Templates.Wizard.Steps.Pages.NewPage } } + private void Validate(string value) + { + //TODO: CREATE VALIDATION ERROR CLASS + if (!TemplateSelected.MultipleInstances) + { + throw new Exception(Strings.ValidationError_RenameNotAllowed); + } + + var validationResult = Naming.Validate(_selectedNames, value); + + HandleValidation(validationResult); + } + private bool IsValid() => _isValid; } } diff --git a/code/src/Wizard/Steps/Pages/Strings.Designer.cs b/code/src/Wizard/Steps/Pages/Strings.Designer.cs index 93808e4b1..e9b27287c 100644 --- a/code/src/Wizard/Steps/Pages/Strings.Designer.cs +++ b/code/src/Wizard/Steps/Pages/Strings.Designer.cs @@ -150,6 +150,15 @@ namespace Microsoft.Templates.Wizard.Steps.Pages { } } + /// + /// Looks up a localized string similar to Cannot set a custom name. + /// + public static string ValidationError_RenameNotAllowed { + get { + return ResourceManager.GetString("ValidationError_RenameNotAllowed", resourceCulture); + } + } + /// /// Looks up a localized string similar to Name is reserved. /// diff --git a/code/src/Wizard/Steps/Pages/Strings.resx b/code/src/Wizard/Steps/Pages/Strings.resx index d728a7a71..bb79545e4 100644 --- a/code/src/Wizard/Steps/Pages/Strings.resx +++ b/code/src/Wizard/Steps/Pages/Strings.resx @@ -147,6 +147,9 @@ Name cannot be empty + + Cannot set a custom name + Name is reserved