-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
Description
Migrated a Blazor application from .NET 5 to latest 6 preview and wanted to test AOT which led me to this error.
Managed to narrow it down to a dictionary implementation which had a strange equality operator overload using EqualityComparer<>.Default.Equals(left, right);
. Changing it to just Equals(left, right);
fixed it (IEquatable<>
is implemented). I have a full repro in the zip-file below.
> dotnet publish -c Release
Microsoft (R) Build Engine version 17.0.0-preview-21378-03+d592862ed for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
All projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
SomeTestLib -> C:\code\private\wasmtest\SomeTestLib\bin\Release\net6.0\SomeTestLib.dll
wasmtest -> C:\code\private\wasmtest\wasmtest\bin\Release\net6.0\wasmtest.dll
wasmtest (Blazor output) -> C:\code\private\wasmtest\wasmtest\bin\Release\net6.0\wwwroot
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
AOT'ing 30 assemblies
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\6.0.0-preview.7.21377.19\Sdk\WasmApp.Native.targets(443,5): error : Precompiling failed for C:\code\private\wasmtest\wasmtest\obj\Release\net6.0\linked\SomeTestLib.dll: Mono Ahead of Time compiler - compiling assembly C:\code\private\wasmtest\wasmtest\obj\Release\net6.0\linked\SomeTestLib.dll [C:\code\private\wasmtest\wasmtest\wasmtest.csproj]
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\6.0.0-preview.7.21377.19\Sdk\WasmApp.Native.targets(443,5): error : * Assertion at D:\workspace\_work\1\s\src\mono\mono\mini\method-to-ir.c:7318, condition `is_ok (error)' not met, function:mono_method_to_ir, VAR 1 (TValue_REF) cannot be expanded in this context with 1 instantiations [C:\code\private\wasmtest\wasmtest\wasmtest.csproj]
Repro solution:
wasmtest.zip
In Classes.cs
, make the following modification to let the build complete successfully with AOT.
public static bool operator ==(ValueDictionary<TKey, TValue>? left, ValueDictionary<TKey, TValue>? right) =>
- EqualityComparer<ValueDictionary<TKey, TValue>>.Default.Equals(left, right);
+ Equals(left, right);
dotnet publish -c Release
Configuration
- Windows 10, x64
PS > dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.7.21379.14
Commit: 22d70b47bc
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19043
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\
Host (useful for support):
Version: 6.0.0-preview.7.21377.19
Commit: 91ba01788d
Regression?
I haven't tried to reproduce in older previews.