Last active
January 27, 2020 11:14
-
-
Save controlflow/b3d64eca9568b78574f3cf01cc53a8aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var argumentType = typeofExpression.ArgumentType; | |
if (!(argumentType is IDeclaredType declaredType) | |
|| declaredType.IsVoid() | |
|| declaredType is IDynamicType) return null; | |
var typeElement = declaredType.GetTypeElement(); | |
if (typeElement is ITypeParameter) return null; | |
return typeElement?.TypeParameters.Count == 0 ? typeElement : null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var argumentType = typeofExpression.ArgumentType as IDeclaredType; | |
if (argumentType == null | |
|| argumentType.IsVoid() | |
|| argumentType is IDynamicType) return null; | |
var typeElement = argumentType.GetTypeElement(); | |
if (typeElement == null | |
|| typeElement is ITypeParameter | |
|| typeElement.TypeParameters.Count > 0) return null; | |
return typeElement; // bingo! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment