Add linker annotation to LazyDebugView to avoid warnings (#39899)
authorVitek Karas <vitek.karas@microsoft.com>
Sat, 25 Jul 2020 18:11:14 +0000 (11:11 -0700)
committerGitHub <noreply@github.com>
Sat, 25 Jul 2020 18:11:14 +0000 (11:11 -0700)
In reality this is only to get rid of the warnings, the class is never instatiated by the managed code, so the annotation has no effect on including more code.
When in debugger the class is instatiated with the same T of an existing Lazy<T> which has the same annotation, so the T will always fulfill the annotation's requirements.

src/libraries/System.Private.CoreLib/src/System/Lazy.cs

index 918682f..4fcfbc9 100644 (file)
@@ -508,7 +508,7 @@ namespace System
 
     /// <summary>A debugger view of the Lazy&lt;T&gt; to surface additional debugging properties and
     /// to ensure that the Lazy&lt;T&gt; does not become initialized if it was not already.</summary>
-    internal sealed class LazyDebugView<T>
+    internal sealed class LazyDebugView<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] T>
     {
         // The Lazy object being viewed.
         private readonly Lazy<T> _lazy;