diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs
index a6ee8005c3..6f4f22626b 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/MvcViewDocumentClassifierPass.cs
@@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
ClassDeclarationIRNode @class,
MethodDeclarationIRNode method)
{
- var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FileName;
+ var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@class.Name = CSharpIdentifier.GetClassNameFromPath(filePath);
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs
index 7df5e9272c..db4cc83d9a 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/NamespaceDirective.cs
@@ -59,11 +59,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
return;
}
- if (TryComputeNamespace(codeDocument.Source.FileName, directive, out var computedNamespace))
+ if (TryComputeNamespace(codeDocument.Source.FilePath, directive, out var computedNamespace))
{
// Beautify the class name since we're using a hierarchy for namespaces.
var @class = visitor.FirstClass;
- var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FileName));
+ var prefix = CSharpIdentifier.SanitizeClassName(Path.GetFileNameWithoutExtension(codeDocument.Source.FilePath));
if (@class != null && irDocument.DocumentKind == RazorPageDocumentClassifierPass.RazorPageDocumentKind)
{
@class.Name = prefix + "_Page";
@@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
// This code does a best-effort attempt to compute a namespace 'suffix' - the path difference between
// where the @namespace directive appears and where the current document is on disk.
//
- // In the event that these two source either don't have filenames set or don't follow a coherent hierarchy,
+ // In the event that these two source either don't have FileNames set or don't follow a coherent hierarchy,
// we will just use the namespace verbatim.
internal static bool TryComputeNamespace(string source, DirectiveIRNode directive, out string @namespace)
{
@@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
var segments = source.Substring(directiveSource.Length).Split(Separators);
- // Skip the last segment because it's the filename.
+ // Skip the last segment because it's the FileName.
for (var i = 0; i < segments.Length - 1; i++)
{
builder.Append('.');
diff --git a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs
index 4a225dd060..0dd108a6a8 100644
--- a/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs
+++ b/src/Microsoft.AspNetCore.Mvc.Razor.Extensions/RazorPageDocumentClassifierPass.cs
@@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions
ClassDeclarationIRNode @class,
MethodDeclarationIRNode method)
{
- var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FileName;
+ var filePath = codeDocument.GetRelativePath() ?? codeDocument.Source.FilePath;
base.OnDocumentStructureCreated(codeDocument, @namespace, @class, method);
@class.BaseType = "global::Microsoft.AspNetCore.Mvc.RazorPages.Page";
diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs
index 9fc1be0207..3935322ae9 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/CSharpRenderingContext.cs
@@ -43,8 +43,8 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
return;
}
- if (SourceDocument.FileName != null &&
- !string.Equals(SourceDocument.FileName, node.Source.Value.FilePath, StringComparison.OrdinalIgnoreCase))
+ if (SourceDocument.FilePath != null &&
+ !string.Equals(SourceDocument.FilePath, node.Source.Value.FilePath, StringComparison.OrdinalIgnoreCase))
{
// We don't want to generate line mappings for imports.
return;
diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs
index 96b49c9ec9..d0660a5276 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/DesignTimeDirectiveTargetExtension.cs
@@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
var tokenKind = node.Descriptor.Kind;
if (!node.Source.HasValue ||
!string.Equals(
- context.SourceDocument?.FileName,
+ context.SourceDocument?.FilePath,
node.Source.Value.FilePath,
StringComparison.OrdinalIgnoreCase))
{
diff --git a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs
index cd86141a52..041f88636c 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/CodeGeneration/RuntimeBasicWriter.cs
@@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language.CodeGeneration
{
context.Writer
.Write("#pragma checksum \"")
- .Write(node.FileName)
+ .Write(node.FilePath)
.Write("\" \"")
.Write(node.Guid)
.Write("\" \"")
diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIRLoweringPhase.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIRLoweringPhase.cs
index b71f8d5ec8..7e370449de 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIRLoweringPhase.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorIRLoweringPhase.cs
@@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
var import = imports[j];
- importsVisitor.FileName = import.Source.FileName;
+ importsVisitor.FilePath = import.Source.FilePath;
importsVisitor.VisitBlock(import.Root);
}
}
@@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var tagHelperPrefix = tagHelperContext?.Prefix;
var visitor = new MainSourceVisitor(document, builder, namespaces, tagHelperPrefix)
{
- FileName = syntaxTree.Source.FileName,
+ FilePath = syntaxTree.Source.FilePath,
};
visitor.VisitBlock(syntaxTree.Root);
@@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_namespaces = namespaces;
}
- public string FileName { get; set; }
+ public string FilePath { get; set; }
public override void VisitImportSpan(AddImportChunkGenerator chunkGenerator, Span span)
{
@@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.Razor.Language
}
var span = new SourceSpan(
- node.Start.FilePath ?? FileName,
+ node.Start.FilePath ?? FilePath,
node.Start.AbsoluteIndex,
node.Start.LineIndex,
node.Start.CharacterIndex,
@@ -331,7 +331,7 @@ namespace Microsoft.AspNetCore.Razor.Language
if (location != SourceLocation.Undefined)
{
valueSpan = new SourceSpan(
- location.FilePath ?? FileName,
+ location.FilePath ?? FilePath,
location.AbsoluteIndex,
location.LineIndex,
location.CharacterIndex,
@@ -369,7 +369,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var contentLength = templateNode.Children.Sum(child => child.Source?.Length ?? 0);
templateNode.Source = new SourceSpan(
- sourceRangeStart.Value.FilePath ?? FileName,
+ sourceRangeStart.Value.FilePath ?? FilePath,
sourceRangeStart.Value.AbsoluteIndex,
sourceRangeStart.Value.LineIndex,
sourceRangeStart.Value.CharacterIndex,
@@ -412,7 +412,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var contentLength = expressionNode.Children.Sum(child => child.Source?.Length ?? 0);
expressionNode.Source = new SourceSpan(
- sourceRangeStart.Value.FilePath ?? FileName,
+ sourceRangeStart.Value.FilePath ?? FilePath,
sourceRangeStart.Value.AbsoluteIndex,
sourceRangeStart.Value.LineIndex,
sourceRangeStart.Value.CharacterIndex,
diff --git a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs
index 7c7709b36e..87749a73e6 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/DefaultRazorSourceLineCollection.cs
@@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// We have an exact match for the start of a line.
Debug.Assert(_lineStarts[index] == position);
- return new SourceLocation(_document.FileName, position, index, characterIndex: 0);
+ return new SourceLocation(_document.FilePath, position, index, characterIndex: 0);
}
@@ -59,12 +59,12 @@ namespace Microsoft.AspNetCore.Razor.Language
if (index == -1)
{
// There's no preceding line, so it's based on the start of the string
- return new SourceLocation(_document.FileName, position, 0, position);
+ return new SourceLocation(_document.FilePath, position, 0, position);
}
else
{
var characterIndex = position - _lineStarts[index];
- return new SourceLocation(_document.FileName, position, index, characterIndex);
+ return new SourceLocation(_document.FilePath, position, index, characterIndex);
}
}
diff --git a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ChecksumIRNode.cs b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ChecksumIRNode.cs
index f6d77a3573..92c2aba201 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ChecksumIRNode.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/Intermediate/ChecksumIRNode.cs
@@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
public string Bytes { get; set; }
- public string FileName { get; set; }
+ public string FilePath { get; set; }
public string Guid { get; set; }
@@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Intermediate
var node = new ChecksumIRNode()
{
- FileName = sourceDocument.FileName,
+ FilePath = sourceDocument.FilePath,
Guid = Sha1AlgorithmId
};
diff --git a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs
index 8c1a5b3a0b..20498f66b4 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/LargeTextSourceDocument.cs
@@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_chunkMaxLength = chunkMaxLength;
Encoding = encoding;
- FileName = fileName;
+ FilePath = fileName;
ReadChunks(reader, _chunkMaxLength, out _length, out _chunks);
_lines = new DefaultRazorSourceLineCollection(this);
@@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public override Encoding Encoding { get; }
- public override string FileName { get; }
+ public override string FilePath { get; }
public override int Length => _length;
diff --git a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs
index cfe4e6d04c..f12264df83 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/Legacy/ParserContext.cs
@@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy
var chars = new char[source.Length];
source.CopyTo(0, chars, 0, source.Length);
- Source = new SeekableTextReader(chars, source.FileName);
+ Source = new SeekableTextReader(chars, source.FilePath);
DesignTimeMode = options.DesignTime;
ParseOnlyLeadingDirectives = options.ParseOnlyLeadingDirectives;
Builder = new SyntaxTreeBuilder();
diff --git a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs
index 40d161c5ab..012f5c5868 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/RazorSourceDocument.cs
@@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Razor.Language
///
/// Path of the file the content was read from.
///
- public abstract string FileName { get; }
+ public abstract string FilePath { get; }
///
/// Gets a character at given position.
diff --git a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs
index 99efef4933..2c0fab062c 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/StreamSourceDocument.cs
@@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public override Encoding Encoding => _innerSourceDocument.Encoding;
- public override string FileName => _innerSourceDocument.FileName;
+ public override string FilePath => _innerSourceDocument.FilePath;
public override int Length => _innerSourceDocument.Length;
diff --git a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs
index e2c062eef5..5f528024c2 100644
--- a/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs
+++ b/src/Microsoft.AspNetCore.Razor.Language/StringSourceDocument.cs
@@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language
private readonly RazorSourceLineCollection _lines;
private byte[] _checksum;
- public StringSourceDocument(string content, Encoding encoding, string fileName)
+ public StringSourceDocument(string content, Encoding encoding, string filePath)
{
if (content == null)
{
@@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Razor.Language
_content = content;
Encoding = encoding;
- FileName = fileName;
+ FilePath = filePath;
_lines = new DefaultRazorSourceLineCollection(this);
}
@@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Razor.Language
public override Encoding Encoding { get; }
- public override string FileName { get; }
+ public override string FilePath { get; }
public override int Length => _content.Length;
diff --git a/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs b/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs
index 981d28f526..b3a165bcd4 100644
--- a/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs
+++ b/src/Microsoft.CodeAnalysis.Remote.Razor/RazorLanguageService.cs
@@ -49,7 +49,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
return Task.FromResult(directives ?? Enumerable.Empty());
}
- public Task GenerateDocumentAsync(Guid projectIdBytes, string projectDebugName, string filename, string text, CancellationToken cancellationToken = default(CancellationToken))
+ public Task GenerateDocumentAsync(Guid projectIdBytes, string projectDebugName, string filePath, string text, CancellationToken cancellationToken = default(CancellationToken))
{
var projectId = ProjectId.CreateFromSerialized(projectIdBytes, projectDebugName);
@@ -62,7 +62,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor
stream.Write(bytes, 0, bytes.Length);
stream.Seek(0L, SeekOrigin.Begin);
- source = RazorSourceDocument.ReadFrom(stream, filename, Encoding.UTF8);
+ source = RazorSourceDocument.ReadFrom(stream, filePath, Encoding.UTF8);
}
var code = RazorCodeDocument.Create(source);
diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineDocumentGenerator.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineDocumentGenerator.cs
index 86967c843d..308e67e585 100644
--- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineDocumentGenerator.cs
+++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorEngineDocumentGenerator.cs
@@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
[Export(typeof(IRazorEngineDocumentGenerator))]
internal class DefaultRazorEngineDocumentGenerator : IRazorEngineDocumentGenerator
{
- public async Task GenerateDocumentAsync(Workspace workspace, Project project, string filename, string text, CancellationToken cancellationToken = default(CancellationToken))
+ public async Task GenerateDocumentAsync(Workspace workspace, Project project, string filePath, string text, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
@@ -21,7 +21,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
using (var session = await client.CreateSessionAsync(project.Solution))
{
- var document = await session.InvokeAsync("GenerateDocumentAsync", new object[] { project.Id.Id, "Foo", filename, text }).ConfigureAwait(false);
+ var document = await session.InvokeAsync("GenerateDocumentAsync", new object[] { project.Id.Id, "Foo", filePath, text }).ConfigureAwait(false);
return document;
}
}
diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorSyntaxFactsService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorSyntaxFactsService.cs
index 59a52a071c..ddd0ab485f 100644
--- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorSyntaxFactsService.cs
+++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultRazorSyntaxFactsService.cs
@@ -31,13 +31,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
var span = spans[i];
result[i] = new ClassifiedSpan(
new SourceSpan(
- span.Start.FilePath ?? syntaxTree.Source.FileName,
+ span.Start.FilePath ?? syntaxTree.Source.FilePath,
span.Start.AbsoluteIndex,
span.Start.LineIndex,
span.Start.CharacterIndex,
span.Length),
new SourceSpan(
- span.Parent.Start.FilePath ?? syntaxTree.Source.FileName,
+ span.Parent.Start.FilePath ?? syntaxTree.Source.FilePath,
span.Parent.Start.AbsoluteIndex,
span.Parent.Start.LineIndex,
span.Parent.Start.CharacterIndex,
@@ -111,7 +111,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
{
results.Add(new TagHelperSpan(
new SourceSpan(
- tagHelperNode.Start.FilePath ?? syntaxTree.Source.FileName,
+ tagHelperNode.Start.FilePath ?? syntaxTree.Source.FilePath,
tagHelperNode.Start.AbsoluteIndex,
tagHelperNode.Start.LineIndex,
tagHelperNode.Start.CharacterIndex,
diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs
index 21e7a481eb..9c618e6702 100644
--- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs
+++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs
@@ -142,7 +142,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
throw new ArgumentNullException(nameof(textBuffer));
}
- // If there's no document we can't find the filename, or look for a matching hierarchy.
+ // If there's no document we can't find the FileName, or look for a matching hierarchy.
if (!_documentFactory.TryGetTextDocument(textBuffer, out var textDocument))
{
return null;
diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineDocumentGenerator.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineDocumentGenerator.cs
index 64cef94b0c..4b39c82bdb 100644
--- a/src/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineDocumentGenerator.cs
+++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/IRazorEngineDocumentGenerator.cs
@@ -10,7 +10,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor
{
internal interface IRazorEngineDocumentGenerator
{
- Task GenerateDocumentAsync(Workspace workspace, Project project, string filename, string text, CancellationToken cancellationToken = default(CancellationToken));
+ Task GenerateDocumentAsync(Workspace workspace, Project project, string filePath, string text, CancellationToken cancellationToken = default(CancellationToken));
}
}
#endif
\ No newline at end of file
diff --git a/src/RazorPageGenerator/Program.cs b/src/RazorPageGenerator/Program.cs
index 63b1ce2c0c..4235411c03 100644
--- a/src/RazorPageGenerator/Program.cs
+++ b/src/RazorPageGenerator/Program.cs
@@ -46,7 +46,7 @@ namespace RazorPageGenerator
.SetBaseType("Microsoft.Extensions.RazorViews.BaseView")
.ConfigureClass((document, @class) =>
{
- @class.Name = Path.GetFileNameWithoutExtension(document.Source.FileName);
+ @class.Name = Path.GetFileNameWithoutExtension(document.Source.FilePath);
@class.AccessModifier = "internal";
});
diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs
index e73038f062..c344a4f1f1 100644
--- a/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Mvc.Razor.Extensions.Test/IntegrationTests/CodeGenerationIntegrationTest.cs
@@ -614,7 +614,7 @@ public class AllTagHelper : {typeof(TagHelper).FullName}
var text = new string(buffer);
text = Regex.Replace(text, "(?)directiveDescriptors).ToList(), document, errorSink);
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs
index a446a3b680..7885f8edab 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/IntegrationTests/RazorTemplateEngineIntegrationTest.cs
@@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public void GenerateCodeWithDefaults()
{
// Arrange
- var filePath = Path.Combine(TestProjectRoot, $"{Filename}.cshtml");
+ var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml");
var content = File.ReadAllText(filePath);
- var projectItem = new TestRazorProjectItem($"{Filename}.cshtml", "")
+ var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "")
{
Content = content,
};
@@ -33,9 +33,9 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public void GenerateCodeWithBaseType()
{
// Arrange
- var filePath = Path.Combine(TestProjectRoot, $"{Filename}.cshtml");
+ var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml");
var content = File.ReadAllText(filePath);
- var projectItem = new TestRazorProjectItem($"{Filename}.cshtml", "")
+ var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "")
{
Content = content,
};
@@ -54,9 +54,9 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public void GenerateCodeWithConfigureClass()
{
// Arrange
- var filePath = Path.Combine(TestProjectRoot, $"{Filename}.cshtml");
+ var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml");
var content = File.ReadAllText(filePath);
- var projectItem = new TestRazorProjectItem($"{Filename}.cshtml", "")
+ var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "")
{
Content = content,
};
@@ -88,9 +88,9 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public void GenerateCodeWithSetNamespace()
{
// Arrange
- var filePath = Path.Combine(TestProjectRoot, $"{Filename}.cshtml");
+ var filePath = Path.Combine(TestProjectRoot, $"{FileName}.cshtml");
var content = File.ReadAllText(filePath);
- var projectItem = new TestRazorProjectItem($"{Filename}.cshtml", "")
+ var projectItem = new TestRazorProjectItem($"{FileName}.cshtml", "")
{
Content = content,
};
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs
index 3f4a7b89bd..bf61974524 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/LargeTextSourceDocumentTest.cs
@@ -99,17 +99,17 @@ namespace Microsoft.AspNetCore.Razor.Language.Test
[Theory]
[InlineData("test.cshtml")]
[InlineData(null)]
- public void Filename(string fileName)
+ public void FilePath(string filePath)
{
// Arrange
var stream = TestRazorSourceDocument.CreateStreamContent("abc");
var reader = new StreamReader(stream, true);
// Act
- var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, fileName);
+ var document = new LargeTextSourceDocument(reader, ChunkTestLength, Encoding.UTF8, filePath);
// Assert
- Assert.Equal(fileName, document.FileName);
+ Assert.Equal(filePath, document.FilePath);
}
[Fact]
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs
index bc2d714423..3001d53ec8 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorSourceDocumentTest.cs
@@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.IsType(document);
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Same(Encoding.UTF8, document.Encoding);
}
@@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.ReadFrom(content, "file.cshtml", Encoding.UTF32);
// Assert
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding);
}
@@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.ReadFrom(content, "file.cshtml", Encoding.UTF32);
// Assert
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Same(Encoding.UTF32, Assert.IsType(document).Encoding);
}
@@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.ReadFrom(projectItem);
// Assert
- Assert.Equal(projectItem.PhysicalPath, document.FileName);
+ Assert.Equal(projectItem.PhysicalPath, document.FilePath);
Assert.Equal(projectItem.Content, ReadContent(document));
}
@@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.ReadFrom(projectItem);
// Assert
- Assert.Equal(projectItem.Path, document.FileName);
+ Assert.Equal(projectItem.Path, document.FilePath);
Assert.Equal(projectItem.Content, ReadContent(document));
}
@@ -90,7 +90,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.Create(content, fileName);
// Assert
- Assert.Equal(fileName, document.FileName);
+ Assert.Equal(fileName, document.FilePath);
Assert.Equal(content, ReadContent(document));
Assert.Same(Encoding.UTF8, document.Encoding);
}
@@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Razor.Language
var document = RazorSourceDocument.Create(content, fileName, encoding);
// Assert
- Assert.Equal(fileName, document.FileName);
+ Assert.Equal(fileName, document.FilePath);
Assert.Equal(content, ReadContent(document));
Assert.Same(encoding, document.Encoding);
}
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs
index 442d0b4b25..1cb5cc62b2 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/RazorTemplateEngineTest.cs
@@ -55,7 +55,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
var import = Assert.Single(imports);
- Assert.Equal(projectItem.Path, import.FileName);
+ Assert.Equal(projectItem.Path, import.FilePath);
}
[Fact]
@@ -207,8 +207,8 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.Collection(codeDocument.Imports,
- import => Assert.Equal("/MyImport.cshtml", import.FileName),
- import => Assert.Equal("/Views/Home/MyImport.cshtml", import.FileName));
+ import => Assert.Equal("/MyImport.cshtml", import.FilePath),
+ import => Assert.Equal("/Views/Home/MyImport.cshtml", import.FilePath));
}
[Fact]
@@ -236,8 +236,8 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.Collection(codeDocument.Imports,
import => Assert.Same(defaultImport, import),
- import => Assert.Equal("/MyImport.cshtml", import.FileName),
- import => Assert.Equal("/Views/Home/MyImport.cshtml", import.FileName));
+ import => Assert.Equal("/MyImport.cshtml", import.FilePath),
+ import => Assert.Equal("/Views/Home/MyImport.cshtml", import.FilePath));
}
[Fact]
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs
index 6ab12c5924..84163a1c57 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StreamSourceDocumentTest.cs
@@ -70,7 +70,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.IsType(document);
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Equal(Encoding.UTF32, document.Encoding);
}
@@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
Assert.IsType(document);
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Equal(Encoding.UTF32, document.Encoding);
}
@@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Assert
var streamDocument = Assert.IsType(document);
Assert.IsType(streamDocument._innerSourceDocument);
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
Assert.Same(Encoding.UTF8, document.Encoding);
Assert.Equal(content, ReadContent(document));
}
diff --git a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs
index 980e9b2c9c..7fca1377e1 100644
--- a/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs
+++ b/test/Microsoft.AspNetCore.Razor.Language.Test/StringSourceDocumentTest.cs
@@ -60,7 +60,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var expectedContent = "Hello, World!";
var indexerBuffer = new char[expectedContent.Length];
- var document = new StringSourceDocument(expectedContent, Encoding.UTF8, fileName: "file.cshtml");
+ var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml");
// Act
for (var i = 0; i < document.Length; i++)
@@ -78,36 +78,36 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var expectedContent = "Hello, World!";
- var document = new StringSourceDocument(expectedContent, Encoding.UTF8, fileName: "file.cshtml");
+ var document = new StringSourceDocument(expectedContent, Encoding.UTF8, filePath: "file.cshtml");
// Act & Assert
Assert.Equal(expectedContent.Length, document.Length);
}
[Fact]
- public void Filename()
+ public void FilePath()
{
// Arrange
var content = "Hello, World!";
// Act
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: "file.cshtml");
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "file.cshtml");
// Assert
- Assert.Equal("file.cshtml", document.FileName);
+ Assert.Equal("file.cshtml", document.FilePath);
}
[Fact]
- public void Filename_Null()
+ public void FilePath_Null()
{
// Arrange
var content = "Hello, World!";
// Act
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Assert
- Assert.Null(document.FileName);
+ Assert.Null(document.FilePath);
}
[Fact]
@@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "Hello, World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
var expectedContent = "Hello";
var charBuffer = new char[expectedContent.Length];
@@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "Hello, World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
var expectedContent = "$Hello";
var charBuffer = new char[expectedContent.Length];
charBuffer[0] = '$';
@@ -150,7 +150,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "Hello, World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
var expectedContent = "World";
var charBuffer = new char[expectedContent.Length];
@@ -167,7 +167,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "Hi";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
var charBuffer = new char[2];
// Act
@@ -183,7 +183,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "Hi";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act & Assert
//
@@ -202,7 +202,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = string.Empty;
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.Count;
@@ -216,7 +216,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = string.Empty;
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLineLength(0);
@@ -230,7 +230,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "hello\n";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLineLength(0);
@@ -244,7 +244,7 @@ namespace Microsoft.AspNetCore.Razor.Language
{
// Arrange
var content = "hello\r\n";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLineLength(0);
@@ -263,7 +263,7 @@ namespace Microsoft.AspNetCore.Razor.Language
.Append("jumps over the lazy dog.")
.ToString();
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -278,7 +278,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -293,7 +293,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\rWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -309,7 +309,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\rBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -324,7 +324,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -339,7 +339,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\u0085World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -354,7 +354,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\u2028World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -369,7 +369,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\u2029World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = GetAllLineMappings(document);
@@ -384,7 +384,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello, World!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: "Hi.cshtml");
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: "Hi.cshtml");
// Act
var actual = document.Lines.GetLocation(1);
@@ -402,7 +402,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLocation(0);
@@ -418,7 +418,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLocation(5);
@@ -434,7 +434,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLocation(7);
@@ -450,7 +450,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLocation(11);
@@ -466,7 +466,7 @@ namespace Microsoft.AspNetCore.Razor.Language
// Arrange
var content = "Hello\nBig\r\nWorld!";
- var document = new StringSourceDocument(content, Encoding.UTF8, fileName: null);
+ var document = new StringSourceDocument(content, Encoding.UTF8, filePath: null);
// Act
var actual = document.Lines.GetLocation(16);
diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntegrationTestBase.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntegrationTestBase.cs
index 1da5fa9e47..80751b6ef1 100644
--- a/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntegrationTestBase.cs
+++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntegrationTestBase.cs
@@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
public abstract class IntegrationTestBase
{
#if !NET46
- private static readonly AsyncLocal _filename = new AsyncLocal();
+ private static readonly AsyncLocal _fileName = new AsyncLocal();
#endif
protected IntegrationTestBase()
@@ -40,53 +40,53 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
protected string TestProjectRoot { get; }
// Used by the test framework to set the 'base' name for test files.
- public static string Filename
+ public static string FileName
{
#if NET46
get
{
- var handle = (ObjectHandle)CallContext.LogicalGetData("IntegrationTestBase_Filename");
+ var handle = (ObjectHandle)CallContext.LogicalGetData("IntegrationTestBase_FileName");
return (string)handle.Unwrap();
}
set
{
- CallContext.LogicalSetData("IntegrationTestBase_Filename", new ObjectHandle(value));
+ CallContext.LogicalSetData("IntegrationTestBase_FileName", new ObjectHandle(value));
}
#elif NETCOREAPP2_0
- get { return _filename.Value; }
- set { _filename.Value = value; }
+ get { return _fileName.Value; }
+ set { _fileName.Value = value; }
#endif
}
protected virtual RazorCodeDocument CreateCodeDocument()
{
- if (Filename == null)
+ if (FileName == null)
{
- var message = $"{nameof(CreateCodeDocument)} should only be called from an integration test ({nameof(Filename)} is null).";
+ var message = $"{nameof(CreateCodeDocument)} should only be called from an integration test ({nameof(FileName)} is null).";
throw new InvalidOperationException(message);
}
- var suffixIndex = Filename.LastIndexOf("_");
- var normalizedFileName = suffixIndex == -1 ? Filename : Filename.Substring(0, suffixIndex);
- var sourceFilename = Path.ChangeExtension(normalizedFileName, ".cshtml");
- var testFile = TestFile.Create(sourceFilename, GetType().GetTypeInfo().Assembly);
+ var suffixIndex = FileName.LastIndexOf("_");
+ var normalizedFileName = suffixIndex == -1 ? FileName : FileName.Substring(0, suffixIndex);
+ var sourceFileName = Path.ChangeExtension(normalizedFileName, ".cshtml");
+ var testFile = TestFile.Create(sourceFileName, GetType().GetTypeInfo().Assembly);
if (!testFile.Exists())
{
- throw new XunitException($"The resource {sourceFilename} was not found.");
+ throw new XunitException($"The resource {sourceFileName} was not found.");
}
- var source = TestRazorSourceDocument.CreateResource(sourceFilename, GetType(), normalizeNewLines: true);
+ var source = TestRazorSourceDocument.CreateResource(sourceFileName, GetType(), normalizeNewLines: true);
var imports = new List();
while (true)
{
- var importsFilename = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml");
- if (!TestFile.Create(importsFilename, GetType().GetTypeInfo().Assembly).Exists())
+ var importsFileName = Path.ChangeExtension(normalizedFileName + "_Imports" + imports.Count.ToString(), ".cshtml");
+ if (!TestFile.Create(importsFileName, GetType().GetTypeInfo().Assembly).Exists())
{
break;
}
- imports.Add(TestRazorSourceDocument.CreateResource(importsFilename, GetType(), normalizeNewLines: true));
+ imports.Add(TestRazorSourceDocument.CreateResource(importsFileName, GetType(), normalizeNewLines: true));
}
OnCreatingCodeDocument(ref source, imports);
@@ -114,25 +114,25 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
protected void AssertIRMatchesBaseline(DocumentIRNode document)
{
- if (Filename == null)
+ if (FileName == null)
{
- var message = $"{nameof(AssertIRMatchesBaseline)} should only be called from an integration test ({nameof(Filename)} is null).";
+ var message = $"{nameof(AssertIRMatchesBaseline)} should only be called from an integration test ({nameof(FileName)} is null).";
throw new InvalidOperationException(message);
}
- var baselineFilename = Path.ChangeExtension(Filename, ".ir.txt");
+ var baselineFileName = Path.ChangeExtension(FileName, ".ir.txt");
if (GenerateBaselines)
{
- var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilename);
+ var baselineFullPath = Path.Combine(TestProjectRoot, baselineFileName);
File.WriteAllText(baselineFullPath, RazorIRNodeSerializer.Serialize(document));
return;
}
- var irFile = TestFile.Create(baselineFilename, GetType().GetTypeInfo().Assembly);
+ var irFile = TestFile.Create(baselineFileName, GetType().GetTypeInfo().Assembly);
if (!irFile.Exists())
{
- throw new XunitException($"The resource {baselineFilename} was not found.");
+ throw new XunitException($"The resource {baselineFileName} was not found.");
}
var baseline = irFile.ReadAllText().Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
@@ -141,21 +141,21 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
protected void AssertCSharpDocumentMatchesBaseline(RazorCSharpDocument document)
{
- if (Filename == null)
+ if (FileName == null)
{
- var message = $"{nameof(AssertCSharpDocumentMatchesBaseline)} should only be called from an integration test ({nameof(Filename)} is null).";
+ var message = $"{nameof(AssertCSharpDocumentMatchesBaseline)} should only be called from an integration test ({nameof(FileName)} is null).";
throw new InvalidOperationException(message);
}
- var baselineFilename = Path.ChangeExtension(Filename, ".codegen.cs");
- var baselineDiagnosticsFilename = Path.ChangeExtension(Filename, ".diagnostics.txt");
+ var baselineFileName = Path.ChangeExtension(FileName, ".codegen.cs");
+ var baselineDiagnosticsFileName = Path.ChangeExtension(FileName, ".diagnostics.txt");
if (GenerateBaselines)
{
- var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilename);
+ var baselineFullPath = Path.Combine(TestProjectRoot, baselineFileName);
File.WriteAllText(baselineFullPath, document.GeneratedCode);
- var baselineDiagnosticsFullPath = Path.Combine(TestProjectRoot, baselineDiagnosticsFilename);
+ var baselineDiagnosticsFullPath = Path.Combine(TestProjectRoot, baselineDiagnosticsFileName);
var lines = document.Diagnostics.Select(RazorDiagnosticSerializer.Serialize).ToArray();
if (lines.Any())
{
@@ -169,10 +169,10 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
return;
}
- var codegenFile = TestFile.Create(baselineFilename, GetType().GetTypeInfo().Assembly);
+ var codegenFile = TestFile.Create(baselineFileName, GetType().GetTypeInfo().Assembly);
if (!codegenFile.Exists())
{
- throw new XunitException($"The resource {baselineFilename} was not found.");
+ throw new XunitException($"The resource {baselineFileName} was not found.");
}
var baseline = codegenFile.ReadAllText();
@@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
Assert.Equal(baseline, actual);
var baselineDiagnostics = string.Empty;
- var diagnosticsFile = TestFile.Create(baselineDiagnosticsFilename, GetType().GetTypeInfo().Assembly);
+ var diagnosticsFile = TestFile.Create(baselineDiagnosticsFileName, GetType().GetTypeInfo().Assembly);
if (diagnosticsFile.Exists())
{
baselineDiagnostics = diagnosticsFile.ReadAllText();
@@ -194,29 +194,29 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
protected void AssertLineMappingsMatchBaseline(RazorCodeDocument document)
{
- if (Filename == null)
+ if (FileName == null)
{
- var message = $"{nameof(AssertLineMappingsMatchBaseline)} should only be called from an integration test ({nameof(Filename)} is null).";
+ var message = $"{nameof(AssertLineMappingsMatchBaseline)} should only be called from an integration test ({nameof(FileName)} is null).";
throw new InvalidOperationException(message);
}
var csharpDocument = document.GetCSharpDocument();
Assert.NotNull(csharpDocument);
- var baselineFilename = Path.ChangeExtension(Filename, ".mappings.txt");
+ var baselineFileName = Path.ChangeExtension(FileName, ".mappings.txt");
var serializedMappings = LineMappingsSerializer.Serialize(csharpDocument, document.Source);
if (GenerateBaselines)
{
- var baselineFullPath = Path.Combine(TestProjectRoot, baselineFilename);
+ var baselineFullPath = Path.Combine(TestProjectRoot, baselineFileName);
File.WriteAllText(baselineFullPath, serializedMappings);
return;
}
- var testFile = TestFile.Create(baselineFilename, GetType().GetTypeInfo().Assembly);
+ var testFile = TestFile.Create(baselineFileName, GetType().GetTypeInfo().Assembly);
if (!testFile.Exists())
{
- throw new XunitException($"The resource {baselineFilename} was not found.");
+ throw new XunitException($"The resource {baselineFileName} was not found.");
}
var baseline = testFile.ReadAllText();
@@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
{
public override void VisitClassDeclaration(ClassDeclarationIRNode node)
{
- node.Name = Filename.Replace('/', '_');
+ node.Name = FileName.Replace('/', '_');
node.AccessModifier = "public";
VisitDefault(node);
diff --git a/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntializeTestFileAttribute.cs b/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntializeTestFileAttribute.cs
index 07af1182c8..0b1c78a53e 100644
--- a/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntializeTestFileAttribute.cs
+++ b/test/Microsoft.AspNetCore.Razor.Test.Common/Langauge/IntegrationTests/IntializeTestFileAttribute.cs
@@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
if (typeof(IntegrationTestBase).GetTypeInfo().IsAssignableFrom(methodUnderTest.DeclaringType.GetTypeInfo()))
{
var typeName = methodUnderTest.DeclaringType.Name;
- IntegrationTestBase.Filename = $"TestFiles/IntegrationTests/{typeName}/{methodUnderTest.Name}";
+ IntegrationTestBase.FileName = $"TestFiles/IntegrationTests/{typeName}/{methodUnderTest.Name}";
}
}
@@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Razor.Language.IntegrationTests
{
if (typeof(IntegrationTestBase).GetTypeInfo().IsAssignableFrom(methodUnderTest.DeclaringType.GetTypeInfo()))
{
- IntegrationTestBase.Filename = null;
+ IntegrationTestBase.FileName = null;
}
}
}