From 05422e3cd29851806c6600c0414158f76222c49a Mon Sep 17 00:00:00 2001 From: capdiem Date: Wed, 23 Oct 2024 11:17:05 +0800 Subject: [PATCH] fix: compatibility with .NET 9 (#2201) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * Revert "🔧 chore: disable webcil for running dynamic demo (#2179)" This reverts commit 23d3247c3905ddd6ff300fc9f6393c2d20948907. * Revert "解决组件下try编译失败 (#2178)" This reverts commit 0b1decac2c3e96c2151a3c723c8c9d0e9d5eddb4. * update --- .../Components/Examples/Example.razor.cs | 7 ------- docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj | 2 +- docs/Masa.Docs.Shared/App.razor | 4 ++-- .../Masa.Docs.WebAssembly.csproj | 15 ++++++++++----- .../BottomNavigation/MBottomNavigation.cs | 3 ++- .../Components/ChipGroup/MChipGroup.cs | 3 ++- .../ExpansionPanels/MExpansionPanels.razor.cs | 3 ++- .../Components/ItemGroup/MButtonGroup.cs | 3 ++- .../Components/ItemGroup/MGroupableBase.cs | 16 ++++++++-------- src/Masa.Blazor/Components/ItemGroup/MItem.cs | 4 ---- .../Components/ItemGroup/MItemGroup.razor.cs | 6 +----- .../Components/ItemGroup/MItemGroupBase.cs | 2 +- .../Components/List/MListItemGroup.cs | 3 ++- .../Components/SlideGroup/MSlideGroup.razor.cs | 7 ++----- .../Components/SlideGroup/MSlideItem.cs | 7 +++---- .../Components/Window/MWindow.razor.cs | 3 ++- 16 files changed, 40 insertions(+), 48 deletions(-) diff --git a/docs/Masa.Blazor.Docs/Components/Examples/Example.razor.cs b/docs/Masa.Blazor.Docs/Components/Examples/Example.razor.cs index 8a41468d20..9ebb4a2d66 100644 --- a/docs/Masa.Blazor.Docs/Components/Examples/Example.razor.cs +++ b/docs/Masa.Blazor.Docs/Components/Examples/Example.razor.cs @@ -247,13 +247,6 @@ public async Task RunCode() var portableExecutableReferences = new List(); if (Js is IJSInProcessRuntime) { - var asms = AppDomain.CurrentDomain.GetAssemblies(); - - foreach (var assembly in asms) - { - s_assemblies.Add(assembly.GetName().Name); - } - using var http = HttpClientFactory.CreateClient("masa-docs"); foreach (var asm in s_assemblies) { diff --git a/docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj b/docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj index d967e288db..67d8174f0c 100644 --- a/docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj +++ b/docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj @@ -11,7 +11,7 @@ - + diff --git a/docs/Masa.Docs.Shared/App.razor b/docs/Masa.Docs.Shared/App.razor index cd645e29d4..116a7a7b21 100644 --- a/docs/Masa.Docs.Shared/App.razor +++ b/docs/Masa.Docs.Shared/App.razor @@ -35,13 +35,13 @@ if (path is "blazor/components/image-captcha" or "blazor/labs/watermark") { var assemblies = await AssemblyLoader.LoadAssembliesAsync( - new[] { "SkiaSharp.dll", "SkiaSharp.Views.Blazor.dll" }); + new[] { "SkiaSharp.wasm", "SkiaSharp.Views.Blazor.wasm" }); lazyLoadedAssemblies.AddRange(assemblies); } else if (path == "blazor/components/forms") { var assemblies = await AssemblyLoader.LoadAssembliesAsync( - new[] { "Util.Reflection.dll" }); + new[] { "Util.Reflection.wasm" }); lazyLoadedAssemblies.AddRange(assemblies); } } diff --git a/docs/Masa.Docs.WebAssembly/Masa.Docs.WebAssembly.csproj b/docs/Masa.Docs.WebAssembly/Masa.Docs.WebAssembly.csproj index dd6aca3773..32ee9d7435 100644 --- a/docs/Masa.Docs.WebAssembly/Masa.Docs.WebAssembly.csproj +++ b/docs/Masa.Docs.WebAssembly/Masa.Docs.WebAssembly.csproj @@ -2,21 +2,26 @@ net8.0 + enable enable service-worker-assets.js - false - + + + + + + - - - + + + diff --git a/src/Masa.Blazor/Components/BottomNavigation/MBottomNavigation.cs b/src/Masa.Blazor/Components/BottomNavigation/MBottomNavigation.cs index 0a004a55cc..fea33750d3 100644 --- a/src/Masa.Blazor/Components/BottomNavigation/MBottomNavigation.cs +++ b/src/Masa.Blazor/Components/BottomNavigation/MBottomNavigation.cs @@ -5,8 +5,9 @@ namespace Masa.Blazor; public class MBottomNavigation : MItemGroup, IMeasurable, IScrollable, IAncestorRoutable { - public MBottomNavigation() : base(GroupType.ButtonGroup) + public MBottomNavigation() { + GroupType = GroupType.ButtonGroup; } [Inject] private MasaBlazor MasaBlazor { get; set; } = null!; diff --git a/src/Masa.Blazor/Components/ChipGroup/MChipGroup.cs b/src/Masa.Blazor/Components/ChipGroup/MChipGroup.cs index d5caa6bf85..e8b86b7e38 100644 --- a/src/Masa.Blazor/Components/ChipGroup/MChipGroup.cs +++ b/src/Masa.Blazor/Components/ChipGroup/MChipGroup.cs @@ -2,8 +2,9 @@ public class MChipGroup : MSlideGroup { - public MChipGroup() : base(GroupType.ChipGroup) + public MChipGroup() { + GroupType = GroupType.ChipGroup; } [Parameter] diff --git a/src/Masa.Blazor/Components/ExpansionPanels/MExpansionPanels.razor.cs b/src/Masa.Blazor/Components/ExpansionPanels/MExpansionPanels.razor.cs index 193350f2d3..6128767c03 100644 --- a/src/Masa.Blazor/Components/ExpansionPanels/MExpansionPanels.razor.cs +++ b/src/Masa.Blazor/Components/ExpansionPanels/MExpansionPanels.razor.cs @@ -2,8 +2,9 @@ public partial class MExpansionPanels : MItemGroup { - public MExpansionPanels() : base(GroupType.ExpansionPanels) + public MExpansionPanels() { + GroupType = GroupType.ExpansionPanels; } [Inject] private MasaBlazor MasaBlazor { get; set; } = null!; diff --git a/src/Masa.Blazor/Components/ItemGroup/MButtonGroup.cs b/src/Masa.Blazor/Components/ItemGroup/MButtonGroup.cs index bdc5efe2d1..421d88e42e 100644 --- a/src/Masa.Blazor/Components/ItemGroup/MButtonGroup.cs +++ b/src/Masa.Blazor/Components/ItemGroup/MButtonGroup.cs @@ -2,8 +2,9 @@ public class MButtonGroup : MItemGroup { - public MButtonGroup() : base(GroupType.ButtonGroup) + public MButtonGroup() { + GroupType = GroupType.ButtonGroup; } [Parameter] public bool Borderless { get; set; } diff --git a/src/Masa.Blazor/Components/ItemGroup/MGroupableBase.cs b/src/Masa.Blazor/Components/ItemGroup/MGroupableBase.cs index 017d66902b..246835453b 100644 --- a/src/Masa.Blazor/Components/ItemGroup/MGroupableBase.cs +++ b/src/Masa.Blazor/Components/ItemGroup/MGroupableBase.cs @@ -30,28 +30,28 @@ public StringNumber? Value } /// - /// the of the groupable component. + /// the of the groupable component. /// - private readonly GroupType _groupType; + public GroupType GroupType { get; protected set; } protected bool? UserActive; private StringNumber? _value; private bool _firstRenderAfterBooting; /// - /// Initializes a base component with the . + /// Initializes a base component with the . /// - /// the of the groupable component. + /// the of the groupable component. protected MGroupableBase(GroupType groupType) { - _groupType = groupType; + GroupType = groupType; } /// - /// Initializes a base component with the + /// Initializes a base component with the /// and specifies whether to bootable. /// - /// the of the groupable component. + /// the of the groupable component. /// determines whether bootable is enabled or not. protected MGroupableBase(GroupType groupType, bool bootable) : this(groupType) { @@ -69,7 +69,7 @@ protected MGroupableBase(GroupType groupType, bool bootable) : this(groupType) /// protected IAncestorRoutable? RoutableAncestor => HasRoutableAncestor ? (IAncestorRoutable)ItemGroup! : null; - protected bool Matched => ItemGroup != null && (ItemGroup.GroupType == _groupType); + protected bool Matched => ItemGroup != null && (ItemGroup.GroupType == GroupType); protected bool ValueMatched => Matched && ItemGroup!.InternalValues.Contains(Value); diff --git a/src/Masa.Blazor/Components/ItemGroup/MItem.cs b/src/Masa.Blazor/Components/ItemGroup/MItem.cs index 36ff6a1120..bbbdf5523c 100644 --- a/src/Masa.Blazor/Components/ItemGroup/MItem.cs +++ b/src/Masa.Blazor/Components/ItemGroup/MItem.cs @@ -9,10 +9,6 @@ public MItem() : base(GroupType.ItemGroup) { } - public MItem(GroupType groupType) : base(groupType) - { - } - [Parameter] public RenderFragment? ChildContent { get; set; } protected override void OnAfterRender(bool firstRender) diff --git a/src/Masa.Blazor/Components/ItemGroup/MItemGroup.razor.cs b/src/Masa.Blazor/Components/ItemGroup/MItemGroup.razor.cs index 1955a14493..ba2f3120d6 100644 --- a/src/Masa.Blazor/Components/ItemGroup/MItemGroup.razor.cs +++ b/src/Masa.Blazor/Components/ItemGroup/MItemGroup.razor.cs @@ -5,11 +5,7 @@ namespace Masa.Blazor; public partial class MItemGroup : MItemGroupBase, IThemeable { - public MItemGroup() : base(GroupType.ItemGroup) - { - } - - public MItemGroup(GroupType groupType) : base(groupType) + public MItemGroup(): base(GroupType.ItemGroup) { } diff --git a/src/Masa.Blazor/Components/ItemGroup/MItemGroupBase.cs b/src/Masa.Blazor/Components/ItemGroup/MItemGroupBase.cs index 9cf66e1541..d2d9c477e7 100644 --- a/src/Masa.Blazor/Components/ItemGroup/MItemGroupBase.cs +++ b/src/Masa.Blazor/Components/ItemGroup/MItemGroupBase.cs @@ -40,7 +40,7 @@ protected MItemGroupBase(GroupType groupType) private int _registeredItemsIndex; - public GroupType GroupType { get; private set; } + public GroupType GroupType { get; protected set; } public List Items { get; } = new(); diff --git a/src/Masa.Blazor/Components/List/MListItemGroup.cs b/src/Masa.Blazor/Components/List/MListItemGroup.cs index c7ac56e48c..db43f7c311 100644 --- a/src/Masa.Blazor/Components/List/MListItemGroup.cs +++ b/src/Masa.Blazor/Components/List/MListItemGroup.cs @@ -2,8 +2,9 @@ public class MListItemGroup : MItemGroup { - public MListItemGroup() : base(GroupType.ListItemGroup) + public MListItemGroup() { + GroupType = GroupType.ListItemGroup; } [Parameter] public string? Color { get; set; } diff --git a/src/Masa.Blazor/Components/SlideGroup/MSlideGroup.razor.cs b/src/Masa.Blazor/Components/SlideGroup/MSlideGroup.razor.cs index 37e77ab7d2..e662c9a2be 100644 --- a/src/Masa.Blazor/Components/SlideGroup/MSlideGroup.razor.cs +++ b/src/Masa.Blazor/Components/SlideGroup/MSlideGroup.razor.cs @@ -5,12 +5,9 @@ namespace Masa.Blazor { public partial class MSlideGroup : MItemGroup { - public MSlideGroup() : base(GroupType.SlideGroup) - { - } - - protected MSlideGroup(GroupType groupType) : base(groupType) + public MSlideGroup() { + GroupType = GroupType.SlideGroup; } [Inject] protected MasaBlazor MasaBlazor { get; set; } = null!; diff --git a/src/Masa.Blazor/Components/SlideGroup/MSlideItem.cs b/src/Masa.Blazor/Components/SlideGroup/MSlideItem.cs index d3620d8e8a..ab101ae0bf 100644 --- a/src/Masa.Blazor/Components/SlideGroup/MSlideItem.cs +++ b/src/Masa.Blazor/Components/SlideGroup/MSlideItem.cs @@ -1,10 +1,9 @@ -using Masa.Blazor.Mixins; - -namespace Masa.Blazor; +namespace Masa.Blazor; public class MSlideItem : MItem { - public MSlideItem() : base(GroupType.SlideGroup) + public MSlideItem() { + GroupType = GroupType.SlideGroup; } } \ No newline at end of file diff --git a/src/Masa.Blazor/Components/Window/MWindow.razor.cs b/src/Masa.Blazor/Components/Window/MWindow.razor.cs index e7f45ffa65..d53286a49e 100644 --- a/src/Masa.Blazor/Components/Window/MWindow.razor.cs +++ b/src/Masa.Blazor/Components/Window/MWindow.razor.cs @@ -5,8 +5,9 @@ namespace Masa.Blazor; public partial class MWindow : MItemGroup { - public MWindow() : base(GroupType.Window) + public MWindow() { + GroupType = GroupType.Window; Mandatory = true; }