Skip to content

Commit b7b0c45

Browse files
committed
Add support for source generators in Razor compiler
1 parent 460d4d9 commit b7b0c45

File tree

7 files changed

+128
-7
lines changed

7 files changed

+128
-7
lines changed

src/Razor/Microsoft.AspNetCore.Razor.Language/src/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Common, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1111
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.LanguageServer.Common.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1212
[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.TagHelperTool, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
13+
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.SourceGenerators, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1314
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1415
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Razor.Workspaces, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
1516
[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Remote.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]

src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorProjectItem.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ public string FilePathWithoutExtension
130130
}
131131
}
132132

133+
internal RazorSourceDocument RazorSourceDocument { get; set; }
134+
133135
private string DebuggerToString()
134136
{
135137
return CombinedPath;
136138
}
137139
}
138-
}
140+
}

src/Razor/Microsoft.AspNetCore.Razor.Language/src/RazorSourceDocument.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public static RazorSourceDocument ReadFrom(Stream stream, Encoding encoding, Raz
162162
{
163163
throw new ArgumentNullException(nameof(properties));
164164
}
165-
165+
166166
return new StreamSourceDocument(stream, encoding, properties);
167167
}
168168

@@ -179,7 +179,7 @@ public static RazorSourceDocument ReadFrom(RazorProjectItem projectItem)
179179
}
180180

181181
// ProjectItem.PhysicalPath is usually an absolute (rooted) path.
182-
var filePath = projectItem.PhysicalPath;
182+
var filePath = projectItem.PhysicalPath;
183183
if (string.IsNullOrEmpty(filePath))
184184
{
185185
// Fall back to the relative path only if necessary.
@@ -193,6 +193,11 @@ public static RazorSourceDocument ReadFrom(RazorProjectItem projectItem)
193193
filePath = projectItem.FilePath;
194194
}
195195

196+
if (projectItem.RazorSourceDocument is not null)
197+
{
198+
return projectItem.RazorSourceDocument;
199+
}
200+
196201
using (var stream = projectItem.Read())
197202
{
198203
// Autodetect the encoding.
@@ -217,7 +222,7 @@ public static RazorSourceDocument Create(string content, string fileName)
217222

218223
return Create(content, fileName, Encoding.UTF8);
219224
}
220-
225+
221226

222227
/// <summary>
223228
/// Creates a <see cref="RazorSourceDocument"/> from the specified <paramref name="content"/>.

src/Razor/Microsoft.CodeAnalysis.Razor/src/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
2525
[assembly: InternalsVisibleTo("Microsoft.VisualStudio.Mac.LanguageServices.Razor, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
2626
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
27+
[assembly: InternalsVisibleTo("Microsoft.NET.Sdk.Razor.SourceGenerators, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": true,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:5762/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"ANCM IIS Express": {
12+
"commandName": "Executable",
13+
"executablePath": "$(IISExpressPath)",
14+
"commandLineArgs": "$(IISExpressArguments)",
15+
"environmentVariables": {
16+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
17+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
18+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
19+
"LAUNCHER_ARGS": "$(TargetPath)",
20+
"ASPNETCORE_ENVIRONMENT": "Development",
21+
"LAUNCHER_PATH": "$(DotNetPath)",
22+
"ASPNETCORE_MODULE_DEBUG": "console"
23+
}
24+
},
25+
"ANCM IIS": {
26+
"commandName": "Executable",
27+
"executablePath": "$(IISPath)",
28+
"commandLineArgs": "$(IISArguments)",
29+
"environmentVariables": {
30+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
31+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
32+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
33+
"LAUNCHER_ARGS": "$(TargetPath)",
34+
"ASPNETCORE_ENVIRONMENT": "Development",
35+
"LAUNCHER_PATH": "$(DotNetPath)",
36+
"ASPNETCORE_MODULE_DEBUG": "console"
37+
}
38+
}
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": true,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:5762/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"ANCM IIS Express": {
12+
"commandName": "Executable",
13+
"executablePath": "$(IISExpressPath)",
14+
"commandLineArgs": "$(IISExpressArguments)",
15+
"environmentVariables": {
16+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
17+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
18+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
19+
"LAUNCHER_ARGS": "$(TargetPath)",
20+
"ASPNETCORE_ENVIRONMENT": "Development",
21+
"LAUNCHER_PATH": "$(DotNetPath)",
22+
"ASPNETCORE_MODULE_DEBUG": "console"
23+
}
24+
},
25+
"ANCM IIS": {
26+
"commandName": "Executable",
27+
"executablePath": "$(IISPath)",
28+
"commandLineArgs": "$(IISArguments)",
29+
"environmentVariables": {
30+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
31+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
32+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
33+
"LAUNCHER_ARGS": "$(TargetPath)",
34+
"ASPNETCORE_ENVIRONMENT": "Development",
35+
"LAUNCHER_PATH": "$(DotNetPath)",
36+
"ASPNETCORE_MODULE_DEBUG": "console"
37+
}
38+
}
39+
}
40+
}
Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,40 @@
11
{
2+
"iisSettings": {
3+
"windowsAuthentication": true,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:5762/",
7+
"sslPort": 0
8+
}
9+
},
210
"profiles": {
3-
"ServerComparison.TestSites": {
4-
"commandName": "Project",
5-
"launchBrowser": true
11+
"ANCM IIS Express": {
12+
"commandName": "Executable",
13+
"executablePath": "$(IISExpressPath)",
14+
"commandLineArgs": "$(IISExpressArguments)",
15+
"environmentVariables": {
16+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
17+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
18+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
19+
"LAUNCHER_ARGS": "$(TargetPath)",
20+
"ASPNETCORE_ENVIRONMENT": "Development",
21+
"LAUNCHER_PATH": "$(DotNetPath)",
22+
"ASPNETCORE_MODULE_DEBUG": "console"
23+
}
24+
},
25+
"ANCM IIS": {
26+
"commandName": "Executable",
27+
"executablePath": "$(IISPath)",
28+
"commandLineArgs": "$(IISArguments)",
29+
"environmentVariables": {
30+
"IIS_SITE_PATH": "$(MSBuildThisFileDirectory)",
31+
"ANCMV2_PATH": "$(AspNetCoreModuleV2ShimDll)",
32+
"ASPNETCORE_MODULE_OUTOFPROCESS_HANDLER": "$(AspNetCoreModuleV2OutOfProcessHandlerDll)",
33+
"LAUNCHER_ARGS": "$(TargetPath)",
34+
"ASPNETCORE_ENVIRONMENT": "Development",
35+
"LAUNCHER_PATH": "$(DotNetPath)",
36+
"ASPNETCORE_MODULE_DEBUG": "console"
37+
}
638
}
739
}
840
}

0 commit comments

Comments
 (0)