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
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.9.3-beta03</Version>
<Version>9.9.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion src/BootstrapBlazor/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ private static void EnsureInitialized(this object? instance, bool isAutoInitiali
}

// Reflection performance needs to be optimized here
foreach (var propertyInfo in instance.GetType().GetProperties().Where(p => p.PropertyType.IsClass && p.PropertyType != typeof(string)))
foreach (var propertyInfo in instance.GetType().GetProperties().Where(p => p.PropertyType.IsClass
&& p.PropertyType != typeof(string)
&& p.CanWrite))
{
var type = propertyInfo.PropertyType;
var value = propertyInfo.GetValue(instance, null);
Expand Down
14 changes: 14 additions & 0 deletions test/UnitTest/Extensions/ObjectExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ public void CreateInstance_Ok()

// 接口类型不报错
Assert.Null(ObjectExtensions.CreateInstance<MockInterface>(true));

var bar = ObjectExtensions.CreateInstance<MockObject>(true);
Assert.NotNull(bar);
Assert.NotNull(bar.Foo);
Assert.Null(bar.Bar);
}

private interface MockInterface
Expand All @@ -332,6 +337,15 @@ private class MockComplexObject
public (string Name, int Count)[]? Test { get; set; }
}

private class MockObject
{
public string? Name { get; set; }

public Foo? Foo { get; set; }
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.

Copilot uses AI. Check for mistakes.

public Foo? Bar { get; }
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property references type 'Foo' which is not defined in the test file or visible imports. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
}

private class MockStatic
{
private static int _test;
Expand Down
Loading