@@ -652,12 +652,13 @@ public static unsafe T And<T>(ref T location1, T value) where T : struct
652652 {
653653 // Only integer primitive types and enum types backed by integer types are supported.
654654 // Floating-point types and floating-point backed enums are not supported.
655- if ( ( ! typeof ( T ) . IsPrimitive && ! typeof ( T ) . IsEnum ) ||
656- ( Type . GetTypeCode ( typeof ( T ) ) == TypeCode . Single ) ||
657- ( Type . GetTypeCode ( typeof ( T ) ) == TypeCode . Double ) )
655+ if ( ! typeof ( T ) . IsPrimitive || typeof ( T ) == typeof ( float ) || typeof ( T ) == typeof ( double ) )
656+ {
657+ if ( ! typeof ( T ) . IsEnum || typeof ( T ) . GetEnumUnderlyingType ( ) == typeof ( float ) || typeof ( T ) . GetEnumUnderlyingType ( ) == typeof ( double ) )
658658 {
659659 throw new NotSupportedException ( SR . NotSupported_IntegerEnumOrPrimitiveTypeRequired ) ;
660660 }
661+ }
661662
662663 // For 1-byte and 2-byte types, we need to use CompareExchange-based implementations
663664 // because there are no direct atomic And operations for these sizes.
@@ -795,12 +796,13 @@ public static unsafe T Or<T>(ref T location1, T value) where T : struct
795796 {
796797 // Only integer primitive types and enum types backed by integer types are supported.
797798 // Floating-point types and floating-point backed enums are not supported.
798- if ( ( ! typeof ( T ) . IsPrimitive && ! typeof ( T ) . IsEnum ) ||
799- ( Type . GetTypeCode ( typeof ( T ) ) == TypeCode . Single ) ||
800- ( Type . GetTypeCode ( typeof ( T ) ) == TypeCode . Double ) )
799+ if ( ! typeof ( T ) . IsPrimitive || typeof ( T ) == typeof ( float ) || typeof ( T ) == typeof ( double ) )
800+ {
801+ if ( ! typeof ( T ) . IsEnum || typeof ( T ) . GetEnumUnderlyingType ( ) == typeof ( float ) || typeof ( T ) . GetEnumUnderlyingType ( ) == typeof ( double ) )
801802 {
802803 throw new NotSupportedException ( SR . NotSupported_IntegerEnumOrPrimitiveTypeRequired ) ;
803804 }
805+ }
804806
805807 // For 1-byte and 2-byte types, we need to use CompareExchange-based implementations
806808 // because there are no direct atomic Or operations for these sizes.
0 commit comments