From 87b73a852a54a59ec036bf820f8b102a3d224245 Mon Sep 17 00:00:00 2001 From: Jon Hanna Date: Sat, 11 Mar 2017 00:13:27 +0000 Subject: [PATCH] Rename Type.IsSzArray to Type.IsSZArray and make public. For dotnet/corefxdotnet/coreclr#16566 Commit migrated from https://github.com/dotnet/coreclr/commit/20dec603e09c00cc3e323c7a8bfedb9f652be5b4 --- .../src/mscorlib/shared/System/Reflection/TypeDelegator.cs | 2 ++ .../src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs | 2 +- .../src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs | 2 ++ .../src/System/Reflection/Emit/GenericTypeParameterBuilder.cs | 2 ++ .../mscorlib/src/System/Reflection/Emit/SignatureHelper.cs | 2 +- .../src/mscorlib/src/System/Reflection/Emit/SymbolType.cs | 11 +---------- .../src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs | 2 ++ .../src/System/Reflection/Emit/TypeBuilderInstantiation.cs | 3 +++ src/coreclr/src/mscorlib/src/System/RtType.cs | 8 ++++---- src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs | 2 +- src/coreclr/src/mscorlib/src/System/Type.cs | 4 ++-- .../src/mscorlib/src/System/UnitySerializationHolder.cs | 2 +- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/coreclr/src/mscorlib/shared/System/Reflection/TypeDelegator.cs b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeDelegator.cs index 7044126..7f928d24 100644 --- a/src/coreclr/src/mscorlib/shared/System/Reflection/TypeDelegator.cs +++ b/src/coreclr/src/mscorlib/shared/System/Reflection/TypeDelegator.cs @@ -100,6 +100,8 @@ namespace System.Reflection protected override TypeAttributes GetAttributeFlagsImpl() => typeImpl.Attributes; + public override bool IsSZArray => typeImpl.IsSZArray; + protected override bool IsArrayImpl() => typeImpl.IsArray; protected override bool IsPrimitiveImpl() => typeImpl.IsPrimitive; protected override bool IsByRefImpl() => typeImpl.IsByRef; diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs index 6d77843..e7499e5 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/AQNBuilder.cs @@ -107,7 +107,7 @@ namespace System.Reflection.Emit else if (elementType.IsByRef) AddByRef(); - else if (elementType.IsSzArray) + else if (elementType.IsSZArray) AddSzArray(); else if (elementType.IsArray) diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs index 88b85e5..aae90c2 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs @@ -242,6 +242,8 @@ namespace System.Reflection.Emit return m_typeBuilder.Attributes; } + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index 475a4a5..4538988 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -154,6 +154,8 @@ namespace System.Reflection.Emit protected override TypeAttributes GetAttributeFlagsImpl() { return TypeAttributes.Public; } + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; } protected override bool IsByRefImpl() { return false; } diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs index 6e1429b..eb5df8c 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs @@ -425,7 +425,7 @@ namespace System.Reflection.Emit } else if (clsArgument.IsArray) { - if (clsArgument.IsSzArray) + if (clsArgument.IsSZArray) { AddElementType(CorElementType.SzArray); diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs index 470d69f..bfe9ce0 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs @@ -271,16 +271,7 @@ namespace System.Reflection.Emit #endregion #region Type Overrides - internal override bool IsSzArray - { - get - { - if (m_cRank > 1) - return false; - - return m_isSzArray; - } - } + public override bool IsSZArray => m_cRank <= 1 && m_isSzArray; public override Type MakePointerType() { diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs index ed821d8..b4cba17 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs @@ -1109,6 +1109,8 @@ namespace System.Reflection.Emit return m_iAttr; } + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; diff --git a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index f47f0af..06d8384 100644 --- a/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/coreclr/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -188,6 +188,9 @@ namespace System.Reflection.Emit public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { throw new NotSupportedException(); } protected override TypeAttributes GetAttributeFlagsImpl() { return m_type.Attributes; } + + public override bool IsSZArray => false; + protected override bool IsArrayImpl() { return false; } protected override bool IsByRefImpl() { return false; } protected override bool IsPointerImpl() { return false; } diff --git a/src/coreclr/src/mscorlib/src/System/RtType.cs b/src/coreclr/src/mscorlib/src/System/RtType.cs index 9bdeab0..9a3d9ab 100644 --- a/src/coreclr/src/mscorlib/src/System/RtType.cs +++ b/src/coreclr/src/mscorlib/src/System/RtType.cs @@ -1012,7 +1012,7 @@ namespace System } } - if (ReflectedType.IsSzArray) + if (ReflectedType.IsSZArray) { RuntimeType arrayType = (RuntimeType)ReflectedType.GetElementType(); @@ -2750,7 +2750,7 @@ namespace System // SZArrays implement the methods on IList`1, IEnumerable`1, and ICollection`1 with // SZArrayHelper and some runtime magic. We don't have accurate interface maps for them. - if (IsSzArray && ifaceType.IsGenericType) + if (IsSZArray && ifaceType.IsGenericType) throw new ArgumentException(Environment.GetResourceString("Argument_ArrayGetInterfaceMap")); int ifaceInstanceMethodCount = RuntimeTypeHandle.GetNumVirtuals(ifaceRtType); @@ -3542,11 +3542,11 @@ namespace System #endregion #region Arrays - internal override bool IsSzArray + public sealed override bool IsSZArray { get { - return RuntimeTypeHandle.IsSzArray(this); + return RuntimeTypeHandle.IsSZArray(this); } } diff --git a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs index d343de4..dcf8cd6 100644 --- a/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs +++ b/src/coreclr/src/mscorlib/src/System/RuntimeHandles.cs @@ -153,7 +153,7 @@ namespace System return (corElemType == CorElementType.Array || corElemType == CorElementType.SzArray); } - internal static bool IsSzArray(RuntimeType type) + internal static bool IsSZArray(RuntimeType type) { CorElementType corElemType = GetCorElementType(type); return (corElemType == CorElementType.SzArray); diff --git a/src/coreclr/src/mscorlib/src/System/Type.cs b/src/coreclr/src/mscorlib/src/System/Type.cs index 795a42f..cb6c9ab 100644 --- a/src/coreclr/src/mscorlib/src/System/Type.cs +++ b/src/coreclr/src/mscorlib/src/System/Type.cs @@ -1182,10 +1182,10 @@ namespace System get { return IsArrayImpl(); } } - internal virtual bool IsSzArray + public virtual bool IsSZArray { [Pure] - get { return false; } + get { throw new NotImplementedException(); } } public virtual bool IsGenericType diff --git a/src/coreclr/src/mscorlib/src/System/UnitySerializationHolder.cs b/src/coreclr/src/mscorlib/src/System/UnitySerializationHolder.cs index f343cf6..038b9b0 100644 --- a/src/coreclr/src/mscorlib/src/System/UnitySerializationHolder.cs +++ b/src/coreclr/src/mscorlib/src/System/UnitySerializationHolder.cs @@ -45,7 +45,7 @@ namespace System List elementTypes = new List(); while (type.HasElementType) { - if (type.IsSzArray) + if (type.IsSZArray) { elementTypes.Add(SzArray); } -- 2.7.4