fluentui-blazor: fix: FluentMenu broken in published release build
🐛 Bug Report
I have a basic FluentMenu.
On local development build everything works great. On a published release build clicking the FluentMenuItem causes an exception. There are no other warnings or exceptions visible in dev tools.
blazor.webassembly.js:1
Uncaught (in promise) Error: System.InvalidOperationException: There was an error parsing the event arguments. EventId: '8'.
---> System.NotSupportedException: DeserializeNoConstructor, JsonConstructorAttribute, Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs Path: $ | LineNumber: 0 | BytePositionInLine: 1.
---> System.NotSupportedException: DeserializeNoConstructor, JsonConstructorAttribute, Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs
Exception_EndOfInnerExceptionStack
at System.Text.Json.ThrowHelper.ThrowNotSupportedException(ReadStack& , Utf8JsonReader& , NotSupportedException )
at System.Text.Json.ThrowHelper.ThrowNotSupportedException_DeserializeNoConstructor(Type , Utf8JsonReader& , ReadStack& )
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs, Microsoft.Fast.Components.FluentUI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , MenuChangeEventArgs& )
at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs, Microsoft.Fast.Components.FluentUI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]].TryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , MenuChangeEventArgs& )
at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs, Microsoft.Fast.Components.FluentUI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.Fast.Components.FluentUI.MenuChangeEventArgs, Microsoft.Fast.Components.FluentUI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null]].ReadCoreAsObject(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo , Nullable`1 )
at System.Text.Json.JsonSerializer.ReadFromSpan[Object](ReadOnlySpan`1 , JsonTypeInfo )
at System.Text.Json.JsonSerializer.Deserialize(String , Type , JsonSerializerOptions )
at Microsoft.AspNetCore.Components.Web.WebEventData.ParseEventArgsJson(Renderer , JsonSerializerOptions , UInt64 , String , JsonElement )
Exception_EndOfInnerExceptionStack
at Microsoft.AspNetCore.Components.Web.WebEventData.ParseEventArgsJson(Renderer , JsonSerializerOptions , UInt64 , String , JsonElement )
at Microsoft.AspNetCore.Components.Web.WebEventData.Parse(Renderer , JsonSerializerOptions , WebEventDescriptor , JsonElement )
at Microsoft.AspNetCore.Components.Web.WebEventData.Parse(Renderer , JsonSerializerOptions , JsonElement , JsonElement )
at Microsoft.AspNetCore.Components.RenderTree.WebRenderer.WebRendererInteropMethods.DispatchEventAsync(JsonElement eventDescriptor, JsonElement eventArgs)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime , DotNetInvocationInfo& , IDotNetObjectReference , String )
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime , DotNetInvocationInfo , String )
at Object.endInvokeDotNetFromJS (**************/_framework/blazor.webassembly.js:1:3549)
at Object.Xt [as endInvokeDotNetFromJS] (**************/_framework/blazor.webassembly.js:1:63231)
at Object.Gt [as invokeJSFromDotNet] (**************/_framework/blazor.webassembly.js:1:62728)
at Object.Ii (**************/_framework/dotnet.7.0.1.16jbry1adl.js:5:71465)
at _mono_wasm_invoke_js_blazor (**************/_framework/dotnet.7.0.1.16jbry1adl.js:14:103886)
at wasm://wasm/00992aee:wasm-function[313]:0x1d4d6
at wasm://wasm/00992aee:wasm-function[283]:0x1c904
at wasm://wasm/00992aee:wasm-function[221]:0xdff4
at wasm://wasm/00992aee:wasm-function[220]:0xce93
at wasm://wasm/00992aee:wasm-function[8113]:0x1a215b
endInvokeDotNetFromJS @ blazor.webassembly.js:1
Xt @ blazor.webassembly.js:1
Gt @ blazor.webassembly.js:1
Ii @ dotnet.7.0.1.16jbry1adl.js:5
_mono_wasm_invoke_js_blazor @ dotnet.7.0.1.16jbry1adl.js:14
$func313 @ 00992aee:0x1d4d6
$func283 @ 00992aee:0x1c904
$func221 @ 00992aee:0xdff4
$func220 @ 00992aee:0xce93
$func8113 @ 00992aee:0x1a215b
$func2054 @ 00992aee:0x85bb8
$func2059 @ 00992aee:0x86220
$func2086 @ 00992aee:0x882df
$mono_wasm_invoke_method_ref @ 00992aee:0x9bcf
Module._mono_wasm_invoke_method_ref @ dotnet.7.0.1.16jbry1adl.js:14
_Microsoft_AspNetCore_Components_WebAssembly__Microsoft_AspNetCore_Components_WebAssembly_Services_DefaultWebAssemblyJSRuntime_BeginInvokeDotNet @ _Microsoft_AspNetCor…eginInvokeDotNet:29
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
b @ blazor.webassembly.js:1
invokeMethodAsync @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
invokeWhenHeapUnlocked @ blazor.webassembly.js:1
S @ blazor.webassembly.js:1
A @ blazor.webassembly.js:1
dispatchGlobalEventToAllElements @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
onGlobalEvent @ blazor.webassembly.js:1
emit @ web-components.min.js:1
$emit @ web-components.min.js:1
invoke @ web-components.min.js:21
handleMenuItemClick @ web-components.min.js:21
(anonymous) @ web-components.min.js:183
handleEvent
That’s all the info I have at this point. I can try to come up with minimal repro in few days.
💻 Repro or Code Sample
🤔 Expected Behavior
😯 Current Behavior
💁 Possible Solution
🔦 Context
🌍 Your Environment
<PackageReference Include="Microsoft.Fast.Components.FluentUI" Version="2.0.0-rc-2" />
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 36 (3 by maintainers)
Commits related to this issue
- fix: FluentDialog overlay dismiss broken in published release build for Azure SWA This fix is related to #280 , but for FluentDialog — committed to Narvalex/fluentui-blazor by Narvalex 6 months ago
@Narvalex This problem seems to be due to an invalid deserialization of the
DialogEventArgsclass. Are you using a class inherited from this class? Or can you add this line to your code to check whether the Trimming process has removed this class?This is added for FluentSwitch in version 2.1 which will be released in the coming days
Ok, applying the same trick with the attribute on the
DesignTokenconstructor resolved the error in the minimal repo. Please test again with this packageOk, I think I have the code replicated now in my local copy of your minimal repo and publishing as I’m typing this…
Update: Yes, can replicate the error
No, it definitely is a trimming issue. Works on non-trimmed build.
Just meant that I don’t think it’s necessarily new to the build you sent to me. Haven’t tested that particular line on the nuget build of the package (with trimming enabled).
The minimal repro with just the menu component works fine now.
There might be a way I can use the attribute in the library itself. Will experiment with it some more tomorrow.
Similar issue trying to dismiss FluentDialog by clicking outside the dialog.