Skip to content

Commit 307e107

Browse files
authored
Add support for source generators in Razor compiler (#29916)
* Add support for source generators in Razor compiler * Fix PublicAPI text files
1 parent 70a880f commit 307e107

File tree

8 files changed

+16
-198
lines changed

8 files changed

+16
-198
lines changed

src/Components/Components/src/PublicAPI.Unshipped.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Microsoft.AspNetCore.Components.DynamicComponent.Type.get -> System.Type!
99
Microsoft.AspNetCore.Components.DynamicComponent.Type.set -> void
1010
static Microsoft.AspNetCore.Components.ParameterView.FromDictionary(System.Collections.Generic.IDictionary<string!, object?>! parameters) -> Microsoft.AspNetCore.Components.ParameterView
1111
virtual Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(ulong eventHandlerId, Microsoft.AspNetCore.Components.RenderTree.EventFieldInfo? fieldInfo, System.EventArgs! eventArgs) -> System.Threading.Tasks.Task!
12+
*REMOVED*readonly Microsoft.AspNetCore.Components.RenderTree.RenderTreeEdit.RemovedAttributeName -> string

src/Components/Ignitor/src/Ignitor.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
<NoWarn>$(NoWarn);CS1591</NoWarn>
88
<DefineConstants>$(DefineConstants);IGNITOR</DefineConstants>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10+
11+
<AddPublicApiAnalyzers>false</AddPublicApiAnalyzers>
1012
</PropertyGroup>
1113

1214
<ItemGroup>

src/Components/Ignitor/src/PublicAPI.Shipped.txt

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

src/Components/Ignitor/src/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

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"/>.

0 commit comments

Comments
 (0)