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

Unify app and view assembly for Razor #16168

Merged
merged 9 commits into from Mar 10, 2021
Merged

Unify app and view assembly for Razor #16168

merged 9 commits into from Mar 10, 2021

Conversation

captainsafia
Copy link
Member

No description provided.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@captainsafia captainsafia added the Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch label Mar 2, 2021
@captainsafia captainsafia force-pushed the safia/one-assembly branch 2 times, most recently from cc09a68 to e3dbd15 Compare March 4, 2021 22:18
@captainsafia captainsafia marked this pull request as ready for review March 5, 2021 22:18
src/RazorSdk/SourceGenerators/RazorSourceGenerator.cs Outdated Show resolved Hide resolved
src/RazorSdk/SourceGenerators/RazorSourceGenerator.cs Outdated Show resolved Hide resolved
src/RazorSdk/Targets/Sdk.Razor.CurrentVersion.targets Outdated Show resolved Hide resolved

RazorCoreCompile and any other targets that are needed for two-step compilation should be defined there.
-->
<Import Project="Microsoft.NET.Sdk.Razor.Compilation.targets" Condition="'$(_UseRazorSourceGenerator)' != 'true'"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any fun stuff in here (properties or items) that requires it to be imported where it was previously imported? For .e.g

<!-- <Import Project="X.target" /> -->
<PropertyGroup>
  <Foo>X</Foo>
</PropertyGroup>

<!-- <Import Project="Y.targets" /> -->
<PropertyGroup>
  <Foo>$(Foo);X</Foo>
</PropertyGroup>

Would behave differently if you change the order in which X and Y are imported.

src/RazorSdk/SourceGenerators/RazorSourceGenerator.cs Outdated Show resolved Hide resolved
@@ -78,9 +86,18 @@ private void GenerateViews(GeneratorExecutionContext context, RazorSourceGenerat
context.ReportDiagnostic(csharpDiagnostic);
}

Directory.CreateDirectory(Path.GetDirectoryName(file.GeneratedOutputPath));
File.WriteAllText(file.GeneratedOutputPath, csharpDocument.GeneratedCode);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @jaredpar

@captainsafia
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@captainsafia
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -221,6 +240,13 @@ private static IReadOnlyList<TagHelperDescriptor> GetTagHelperDescriptorsFromRef
return tagHelperDescriptors;
}

private static void PopulateAssemblyInfo(GeneratorExecutionContext context)
{
var typeInfo = "typeof(global::Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFactory), global::Microsoft.AspNetCore.Mvc.Razor";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need this: , global::Microsoft.AspNetCore.Mvc.Razor

{
var typeInfo = "typeof(global::Microsoft.AspNetCore.Mvc.ApplicationParts.ConsolidatedAssemblyApplicationPartFactory), global::Microsoft.AspNetCore.Mvc.Razor";
var assemblyInfo = $@"[assembly: global::Microsoft.AspNetCore.Mvc.ApplicationParts.ProvideApplicationPartFactoryAttribute(""{typeInfo}"")]";
context.AddSource($"{context.Compilation.AssemblyName}.UnifiedAssembly.Info", SourceText.From(assemblyInfo, Encoding.UTF8));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this one is ripe for being statically cached

@captainsafia captainsafia merged commit 6a7e4ca into master Mar 10, 2021
@akoeplinger akoeplinger deleted the safia/one-assembly branch April 12, 2021 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-AspNetCore RazorSDK, BlazorWebAssemblySDK, dotnet-watch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants