Skip to content

[main] Update dependencies from dotnet/razor #48362

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

Merged
merged 9 commits into from
Apr 14, 2025
Merged
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,22 +426,22 @@
<Sha>b3399b82c5f13e3f4ad164656083d37b5c04ea85</Sha>
<SourceBuild RepoName="aspnetcore" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.CodeAnalysis.Razor.Tooling.Internal" Version="10.0.0-preview.25209.1">
<Dependency Name="Microsoft.CodeAnalysis.Razor.Tooling.Internal" Version="10.0.0-preview.25213.1">
<Uri>https://github.com/dotnet/razor</Uri>
<Sha>b4c33260cee7aa836db701bc92e09742435fc73e</Sha>
<Sha>f50cc83551d1458a73206ac8f08bf117d0b32d5a</Sha>
</Dependency>
<Dependency Name="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="10.0.0-preview.25209.1">
<Dependency Name="Microsoft.AspNetCore.Mvc.Razor.Extensions.Tooling.Internal" Version="10.0.0-preview.25213.1">
<Uri>https://github.com/dotnet/razor</Uri>
<Sha>b4c33260cee7aa836db701bc92e09742435fc73e</Sha>
<Sha>f50cc83551d1458a73206ac8f08bf117d0b32d5a</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Sdk.Razor.SourceGenerators.Transport" Version="10.0.0-preview.25209.1">
<Dependency Name="Microsoft.NET.Sdk.Razor.SourceGenerators.Transport" Version="10.0.0-preview.25213.1">
<Uri>https://github.com/dotnet/razor</Uri>
<Sha>b4c33260cee7aa836db701bc92e09742435fc73e</Sha>
<Sha>f50cc83551d1458a73206ac8f08bf117d0b32d5a</Sha>
</Dependency>
<!-- Intermediate is necessary for source build. -->
<Dependency Name="Microsoft.SourceBuild.Intermediate.razor" Version="10.0.0-preview.25209.1">
<Dependency Name="Microsoft.SourceBuild.Intermediate.razor" Version="10.0.0-preview.25213.1">
<Uri>https://github.com/dotnet/razor</Uri>
<Sha>b4c33260cee7aa836db701bc92e09742435fc73e</Sha>
<Sha>f50cc83551d1458a73206ac8f08bf117d0b32d5a</Sha>
<SourceBuild RepoName="razor" ManagedOnly="true" />
</Dependency>
<!-- For coherency purposes, these versions should be gated by the versions of winforms and wpf routed via windowsdesktop -->
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/razor -->
<MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion>10.0.0-preview.25209.1</MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion>
<MicrosoftCodeAnalysisRazorToolingInternalVersion>10.0.0-preview.25209.1</MicrosoftCodeAnalysisRazorToolingInternalVersion>
<MicrosoftNETSdkRazorSourceGeneratorsTransportPackageVersion>10.0.0-preview.25209.1</MicrosoftNETSdkRazorSourceGeneratorsTransportPackageVersion>
<MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion>10.0.0-preview.25213.1</MicrosoftAspNetCoreMvcRazorExtensionsToolingInternalPackageVersion>
<MicrosoftCodeAnalysisRazorToolingInternalVersion>10.0.0-preview.25213.1</MicrosoftCodeAnalysisRazorToolingInternalVersion>
<MicrosoftNETSdkRazorSourceGeneratorsTransportPackageVersion>10.0.0-preview.25213.1</MicrosoftNETSdkRazorSourceGeneratorsTransportPackageVersion>
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/emsdk -->
Expand Down
2 changes: 1 addition & 1 deletion src/RazorSdk/Tool/CompositeRazorProjectFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override IEnumerable<RazorProjectItem> EnumerateItems(string basePath)
}
}

public override RazorProjectItem GetItem(string path, string fileKind)
public override RazorProjectItem GetItem(string path, RazorFileKind? fileKind)
{
RazorProjectItem razorProjectItem = null;
foreach (var fileSystem in FileSystems)
Expand Down
38 changes: 34 additions & 4 deletions src/RazorSdk/Tool/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,13 @@ private static SourceItem[] GetSourceItems(List<string> sources, List<string> ou
var items = new SourceItem[sources.Count];
for (var i = 0; i < items.Length; i++)
{
var fileKind = fileKinds.Count > 0 ? fileKinds[i] : "mvc";
var fileKind = fileKinds.Count > 0
? ConvertFileKind(fileKinds[i])
: RazorFileKind.Legacy;

if (AspNetCore.Razor.Language.FileKinds.IsComponent(fileKind))
{
fileKind = AspNetCore.Razor.Language.FileKinds.GetComponentFileKindFromFilePath(sources[i]);
fileKind = GetComponentFileKindFromFilePath(sources[i]);
}

var cssScopeValue = cssScopeAssociations.TryGetValue(sources[i], out var cssScopeIndex)
Expand All @@ -345,6 +348,33 @@ private static SourceItem[] GetSourceItems(List<string> sources, List<string> ou
return items;
}

private static RazorFileKind ConvertFileKind(string fileKind)
{
if (string.Equals(fileKind, "component", StringComparison.OrdinalIgnoreCase))
{
return RazorFileKind.Component;
}

if (string.Equals(fileKind, "componentImport", StringComparison.OrdinalIgnoreCase))
{
return RazorFileKind.ComponentImport;
}

if (string.Equals(fileKind, "mvc", StringComparison.OrdinalIgnoreCase))
{
return RazorFileKind.Legacy;
}

return RazorFileKind.Legacy;
}

private static RazorFileKind GetComponentFileKindFromFilePath(string filePath)
{
return AspNetCore.Razor.Language.FileKinds.TryGetFileKindFromPath(filePath, out var kind) && kind != RazorFileKind.Legacy
? kind
: RazorFileKind.Component;
}

private OutputItem[] GenerateCode(RazorProjectEngine engine, SourceItem[] inputs)
{
var outputs = new OutputItem[inputs.Length];
Expand Down Expand Up @@ -377,7 +407,7 @@ public OutputItem(

private readonly struct SourceItem
{
public SourceItem(string sourcePath, string outputPath, string physicalRelativePath, string fileKind, string cssScope)
public SourceItem(string sourcePath, string outputPath, string physicalRelativePath, RazorFileKind fileKind, string cssScope)
{
SourcePath = sourcePath;
OutputPath = outputPath;
Expand All @@ -397,7 +427,7 @@ public SourceItem(string sourcePath, string outputPath, string physicalRelativeP

public string FilePath { get; }

public string FileKind { get; }
public RazorFileKind FileKind { get; }

public string CssScope { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ internal class NotFoundProjectItem : RazorProjectItem
/// <param name="basePath">The base path.</param>
/// <param name="path">The path.</param>
/// <param name="fileKind">The file kind</param>
public NotFoundProjectItem(string basePath, string path, string fileKind)
public NotFoundProjectItem(string basePath, string path, RazorFileKind? fileKind)
{
BasePath = basePath;
FilePath = path;
FileKind = fileKind ?? FileKinds.GetFileKindFromFilePath(path);
FileKind = fileKind ?? FileKinds.GetFileKindFromPath(path);
}

/// <inheritdoc />
Expand All @@ -30,7 +30,7 @@ public NotFoundProjectItem(string basePath, string path, string fileKind)
public override string FilePath { get; }

/// <inheritdoc />
public override string FileKind { get; }
public override RazorFileKind FileKind { get; }

/// <inheritdoc />
public override bool Exists => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ namespace Microsoft.AspNetCore.Razor.Language
{
public class TestRazorProjectItem : RazorProjectItem
{
private readonly string _fileKind;
private readonly RazorFileKind? _fileKind;

public TestRazorProjectItem(
string filePath,
string physicalPath = null,
string relativePhysicalPath = null,
string basePath = "/",
string fileKind = null,
RazorFileKind? fileKind = null,
string cssScope = null)
{
FilePath = filePath;
Expand All @@ -27,7 +27,7 @@ public TestRazorProjectItem(

public override string BasePath { get; }

public override string FileKind => _fileKind ?? base.FileKind;
public override RazorFileKind FileKind => _fileKind ?? base.FileKind;

public override string FilePath { get; }

Expand Down
Loading