Ejemplo n.º 1
0
        public static ICollection <ISymbol> GetMissingEnumMembers(ISwitchExpressionOperation operation)
        {
            var switchExpression     = operation.Value;
            var switchExpressionType = switchExpression?.Type;

            var enumMembers = new Dictionary <long, ISymbol>();

            // Check if the type of the expression is a nullable INamedTypeSymbol
            // if the type is both nullable and an INamedTypeSymbol extract the type argument from the nullable
            // and check if it is of enum type
            if (switchExpressionType != null)
            {
                switchExpressionType = switchExpressionType.IsNullable(out var underlyingType) ? underlyingType : switchExpressionType;
            }

            if (switchExpressionType?.TypeKind == TypeKind.Enum)
            {
                if (!PopulateSwitchStatementHelpers.TryGetAllEnumMembers(switchExpressionType, enumMembers) ||
                    !TryRemoveExistingEnumMembers(operation, enumMembers))
                {
                    return(SpecializedCollections.EmptyCollection <ISymbol>());
                }
            }

            return(enumMembers.Values);
        }
        public static ICollection <ISymbol> GetMissingEnumMembers(ISwitchExpressionOperation operation)
        {
            var switchExpression     = operation.Value;
            var switchExpressionType = switchExpression?.Type;

            var enumMembers = new Dictionary <long, ISymbol>();

            if (switchExpressionType?.TypeKind == TypeKind.Enum)
            {
                if (!PopulateSwitchStatementHelpers.TryGetAllEnumMembers(switchExpressionType, enumMembers) ||
                    !TryRemoveExistingEnumMembers(operation, enumMembers))
                {
                    return(SpecializedCollections.EmptyCollection <ISymbol>());
                }
            }

            return(enumMembers.Values);
        }
 protected sealed override ICollection <ISymbol> GetMissingEnumMembers(ISwitchOperation switchOperation)
 => PopulateSwitchStatementHelpers.GetMissingEnumMembers(switchOperation);
Ejemplo n.º 4
0
 protected sealed override bool HasDefaultCase(ISwitchOperation operation) =>
 PopulateSwitchStatementHelpers.HasDefaultCase(operation);
Ejemplo n.º 5
0
 protected sealed override bool HasNullSwitchArm(ISwitchOperation switchOperation)
 => PopulateSwitchStatementHelpers.HasNullSwitchArm(switchOperation);