Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspicious logic in TypeSymbolExtensions.IsValidEnumType #72317

Open
AlekseyTs opened this issue Feb 28, 2024 · 0 comments
Open

Suspicious logic in TypeSymbolExtensions.IsValidEnumType #72317

AlekseyTs opened this issue Feb 28, 2024 · 0 comments
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@AlekseyTs
Copy link
Contributor

        public static bool IsValidEnumType(this TypeSymbol type)
        {
            var underlyingType = type.GetEnumUnderlyingType();
            // SpecialType will be None if the underlying type is invalid.
            return (underlyingType is object) && (underlyingType.SpecialType != SpecialType.None);
        }

The underlyingType.SpecialType != SpecialType.None logic looks questionable, in fact we have a SpecialType extension called IsValidEnumUnderlyingType, which we probably should use instead.

@AlekseyTs AlekseyTs added Concept-API This issue involves adding, removing, clarification, or modification of an API. Area-Compilers labels Feb 28, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Concept-API This issue involves adding, removing, clarification, or modification of an API. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant