10000 Use generic weakref instead · dotnet/wpf@99b9573 · GitHub
[go: up one dir, main page]

Skip to content

Commit 99b9573

Browse files
committed
Use generic weakref instead
1 parent e912a4e commit 99b9573

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/AssemblyNamespacePair.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ namespace System.Xaml.MS.Impl
1313
[DebuggerDisplay("{ClrNamespace} {Assembly.FullName}")]
1414
internal readonly struct AssemblyNamespacePair
1515
{
16-
private readonly WeakReference _assembly;
16+
private readonly WeakReference<Assembly> _assembly;
1717
private readonly string _clrNamespace;
1818

1919
public AssemblyNamespacePair(Assembly asm, string clrNamespace)
2020
{
21-
_assembly = new WeakReference(asm);
21+
_assembly = new WeakReference<Assembly>(asm);
2222
_clrNamespace = clrNamespace;
2323
}
2424

2525
public Assembly? Assembly
2626
{
27-
get { return (Assembly?)_assembly.Target; }
27+
get => _assembly.TryGetTarget(out Assembly? assembly) ? assembly : null;
2828
}
2929

3030
public string ClrNamespace
3131
{
32-
get { return _clrNamespace; }
32+
get => _clrNamespace;
3333
}
3434
}
3535
}

0 commit comments

Comments
 (0)
0