src/Shared/EntityFramework/Core/SchemaObjectModel/SchemaEnumType.cs
// <summary>
// Validates the specified enumeration type as a whole.
// </summary>
Validates the specified enumeration type as a whole.
Validates the specified enumeration type as a whole .
internal override void Validate()
        {
            base.Validate();
            var enumUnderlyingType = UnderlyingType as ScalarType;
            if (enumUnderlyingType == null
                || !Helper.IsSupportedEnumUnderlyingType(enumUnderlyingType.TypeKind))
            {
                AddError(
                    ErrorCode.InvalidEnumUnderlyingType,
                    EdmSchemaErrorSeverity.Error,
                    Strings.InvalidEnumUnderlyingType);
            }
            else
            {
                Debug.Assert(!_enumMembers.Any(m => !m.Value.HasValue), "member values should have been fixed up already.");
                var invalidEnumMembers = _enumMembers
                    .Where(m => !Helper.IsEnumMemberValueInRange(enumUnderlyingType.TypeKind, (long)m.Value));
                foreach (var invalidEnumMember in invalidEnumMembers)
                {
                    invalidEnumMember.AddError(
                        ErrorCode.EnumMemberValueOutOfItsUnderylingTypeRange,
                        EdmSchemaErrorSeverity.Error,
                        Strings.EnumMemberValueOutOfItsUnderylingTypeRange(
                            invalidEnumMember.Value, invalidEnumMember.Name, UnderlyingType.Name));
                }
            }
            if (_enumMembers.GroupBy(o => o.Name).Where(g => g.Count() > 1).Any())
            {
                AddError(
                    ErrorCode.DuplicateEnumMember,
                    EdmSchemaErrorSeverity.Error,
                    Strings.DuplicateEnumMember);
            }
        }
internal override void Validate ( ) { base . Validate ( ) ; var enumUnderlyingType = UnderlyingType as ScalarType ; if ( enumUnderlyingType == null || ! Helper . IsSupportedEnumUnderlyingType ( enumUnderlyingType . TypeKind ) ) { AddError ( ErrorCode . InvalidEnumUnderlyingType , EdmSchemaErrorSeverity . Error , Strings . InvalidEnumUnderlyingType ) ; } else { Debug . Assert ( ! _enumMembers . Any ( m => ! m . Value . HasValue ) , " " ) ; var invalidEnumMembers = _enumMembers . Where ( m => ! Helper . IsEnumMemberValueInRange ( enumUnderlyingType . TypeKind , ( long ) m . Value ) ) ; foreach ( var invalidEnumMember in invalidEnumMembers ) { invalidEnumMember . AddError ( ErrorCode . EnumMemberValueOutOfItsUnderylingTypeRange , EdmSchemaErrorSeverity . Error , Strings . EnumMemberValueOutOfItsUnderylingTypeRange ( invalidEnumMember . Value , invalidEnumMember . Name , UnderlyingType . Name ) ) ; } } if ( _enumMembers . GroupBy ( o => o . Name ) . Where ( g => g . Count ( ) > 1 ) . Any ( ) ) { AddError ( ErrorCode . DuplicateEnumMember , EdmSchemaErrorSeverity . Error , Strings . DuplicateEnumMember ) ; } }
Validates the specified enumeration type as a whole.
Validates the specified enumeration type as a whole .
// Check for underflows and overflows // Check for duplicate enumeration members.