Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ Copyright (c) .NET Foundation. All rights reserved.
EnableThreads="$(_WasmEnableThreads)"
EnableDiagnostics="$(_WasmEmitDiagnosticModuleBuild)"
EmitSourceMap="$(_WasmEmitSourceMapBuild)"
EmitSymbolMap="$(WasmEmitSymbolMap)"
FingerprintAssets="$(_WasmFingerprintAssets)"
FingerprintDotnetJs="$(_WasmFingerprintDotnetJs)"
>
Expand Down Expand Up @@ -362,6 +363,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<_WasmFingerprintPatterns Include="DllFiles" Pattern="*.dll" Expression="#[.{fingerprint}]!" />
<_WasmFingerprintPatterns Include="DatFiles" Pattern="*.dat" Expression="#[.{fingerprint}]!" />
<_WasmFingerprintPatterns Include="Pdb" Pattern="*.pdb" Expression="#[.{fingerprint}]!" />
<_WasmFingerprintPatterns Include="Symbols" Pattern="*.js.symbols" Expression="#[.{fingerprint}]!" />
</ItemGroup>

<DefineStaticWebAssets
Expand Down Expand Up @@ -700,6 +702,7 @@ Copyright (c) .NET Foundation. All rights reserved.
EnableThreads="$(_WasmEnableThreads)"
EnableDiagnostics="$(_WasmEmitDiagnosticModulePublish)"
EmitSourceMap="$(_WasmEmitSourceMapPublish)"
EmitSymbolMap="$(WasmEmitSymbolMap)"
IsWebCilEnabled="$(_WasmEnableWebcil)"
FingerprintAssets="$(_WasmFingerprintAssets)"
>
Expand Down
25 changes: 25 additions & 0 deletions src/mono/wasm/Wasm.Build.Tests/ModuleConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,29 @@ public async Task AssetIntegrity()
"There are assets without integrity hash"
);
}

[Theory]
[InlineData(true, false)]
[InlineData(true, true)]
[InlineData(false, false)]
[InlineData(false, true)]
public void SymbolMapFileEmitted(bool emitSymbolMap, bool isPublish)
{
Configuration config = Configuration.Release;
string extraProperties = $"<WasmEmitSymbolMap>{emitSymbolMap.ToString().ToLowerInvariant()}</WasmEmitSymbolMap>";
ProjectInfo info = CopyTestAsset(config, aot: false, TestAsset.WasmBasicTestApp,
$"SymbolMapFile_{emitSymbolMap}_{isPublish}", extraProperties: extraProperties);

if (isPublish)
PublishProject(info, config, new PublishOptions(AssertAppBundle: false));
else
BuildProject(info, config, new BuildOptions(AssertAppBundle: false));

string frameworkDir = GetBinFrameworkDir(config, forPublish: isPublish);

// The file may be fingerprinted (e.g. dotnet.native.<hash>.js.symbols),
// so use a glob pattern to find it.
bool symbolsFileExists = Directory.EnumerateFiles(frameworkDir, "dotnet.native*.js.symbols").Any();
Assert.Equal(emitSymbolMap, symbolsFileExists);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected override IReadOnlyDictionary<string, bool> GetAllKnownDotnetFilesToFin
{ "dotnet.js", true },
{ "dotnet.js.map", false },
{ "dotnet.native.js", true },
{ "dotnet.native.js.symbols", false },
{ "dotnet.native.js.symbols", true },
{ "dotnet.native.wasm", true },
{ "dotnet.native.worker.mjs", true },
{ "dotnet.runtime.js", true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static bool ShouldFilterCandidate(
bool enableThreads,
bool enableDiagnostics,
bool emitSourceMap,
bool emitSymbolMap,
out string reason)
{
var extension = candidate.GetMetadata("Extension");
Expand Down Expand Up @@ -90,7 +91,7 @@ public static bool ShouldFilterCandidate(
".js" when assetType == "native" => $"{fileName}{extension} is not used by Blazor",
".mjs" when assetType == "native" && !(enableThreads && fileName == "dotnet.native.worker") => $"{fileName}{extension} is not used by Blazor",
".pdb" when !copySymbols => "copying symbols is disabled",
".symbols" when fromMonoPackage => "extension .symbols is not required.",
".symbols" when !emitSymbolMap => "emitting wasm symbol map is not enabled",
_ => null
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class ComputeWasmBuildAssets : Task

public bool EmitSourceMap { get; set; }

public bool EmitSymbolMap { get; set; }

public bool FingerprintAssets { get; set; }

public bool FingerprintDotNetJs { get; set; }
Expand Down Expand Up @@ -91,7 +93,7 @@ public override bool Execute()
for (int i = 0; i < Candidates.Length; i++)
{
var candidate = Candidates[i];
if (AssetsComputingHelper.ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, LoadFullICUData, CopySymbols, customIcuCandidateFilename, EnableThreads, EnableDiagnostics, EmitSourceMap, out var reason))
if (AssetsComputingHelper.ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, LoadFullICUData, CopySymbols, customIcuCandidateFilename, EnableThreads, EnableDiagnostics, EmitSourceMap, EmitSymbolMap, out var reason))
{
Log.LogMessage(MessageImportance.Low, "Skipping asset '{0}' because '{1}'", candidate.ItemSpec, reason);
filesToRemove.Add(candidate);
Expand Down Expand Up @@ -251,6 +253,7 @@ private static void ApplyUniqueMetadataProperties(ITaskItem candidate)
case ".js" when filename.StartsWith("dotnet"):
case ".mjs" when filename.StartsWith("dotnet"):
case ".dat" when filename.StartsWith("icudt"):
case ".symbols" when filename.StartsWith("dotnet.native"):
candidate.SetMetadata("AssetTraitName", "WasmResource");
candidate.SetMetadata("AssetTraitValue", "native");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class ComputeWasmPublishAssets : Task

public bool EmitSourceMap { get; set; }

public bool EmitSymbolMap { get; set; }

public bool IsWebCilEnabled { get; set; }

public bool FingerprintAssets { get; set; }
Expand Down Expand Up @@ -676,7 +678,7 @@ private void GroupResolvedFilesToPublish(
foreach (var candidate in resolvedFilesToPublish)
{
#pragma warning disable CA1864 // Prefer the 'IDictionary.TryAdd(TKey, TValue)' method. Dictionary.TryAdd() not available in .Net framework.
if (AssetsComputingHelper.ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, LoadFullICUData, CopySymbols, customIcuCandidateFilename, EnableThreads, EnableDiagnostics, EmitSourceMap, out var reason))
if (AssetsComputingHelper.ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, LoadFullICUData, CopySymbols, customIcuCandidateFilename, EnableThreads, EnableDiagnostics, EmitSourceMap, EmitSymbolMap, out var reason))
{
Log.LogMessage(MessageImportance.Low, "Skipping asset '{0}' because '{1}'", candidate.ItemSpec, reason);
if (!resolvedFilesToPublishToRemove.ContainsKey(candidate.ItemSpec))
Expand Down