Skip to content

Commit

Permalink
Fix minor AOT warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamescaper committed Nov 6, 2024
1 parent 6654b4c commit f37b8f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
14 changes: 7 additions & 7 deletions samples/StylingSample/StylingSample.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net8.0-tizen</TargetFrameworks> -->
<!-- <TargetFrameworks>$(TargetFrameworks);net9.0-tizen</TargetFrameworks> -->

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
Expand Down Expand Up @@ -62,10 +62,10 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui.Markup" Version="4.2.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.92" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.92" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.92" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.0-rc.2.24503.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0-rc.2.24473.5" />
</ItemGroup>

</Project>
23 changes: 10 additions & 13 deletions src/BlazorBindings.Core/NativeComponentAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

using Microsoft.AspNetCore.Components.RenderTree;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace BlazorBindings.Core;

/// <summary>
/// Represents a "shadow" item that Blazor uses to map changes into the live native UI tree.
/// </summary>
[DebuggerDisplay("{DebugName}")]
[DebuggerDisplay("{GetDebugName}")]
internal sealed class NativeComponentAdapter : IDisposable
{
public NativeComponentAdapter(NativeComponentRenderer renderer, NativeComponentAdapter closestPhysicalParent, IElementHandler knownTargetElement = null)
Expand All @@ -25,22 +26,18 @@ public NativeComponentAdapter(NativeComponentRenderer renderer, NativeComponentA
/// </summary>
public string Name { get; internal set; }

private string Text
[RequiresUnreferencedCode("This method is used for debug only.")]
private string GetDebugName()
{
get
string text = null;
try
{
try
{
return (_targetElement?.TargetElement as dynamic)?.Text;
}
catch
{
return null;
}
text = (_targetElement?.TargetElement as dynamic)?.Text;
}
}
catch { }

private string DebugName => $"[\"{Text}\" {Name}";
return $"[\"{text}\" {Name}";
}

public int DeepLevel { get; init; }

Expand Down

0 comments on commit f37b8f8

Please sign in to comment.