summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Lazy.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Lazy.cs')
-rw-r--r--src/mscorlib/src/System/Lazy.cs23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/mscorlib/src/System/Lazy.cs b/src/mscorlib/src/System/Lazy.cs
index 883979ef56..85cbb9816a 100644
--- a/src/mscorlib/src/System/Lazy.cs
+++ b/src/mscorlib/src/System/Lazy.cs
@@ -48,9 +48,6 @@ namespace System
/// </remarks>
[Serializable]
[ComVisible(false)]
-#if !FEATURE_CORECLR
- [HostProtection(Synchronization = true, ExternalThreading = true)]
-#endif
[DebuggerTypeProxy(typeof(System_LazyDebugView<>))]
[DebuggerDisplay("ThreadSafetyMode={Mode}, IsValueCreated={IsValueCreated}, IsValueFaulted={IsValueFaulted}, Value={ValueForDebugDisplay}")]
public class Lazy<T>
@@ -90,7 +87,7 @@ namespace System
// 2- Flag to m_threadSafeObj if ExecutionAndPublication mode and the value is known to be initialized
static readonly Func<T> ALREADY_INVOKED_SENTINEL = delegate
{
- Contract.Assert(false, "ALREADY_INVOKED_SENTINEL should never be invoked.");
+ Debug.Assert(false, "ALREADY_INVOKED_SENTINEL should never be invoked.");
return default(T);
};
@@ -207,7 +204,7 @@ namespace System
public Lazy(Func<T> valueFactory, LazyThreadSafetyMode mode)
{
if (valueFactory == null)
- throw new ArgumentNullException("valueFactory");
+ throw new ArgumentNullException(nameof(valueFactory));
m_threadSafeObj = GetObjectFromMode(mode);
m_valueFactory = valueFactory;
@@ -223,7 +220,7 @@ namespace System
else if (mode == LazyThreadSafetyMode.PublicationOnly)
return LazyHelpers.PUBLICATION_ONLY_SENTINEL;
else if (mode != LazyThreadSafetyMode.None)
- throw new ArgumentOutOfRangeException("mode", Environment.GetResourceString("Lazy_ctor_ModeInvalid"));
+ throw new ArgumentOutOfRangeException(nameof(mode), Environment.GetResourceString("Lazy_ctor_ModeInvalid"));
return null; // None mode
}
@@ -336,18 +333,12 @@ namespace System
}
LazyInternalExceptionHolder exc = m_boxed as LazyInternalExceptionHolder;
- Contract.Assert(exc != null);
+ Debug.Assert(exc != null);
exc.m_edi.Throw();
}
// Fall through to the slow path.
-#if !FEATURE_CORECLR
- // We call NOCTD to abort attempts by the debugger to funceval this property (e.g. on mouseover)
- // (the debugger proxy is the correct way to look at state/value of this object)
- Debugger.NotifyOfCrossThreadDependency();
-#endif
return LazyInitValue();
-
}
}
@@ -391,7 +382,7 @@ namespace System
if (threadSafeObj != (object)ALREADY_INVOKED_SENTINEL)
Monitor.Enter(threadSafeObj, ref lockTaken);
else
- Contract.Assert(m_boxed != null);
+ Debug.Assert(m_boxed != null);
if (m_boxed == null)
{
@@ -405,7 +396,7 @@ namespace System
if (boxed == null) // it is not Boxed, so it is a LazyInternalExceptionHolder
{
LazyInternalExceptionHolder exHolder = m_boxed as LazyInternalExceptionHolder;
- Contract.Assert(exHolder != null);
+ Debug.Assert(exHolder != null);
exHolder.m_edi.Throw();
}
}
@@ -416,7 +407,7 @@ namespace System
Monitor.Exit(threadSafeObj);
}
}
- Contract.Assert(boxed != null);
+ Debug.Assert(boxed != null);
return boxed.m_value;
}