Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 42e3706

Browse files
author
YishaiGalatzer
committed
Remove RazorCompilationDescriptor and merge with RazorFileInfo
1 parent 01c7bfb commit 42e3706

File tree

4 files changed

+29
-36
lines changed

4 files changed

+29
-36
lines changed

src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/RazorCompilationDescriptor.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/RazoFileInfo.cs renamed to src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/RazorFileInfo.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ public class RazorFileInfo
1717
/// </summary>
1818
public DateTime LastModified { get; set; }
1919

20+
/// <summary>
21+
/// The length of the file in bytes.
22+
/// </summary>
2023
public long Length { get; set; }
2124

25+
/// <summary>
26+
/// Path to to the file relative to the application base.
27+
/// </summary>
2228
public string RelativePath { get; set; }
2329

30+
/// <summary>
31+
/// A hash of the file content.
32+
/// </summary>
2433
public string Hash { get; set; }
2534
}
2635
}

src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/RazorPreCompiler.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public virtual void CompileViews([NotNull] IBeforeCompileContext context)
5555
context.CSharpCompilation = context.CSharpCompilation.AddSyntaxTrees(tree);
5656
}
5757

58-
protected virtual IReadOnlyList<RazorCompilationDescriptor>
58+
protected virtual IReadOnlyList<RazorFileInfo>
5959
CreateCompilationDescriptors([NotNull] IBeforeCompileContext context)
6060
{
6161
var state = new CompilationContext(context);
@@ -95,9 +95,9 @@ private void CompileViews(CompilationContext compilationContext, string currentP
9595
}
9696
}
9797

98-
protected virtual RazorCompilationDescriptor ParseView([NotNull] IFileInfo fileInfo,
99-
[NotNull] IBeforeCompileContext context,
100-
[NotNull] CSharpParseOptions options)
98+
protected virtual RazorFileInfo ParseView([NotNull] IFileInfo fileInfo,
99+
[NotNull] IBeforeCompileContext context,
100+
[NotNull] CSharpParseOptions options)
101101
{
102102
using (var stream = fileInfo.CreateReadStream())
103103
{
@@ -126,11 +126,12 @@ protected virtual RazorCompilationDescriptor ParseView([NotNull] IFileInfo fileI
126126

127127
var hash = RazorFileHash.GetHash(fileInfo);
128128

129-
return new RazorCompilationDescriptor()
129+
return new RazorFileInfo()
130130
{
131-
FullViewTypeName = typeName,
131+
FullTypeName = typeName,
132132
RelativePath = relativePath,
133-
RazorFile = fileInfo,
133+
LastModified = fileInfo.LastModified,
134+
Length = fileInfo.Length,
134135
Hash = hash,
135136
};
136137
}
@@ -149,7 +150,7 @@ public CompilationContext(IBeforeCompileContext context)
149150
Options = ParseOptions.GetParseOptions(context.CSharpCompilation);
150151
}
151152

152-
public List<RazorCompilationDescriptor> CompiledFiles { get; } = new List<RazorCompilationDescriptor>();
153+
public List<RazorFileInfo> CompiledFiles { get; } = new List<RazorFileInfo>();
153154
public IBeforeCompileContext Context { get; private set; }
154155
public CSharpParseOptions Options { get; private set; }
155156
}

src/Microsoft.AspNet.Mvc.Razor/Razor/PreCompileViews/ViewDescriptorCollectionGenerator.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public class ViewDescriptorCollectionGenerator
1212
{
1313
private string _fileFormat;
1414

15-
protected IReadOnlyList<RazorCompilationDescriptor> Descriptors { get; private set; }
15+
protected IReadOnlyList<RazorFileInfo> FileInfos { get; private set; }
1616
protected CSharpParseOptions Options { get; private set; }
1717

18-
public ViewDescriptorCollectionGenerator([NotNull] IReadOnlyList<RazorCompilationDescriptor> descriptors,
18+
public ViewDescriptorCollectionGenerator([NotNull] IReadOnlyList<RazorFileInfo> fileInfos,
1919
[NotNull] CSharpParseOptions options)
2020
{
21-
Descriptors = descriptors;
21+
FileInfos = fileInfos;
2222
Options = options;
2323
}
2424

@@ -27,9 +27,9 @@ public virtual SyntaxTree GenerateCollection()
2727
var builder = new StringBuilder();
2828
builder.Append(Top);
2929

30-
foreach (var descriptor in Descriptors)
30+
foreach (var fileInfo in FileInfos)
3131
{
32-
var perFileEntry = GenerateFile(descriptor);
32+
var perFileEntry = GenerateFile(fileInfo);
3333
builder.Append(perFileEntry);
3434
}
3535

@@ -45,14 +45,14 @@ public virtual SyntaxTree GenerateCollection()
4545
}
4646

4747

48-
protected virtual string GenerateFile([NotNull] RazorCompilationDescriptor descriptor)
48+
protected virtual string GenerateFile([NotNull] RazorFileInfo fileInfo)
4949
{
5050
return string.Format(FileFormat,
51-
descriptor.RazorFile.LastModified.ToFileTimeUtc(),
52-
descriptor.RazorFile.Length,
53-
descriptor.RelativePath,
54-
descriptor.FullViewTypeName,
55-
descriptor.Hash);
51+
fileInfo.LastModified.ToFileTimeUtc(),
52+
fileInfo.Length,
53+
fileInfo.RelativePath,
54+
fileInfo.FullTypeName,
55+
fileInfo.Hash);
5656
}
5757

5858
protected virtual string Top

0 commit comments

Comments
 (0)