Created
February 14, 2019 21:32
-
-
Save controlflow/f01b163a67e092dc7daa2b65cc115d41 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
| [Pure, ContractAnnotation("null => false")] | |
| public static bool IsValueTuple([CanBeNull] this ITypeElement typeElement) | |
| { | |
| var structType = typeElement as IStruct; | |
| if (structType == null) return false; | |
| return typeElement.ShortName == "ValueTuple" | |
| && typeElement.GetContainingNamespace() is INamespace ns | |
| && ns.ShortName == "System" | |
| && ns.GetContainingNamespace() is INamespace root | |
| && root.IsRootNamespace; | |
| } |
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
| [Pure, ContractAnnotation("null => false")] | |
| public static bool IsValueTuple([CanBeNull] this ITypeElement typeElement) | |
| { | |
| return typeElement is IStruct { ShortName: "ValueTuple" } | |
| && typeElement.GetContainingNamespace() is { ShortName: "System" } ns | |
| && ns.GetContainingNamespace() is { IsRootNamespace: true }; | |
| } |
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
| [Pure, ContractAnnotation("null => false")] | |
| public static bool IsValueTuple([CanBeNull] this ITypeElement typeElement) | |
| { | |
| return typeElement is IStruct { | |
| ShortName: "ValueTuple", | |
| ContainingNamespace: { | |
| ShortName: "System", | |
| ContainingNamespace: { IsRootNamespace: true } | |
| } | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment