Skip to content

Commit

Permalink
fix: compatibility with .NET 9 (#2201)
Browse files Browse the repository at this point in the history
* wip

* Revert "🔧 chore: disable webcil for running dynamic demo (#2179)"

This reverts commit 23d3247.

* Revert "解决组件下try编译失败 (#2178)"

This reverts commit 0b1deca.

* update
  • Loading branch information
capdiem authored Oct 23, 2024
1 parent 482215c commit 88dcb28
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 48 deletions.
7 changes: 0 additions & 7 deletions docs/Masa.Blazor.Docs/Components/Examples/Example.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,6 @@ public async Task RunCode()
var portableExecutableReferences = new List<PortableExecutableReference>();
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)
{
Expand Down
2 changes: 1 addition & 1 deletion docs/Masa.Blazor.Docs/Masa.Blazor.Docs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Masa.Blazor.Extensions.Languages.Razor" Version="0.0.3" />
<PackageReference Include="Masa.Blazor.Extensions.Languages.Razor" Version="0.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.CustomElements" Version="8.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions docs/Masa.Docs.Shared/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
15 changes: 10 additions & 5 deletions docs/Masa.Docs.WebAssembly/Masa.Docs.WebAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,26 @@

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- <TargetFrameworks>net8.0;net9.0</TargetFrameworks>-->
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<WasmEnableWebcil>false</WasmEnableWebcil>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
</ItemGroup>

<!-- <ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">-->
<!-- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.0-rc.2.*" />-->
<!-- <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.0-rc.2.*" PrivateAssets="all" />-->
<!-- </ItemGroup>-->

<ItemGroup>
<BlazorWebAssemblyLazyLoad Include="SkiaSharp.dll" />
<BlazorWebAssemblyLazyLoad Include="SkiaSharp.Views.Blazor.dll" />
<BlazorWebAssemblyLazyLoad Include="Util.Reflection.dll" />
<BlazorWebAssemblyLazyLoad Include="SkiaSharp.wasm" />
<BlazorWebAssemblyLazyLoad Include="SkiaSharp.Views.Blazor.wasm" />
<BlazorWebAssemblyLazyLoad Include="Util.Reflection.wasm" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
3 changes: 2 additions & 1 deletion src/Masa.Blazor/Components/ChipGroup/MChipGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

public class MChipGroup : MSlideGroup
{
public MChipGroup() : base(GroupType.ChipGroup)
public MChipGroup()
{
GroupType = GroupType.ChipGroup;
}

[Parameter]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
3 changes: 2 additions & 1 deletion src/Masa.Blazor/Components/ItemGroup/MButtonGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

public class MButtonGroup : MItemGroup
{
public MButtonGroup() : base(GroupType.ButtonGroup)
public MButtonGroup()
{
GroupType = GroupType.ButtonGroup;
}

[Parameter] public bool Borderless { get; set; }
Expand Down
16 changes: 8 additions & 8 deletions src/Masa.Blazor/Components/ItemGroup/MGroupableBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ public StringNumber? Value
}

/// <summary>
/// the <see cref="GroupType"/> of the groupable component.
/// the <see cref="Mixins.GroupType"/> of the groupable component.
/// </summary>
private readonly GroupType _groupType;
public GroupType GroupType { get; protected set; }

protected bool? UserActive;
private StringNumber? _value;
private bool _firstRenderAfterBooting;

/// <summary>
/// Initializes a base component <see cref="MGroupable{TGroup}"/> with the <see cref="GroupType"/>.
/// Initializes a base component <see cref="MGroupable{TGroup}"/> with the <see cref="Mixins.GroupType"/>.
/// </summary>
/// <param name="groupType">the <see cref="GroupType"/> of the groupable component.</param>
/// <param name="groupType">the <see cref="Mixins.GroupType"/> of the groupable component.</param>
protected MGroupableBase(GroupType groupType)
{
_groupType = groupType;
GroupType = groupType;
}

/// <summary>
/// Initializes a base component <see cref="MGroupable{TGroup}"/> with the <see cref="GroupType"/>
/// Initializes a base component <see cref="MGroupable{TGroup}"/> with the <see cref="Mixins.GroupType"/>
/// and specifies whether to bootable.
/// </summary>
/// <param name="groupType">the <see cref="GroupType"/> of the groupable component.</param>
/// <param name="groupType">the <see cref="Mixins.GroupType"/> of the groupable component.</param>
/// <param name="bootable">determines whether bootable is enabled or not.</param>
protected MGroupableBase(GroupType groupType, bool bootable) : this(groupType)
{
Expand All @@ -69,7 +69,7 @@ protected MGroupableBase(GroupType groupType, bool bootable) : this(groupType)
/// </summary>
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);

Expand Down
4 changes: 0 additions & 4 deletions src/Masa.Blazor/Components/ItemGroup/MItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ public MItem() : base(GroupType.ItemGroup)
{
}

public MItem(GroupType groupType) : base(groupType)
{
}

[Parameter] public RenderFragment<ItemContext>? ChildContent { get; set; }

protected override void OnAfterRender(bool firstRender)
Expand Down
6 changes: 1 addition & 5 deletions src/Masa.Blazor/Components/ItemGroup/MItemGroup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Masa.Blazor/Components/ItemGroup/MItemGroupBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IGroupable> Items { get; } = new();

Expand Down
3 changes: 2 additions & 1 deletion src/Masa.Blazor/Components/List/MListItemGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

public class MListItemGroup : MItemGroup
{
public MListItemGroup() : base(GroupType.ListItemGroup)
public MListItemGroup()
{
GroupType = GroupType.ListItemGroup;
}

[Parameter] public string? Color { get; set; }
Expand Down
7 changes: 2 additions & 5 deletions src/Masa.Blazor/Components/SlideGroup/MSlideGroup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down
7 changes: 3 additions & 4 deletions src/Masa.Blazor/Components/SlideGroup/MSlideItem.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 2 additions & 1 deletion src/Masa.Blazor/Components/Window/MWindow.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace Masa.Blazor;

public partial class MWindow : MItemGroup
{
public MWindow() : base(GroupType.Window)
public MWindow()
{
GroupType = GroupType.Window;
Mandatory = true;
}

Expand Down

0 comments on commit 88dcb28

Please sign in to comment.