--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System
+{
+ //
+ // This simple class enables one to throw a NotImplementedException using the following
+ // idiom:
+ //
+ // throw NotImplemented.ByDesign;
+ //
+ // Used by methods whose intended implementation is to throw a NotImplementedException (typically
+ // virtual methods in public abstract classes that intended to be subclassed by third parties.)
+ //
+ // This makes it distinguishable both from human eyes and CCI from NYI's that truly represent undone work.
+ //
+ internal static class NotImplemented
+ {
+ internal static Exception ByDesign
+ {
+ get
+ {
+ return new NotImplementedException();
+ }
+ }
+
+ internal static Exception ByDesignWithMessage(string message)
+ {
+ return new NotImplementedException(message);
+ }
+ }
+}
+
<Compile Include="$(BclSourcesRoot)\System\Reflection\MdConstant.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MdImport.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MemberFilter.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Reflection\MemberInfo.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Reflection\MemberInfo.Internal.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MemberInfoSerializationHolder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MemberTypes.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MethodAttributes.cs" />
<!-- These are files are preprocessed -->
<Compile Include="$(CommonPath)\Preprocessed\AssemblyRefs.g.cs" />
<!-- These files are shared with other framework components and don't live the same folder as the rest of them-->
+ <Compile Include="$(CommonPath)\NotImplemented.cs" />
<Compile Include="$(CommonPath)\PinnableBufferCache.cs" />
<!-- Include Internals visible to file in the compilation -->
<Compile Include="$(BclSourcesRoot)\mscorlib.Friends.cs" />
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//
-
-using System;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
-using System.Runtime;
-using System.Runtime.InteropServices;
namespace System.Reflection
{
- [Serializable]
- public abstract class MemberInfo : ICustomAttributeProvider
+ public abstract partial class MemberInfo : ICustomAttributeProvider
{
- #region Constructor
protected MemberInfo() { }
- #endregion
-
- #region Internal Methods
- internal virtual bool CacheEquals(object o) { throw new NotImplementedException(); }
- #endregion
- #region Public Abstract\Virtual Members
public abstract MemberTypes MemberType { get; }
-
- public abstract String Name { get; }
-
+ public abstract string Name { get; }
public abstract Type DeclaringType { get; }
-
public abstract Type ReflectedType { get; }
- public virtual IEnumerable<CustomAttributeData> CustomAttributes
+ public virtual Module Module
{
get
{
- return GetCustomAttributesData();
+ // This check is necessary because for some reason, Type adds a new "Module" property that hides the inherited one instead
+ // of overriding.
+
+ Type type = this as Type;
+ if (type != null)
+ return type.Module;
+
+ throw NotImplemented.ByDesign;
}
}
- public abstract Object[] GetCustomAttributes(bool inherit);
-
- public abstract Object[] GetCustomAttributes(Type attributeType, bool inherit);
public abstract bool IsDefined(Type attributeType, bool inherit);
+ public abstract object[] GetCustomAttributes(bool inherit);
+ public abstract object[] GetCustomAttributes(Type attributeType, bool inherit);
- public virtual IList<CustomAttributeData> GetCustomAttributesData()
- {
- throw new NotImplementedException();
- }
+ public virtual IEnumerable<CustomAttributeData> CustomAttributes => GetCustomAttributesData();
+ public virtual IList<CustomAttributeData> GetCustomAttributesData() { throw NotImplemented.ByDesign; }
public virtual int MetadataToken { get { throw new InvalidOperationException(); } }
- public virtual Module Module
- {
- get
- {
- if (this is Type)
- return ((Type)this).Module;
-
- throw new NotImplementedException();
- }
- }
-
-
-
- #endregion
+ public override bool Equals(object obj) => base.Equals(obj);
+ public override int GetHashCode() => base.GetHashCode();
public static bool operator ==(MemberInfo left, MemberInfo right)
{
- if (ReferenceEquals(left, right))
+ if (object.ReferenceEquals(left, right))
return true;
if ((object)left == null || (object)right == null)
return false;
}
- public static bool operator !=(MemberInfo left, MemberInfo right)
- {
- return !(left == right);
- }
-
- public override bool Equals(object obj)
- {
- return base.Equals(obj);
- }
-
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
+ public static bool operator !=(MemberInfo left, MemberInfo right) => !(left == right);
}
}