Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Mark replaced islands in messages #1778

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Scaffolding/VS.Web.CG.Core/MessageStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<value>Adding dependency '{0}' version '{1}'.</value>
</data>
<data name="CodeGeneratorInstanceCreationError" xml:space="preserve">
<value>There was an error creating the code generator instance: {0}\r\n{1}</value>
<value>There was an error creating the code generator instance: [{0}]\r\n{1}</value>
</data>
<data name="CodeGeneratorNotFound" xml:space="preserve">
<value>No code generators found with the name '{0}'</value>
Expand All @@ -139,22 +139,22 @@
<value>The provided file '{0}' does not exist. This method expects a fully qualified path of an existing file.</value>
</data>
<data name="FileNotFoundInFolders" xml:space="preserve">
<value>A file matching the name {0} was not found within any of the folders: {1}</value>
<value>A file matching the name '{0}' was not found within any of the folders: [{1}]</value>
</data>
<data name="MethodNotFound" xml:space="preserve">
<value>{0} method with a model parameter is not found in class: {1}</value>
<value>[{0}] method with a model parameter is not found in class: [{1}]</value>
</data>
<data name="ModelCreationFailed" xml:space="preserve">
<value>There was an error attempting to create an instace of model for GenerateCode method: {0}</value>
<value>There was an error attempting to create an instace of model for GenerateCode method: [{0}]</value>
</data>
<data name="MultipleCodeGeneratorsFound" xml:space="preserve">
<value>Multiple code generators found matching the name '{0}'</value>
</data>
<data name="MultipleFilesFound" xml:space="preserve">
<value>Multiple files with name {0} found within {1}</value>
<value>Multiple files with name '{0}' found within [{1}]</value>
</data>
<data name="MultipleMethodsFound" xml:space="preserve">
<value>Multiple {0} methods with a model parameter are found in class: {1}</value>
<value>Multiple [{0}] methods with a model parameter are found in class: [{1}]</value>
</data>
<data name="NullParamError" xml:space="preserve">
<value>Parameter '{0}' cannot be null or empty.</value>
Expand All @@ -163,15 +163,15 @@
<value>Could not find a part of the path '{0}'</value>
</data>
<data name="TemplateFileNotFound" xml:space="preserve">
<value>Template file {0} not found within search paths {1}</value>
<value>Template file '{0}' not found within search paths [{1}]</value>
</data>
<data name="TemplateProcessingError" xml:space="preserve">
<value>There was an error running the template {0}: {1}</value>
<value>There was an error running the template at '{0}': [{1}]</value>
</data>
<data name="UnableToRunRestore" xml:space="preserve">
<value>Unable to run restore.</value>
</data>
<data name="UnexpectedTypeLibraryForTemplates" xml:space="preserve">
<value>Unexpected type of library information for template folders</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ await codeGeneratorActionService.AddFileFromTemplateAsync("Dummy",
"Template",
new[] { "TemplateFolder1", "TemplateFolder2" },
null));
Assert.Equal("Template file Template not found within search paths TemplateFolder1;TemplateFolder2", ex.Message);
Assert.Equal("Template file 'Template' not found within search paths [TemplateFolder1;TemplateFolder2]", ex.Message);
}

[Fact]
Expand Down Expand Up @@ -60,7 +60,7 @@ await codeGeneratorActionService.AddFileFromTemplateAsync("Dummy",
templateName,
new[] { "TemplateFolder1", "TemplateFolder2" },
null));
Assert.Equal("There was an error running the template " + templatePath + ": Template Processing Failed:Error1", ex.Message);
Assert.Equal($"There was an error running the template at '{ templatePath }': [Template Processing Failed:Error1]", ex.Message);
}

[Fact]
Expand Down Expand Up @@ -98,4 +98,4 @@ await codeGeneratorActionService.AddFileFromTemplateAsync(outputPath,
Assert.Equal(generatedText, mockFileSystem.ReadAllText(outputPath));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void CodeGeneratorDescriptor_CodeGeneratorAction_Throws_When_No_GenerateC

//Act
var ex = Assert.Throws<InvalidOperationException>(() => descriptor.CodeGeneratorAction);
Assert.Equal("GenerateCode method with a model parameter is not found in class: " +
"Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+CodeGeneratorWithGenerateCodeNoParameters",
Assert.Equal("[GenerateCode] method with a model parameter is not found in class: " +
"[Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+CodeGeneratorWithGenerateCodeNoParameters]",
ex.Message);
}

Expand All @@ -67,8 +67,8 @@ public void CodeGeneratorDescriptor_CodeGeneratorAction_Throws_When_Multiple_Gen

//Act
var ex = Assert.Throws<InvalidOperationException>(() => descriptor.CodeGeneratorAction);
Assert.Equal("Multiple GenerateCode methods with a model parameter are found in class: " +
"Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+ClassWithMultipleGenerateCodeMethods",
Assert.Equal("Multiple [GenerateCode] methods with a model parameter are found in class: " +
"[Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+ClassWithMultipleGenerateCodeMethods]",
ex.Message);
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public void CodeGeneratorDescriptor_CodeGeneratorInstance_Throws_When_Not_Able_T
//Act & Assert
var ex = Assert.Throws<InvalidOperationException>(() => descriptor.CodeGeneratorInstance);
Assert.StartsWith("There was an error creating the code generator instance: " +
"Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+CodeGeneratorWithDependencies", ex.Message);
"[Microsoft.VisualStudio.Web.CodeGeneration.Core.Test.CodeGeneratorDescriptorTests+CodeGeneratorWithDependencies]", ex.Message);
}

[Alias("MyAlias")]
Expand Down Expand Up @@ -166,4 +166,4 @@ public CodeGeneratorWithDependencies(IServiceProvider serviceProvider)
public IServiceProvider ServiceProvider { get; private set; }
}
}
}
}
8 changes: 4 additions & 4 deletions test/Scaffolding/VS.Web.CG.Core.Test/FilesLocatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void FilesLocator_Throws_When_Multiple_Matches_In_OneSearchPath()
FilesLocator locator = new FilesLocator(fs);

var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One" }));
Assert.Equal(@"Multiple files with name template.cshtml found within C:\One", ex.Message);
Assert.Equal(@"Multiple files with name 'template.cshtml' found within [C:\One]", ex.Message);
}

[Fact]
Expand All @@ -52,7 +52,7 @@ public void FilesLocator_Throws_When_No_Matches_In_SearchPaths()
FilesLocator locator = new FilesLocator(fs);

var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", folders));
Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message);
Assert.Equal(@"A file matching the name 'template.cshtml' was not found within any of the folders: [C:\One;C:\Two]", ex.Message);
}

[Fact]
Expand All @@ -61,7 +61,7 @@ public void FilesLocator_Throws_When_No_SearchPaths_Does_Not_Exist()
FilesLocator locator = new FilesLocator(new MockFileSystem());

var ex = Assert.Throws<InvalidOperationException>(() => locator.GetFilePath("template.cshtml", new[] { @"C:\One", @"C:\Two" }));
Assert.Equal(@"A file matching the name template.cshtml was not found within any of the folders: C:\One;C:\Two", ex.Message);
Assert.Equal(@"A file matching the name 'template.cshtml' was not found within any of the folders: [C:\One;C:\Two]", ex.Message);
}
}
}
}