public static IEnumerable <IDeclaredElement> GetGeneratedMembers([NotNull] this IUnionCase unionCase)
        {
            if (!(unionCase.GetContainingType().GetPart <IUnionPart>() is { } unionPart))
            {
                return(EmptyList <IDeclaredElement> .Instance);
            }

            if (unionPart.IsSingleCase && !unionCase.HasFields)
            {
                return(EmptyList <IDeclaredElement> .Instance);
            }

            var result = new List <IDeclaredElement>();

            if (unionCase.HasFields)
            {
                result.Add(new FSharpUnionCaseNewMethod(unionCase));

                if (unionCase.NestedType is { } nestedType)
                {
                    result.Add(nestedType);
                }
            }

            if (unionPart.IsSingleCase)
            {
                return(result);
            }

            result.Add(new FSharpUnionCaseIsCaseProperty(unionCase));
            result.Add(new FSharpUnionCaseTag(unionCase));

            return(result);
        }
        public static IEnumerable <IDeclaredElement> GetGeneratedMembers([NotNull] this IUnionCase unionCase)
        {
            if (!(unionCase.GetContainingType().GetUnionPart() is IUnionPart unionPart))
            {
                return(EmptyList <IDeclaredElement> .Instance);
            }

            if (unionPart.IsSingleCaseUnion && unionCase is FSharpUnionCaseProperty)
            {
                return(EmptyList <IDeclaredElement> .Instance);
            }

            var result = new List <IDeclaredElement>();

            if (unionCase is FSharpNestedTypeUnionCase)
            {
                result.Add(new NewUnionCaseMethod(unionCase));
            }

            if (unionPart.IsSingleCaseUnion)
            {
                return(result);
            }

            result.Add(new IsUnionCaseProperty(unionCase));
            result.Add(new UnionCaseTag(unionCase));

            return(result);
        }
示例#3
0
 private static IEnumerable <RelatedDeclaredElement> GetUnionCaseRelatedElements([NotNull] IUnionCase unionCase) =>
 unionCase.GetGeneratedMembers().Select(member => new RelatedDeclaredElement(member));
示例#4
0
 public NewUnionCaseMethod([NotNull] IUnionCase unionCase) =>
示例#5
0
 public FSharpUnionCaseNewMethod([NotNull] IUnionCase unionCase) =>
 public FSharpUnionCaseTag(IUnionCase unionCase) =>
 internal IsUnionCaseProperty([NotNull] IUnionCase unionCase) =>
示例#8
0
 internal FSharpUnionCaseIsCaseProperty([NotNull] IUnionCase unionCase) =>
示例#9
0
 public UnionCaseTag(IUnionCase unionCase) =>