@@ -118,6 +118,7 @@ public static bool IsInstanceOf(this Type type, Type thisOrBaseType)
118118
119119 type = type . BaseType ( ) ;
120120 }
121+
121122 return false ;
122123 }
123124
@@ -1185,7 +1186,6 @@ public static Type AddAttributes(this Type type, params Attribute[] attrs)
11851186 }
11861187
11871188 typeAttrs . AddRange ( attrs ) ;
1188-
11891189 return type ;
11901190 }
11911191
@@ -1342,17 +1342,24 @@ public static object[] AllAttributes(this FieldInfo fieldInfo, Type attrType)
13421342
13431343 public static object [ ] AllAttributes ( this Type type )
13441344 {
1345- #if ( NETFX_CORE || PCL || NETSTANDARD )
1345+ #if ( NETFX_CORE || PCL )
13461346 return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . ToArray ( ) ;
1347+ #elif NETSTANDARD
1348+ return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . Union ( type . GetRuntimeAttributes ( ) ) . ToArray ( ) ;
13471349#else
13481350 return type . GetCustomAttributes ( true ) . Union ( type . GetRuntimeAttributes ( ) ) . ToArray ( ) ;
13491351#endif
13501352 }
13511353
13521354 public static object [ ] AllAttributes ( this Type type , Type attrType )
13531355 {
1354- #if ( NETFX_CORE || PCL || NETSTANDARD )
1355- return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . Where ( x => attrType . IsInstanceOf ( x . GetType ( ) ) ) . ToArray ( ) ;
1356+ #if ( NETFX_CORE || PCL )
1357+ return type . GetTypeInfo ( ) . GetCustomAttributes ( true ) . Where ( x => x . GetType ( ) . IsInstanceOf ( attrType ) ) . ToArray ( ) ;
1358+ #elif NETSTANDARD
1359+ return type . GetTypeInfo ( ) . GetCustomAttributes ( true )
1360+ . Where ( x => x . GetType ( ) . IsInstanceOf ( attrType ) )
1361+ . Union ( type . GetRuntimeAttributes ( ) )
1362+ . ToArray ( ) ;
13561363#else
13571364 return type . GetCustomAttributes ( true ) . Union ( type . GetRuntimeAttributes ( ) ) . ToArray ( ) ;
13581365#endif
@@ -1408,8 +1415,12 @@ public static TAttr[] AllAttributes<TAttr>(this Type type)
14081415 where TAttr : Attribute
14091416#endif
14101417 {
1411- #if ( NETFX_CORE || PCL || NETSTANDARD )
1418+ #if ( NETFX_CORE || PCL )
14121419 return type . GetTypeInfo ( ) . GetCustomAttributes < TAttr > ( true ) . ToArray( ) ;
1420+ #elif NETSTANDARD
1421+ return type . GetTypeInfo ( ) . GetCustomAttributes < TAttr > ( true )
1422+ . Union( type . GetRuntimeAttributes < TAttr > ( ) )
1423+ . ToArray ( ) ;
14131424#else
14141425 return type. GetCustomAttributes ( typeof ( TAttr ) , true )
14151426 . OfType < TAttr > ( )
0 commit comments