Skip to content

Commit f8dd670

Browse files
committed
Use System.Reflection.Metadata to generate BootConfig
* Remove reference to Mono.Cecil * Remove support for auto embedded css \ js
1 parent 96f4c8f commit f8dd670

File tree

10 files changed

+62
-309
lines changed

10 files changed

+62
-309
lines changed

src/Components/Blazor/Build/src/Cli/Commands/WriteBootJsonCommand.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public static void Command(CommandLineApplication command)
1515
"The path to a file that lists the paths to given referenced dll files",
1616
CommandOptionType.SingleValue);
1717

18-
var embeddedResourcesFile = command.Option("--embedded-resources",
19-
"The path to a file that lists the paths of .NET assemblies that may contain embedded resources (typically, referenced assemblies in their pre-linked states)",
20-
CommandOptionType.SingleValue);
21-
2218
var outputPath = command.Option("--output",
2319
"Path to the output file",
2420
CommandOptionType.SingleValue);
@@ -44,14 +40,9 @@ public static void Command(CommandLineApplication command)
4440
? File.ReadAllLines(referencesFile.Value())
4541
: Array.Empty<string>();
4642

47-
var embeddedResourcesSources = embeddedResourcesFile.HasValue()
48-
? File.ReadAllLines(embeddedResourcesFile.Value())
49-
: Array.Empty<string>();
50-
5143
BootJsonWriter.WriteFile(
5244
mainAssemblyPath.Value,
5345
referencesSources,
54-
embeddedResourcesSources,
5546
linkerEnabledFlag.HasValue(),
5647
outputPath.Value());
5748
return 0;

src/Components/Blazor/Build/src/Core/BootJsonWriter.cs

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7-
using System.Linq;
7+
using System.Reflection;
88
using System.Text.Json;
99
using Microsoft.AspNetCore.Components;
10-
using Mono.Cecil;
1110

1211
namespace Microsoft.AspNetCore.Blazor.Build
1312
{
@@ -16,79 +15,44 @@ internal class BootJsonWriter
1615
public static void WriteFile(
1716
string assemblyPath,
1817
string[] assemblyReferences,
19-
string[] embeddedResourcesSources,
2018
bool linkerEnabled,
2119
string outputPath)
2220
{
23-
var embeddedContent = EmbeddedResourcesProcessor.ExtractEmbeddedResources(
24-
embeddedResourcesSources, Path.GetDirectoryName(outputPath));
2521
var bootJsonText = GetBootJsonContent(
26-
Path.GetFileName(assemblyPath),
27-
GetAssemblyEntryPoint(assemblyPath),
22+
AssemblyName.GetAssemblyName(assemblyPath).Name,
2823
assemblyReferences,
29-
embeddedContent,
3024
linkerEnabled);
3125
var normalizedOutputPath = Path.GetFullPath(outputPath);
3226
Console.WriteLine("Writing boot data to: " + normalizedOutputPath);
3327
File.WriteAllText(normalizedOutputPath, bootJsonText);
3428
}
3529

36-
public static string GetBootJsonContent(string assemblyFileName, string entryPoint, string[] assemblyReferences, IEnumerable<EmbeddedResourceInfo> embeddedContent, bool linkerEnabled)
30+
public static string GetBootJsonContent(string entryAssembly, string[] assemblyReferences, bool linkerEnabled)
3731
{
3832
var data = new BootJsonData(
39-
assemblyFileName,
40-
entryPoint,
33+
entryAssembly,
4134
assemblyReferences,
42-
embeddedContent,
4335
linkerEnabled);
4436
return JsonSerializer.Serialize(data, JsonSerializerOptionsProvider.Options);
4537
}
4638

47-
private static string GetAssemblyEntryPoint(string assemblyPath)
48-
{
49-
using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(assemblyPath))
50-
{
51-
var entryPoint = assemblyDefinition.EntryPoint;
52-
if (entryPoint == null)
53-
{
54-
throw new ArgumentException($"The assembly at {assemblyPath} has no specified entry point.");
55-
}
56-
57-
return $"{entryPoint.DeclaringType.FullName}::{entryPoint.Name}";
58-
}
59-
}
60-
6139
/// <summary>
6240
/// Defines the structure of a Blazor boot JSON file
6341
/// </summary>
64-
class BootJsonData
42+
readonly struct BootJsonData
6543
{
66-
public string Main { get; }
67-
public string EntryPoint { get; }
44+
public string EntryAssembly { get; }
6845
public IEnumerable<string> AssemblyReferences { get; }
69-
public IEnumerable<string> CssReferences { get; }
70-
public IEnumerable<string> JsReferences { get; }
7146
public bool LinkerEnabled { get; }
7247

7348
public BootJsonData(
74-
string entrypointAssemblyWithExtension,
75-
string entryPoint,
49+
string entryAssembly,
7650
IEnumerable<string> assemblyReferences,
77-
IEnumerable<EmbeddedResourceInfo> embeddedContent,
7851
bool linkerEnabled)
7952
{
80-
Main = entrypointAssemblyWithExtension;
81-
EntryPoint = entryPoint;
53+
EntryAssembly = entryAssembly;
8254
AssemblyReferences = assemblyReferences;
8355
LinkerEnabled = linkerEnabled;
84-
85-
CssReferences = embeddedContent
86-
.Where(c => c.Kind == EmbeddedResourceKind.Css)
87-
.Select(c => c.RelativePath);
88-
89-
JsReferences = embeddedContent
90-
.Where(c => c.Kind == EmbeddedResourceKind.JavaScript)
91-
.Select(c => c.RelativePath);
9256
}
9357
}
9458
}

src/Components/Blazor/Build/src/Core/EmbeddedResources/EmbeddedResourceInfo.cs

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

src/Components/Blazor/Build/src/Core/EmbeddedResources/EmbeddedResourceKind.cs

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

src/Components/Blazor/Build/src/Core/EmbeddedResources/EmbeddedResourcesProcessor.cs

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

0 commit comments

Comments
 (0)