Beispiel #1
0
 public static AccessRights GetFSharpRepresentationAccessRights([NotNull] this TypeElement typeElement)
 {
     foreach (var part in typeElement.EnumerateParts())
     {
         if (part is IRepresentationAccessRightsOwner accessRightsOwner)
         {
             return(accessRightsOwner.RepresentationAccessRights);
         }
     }
     return(AccessRights.PUBLIC);
 }
Beispiel #2
0
 public static bool IsUnion([NotNull] this TypeElement typeElement)
 {
     foreach (var part in typeElement.EnumerateParts())
     {
         if (part is IUnionPart)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #3
0
        public static string GetSourceName([NotNull] this TypeElement typeElement)
        {
            foreach (var part in typeElement.EnumerateParts())
            {
                if (part is IFSharpTypePart fsTypePart)
                {
                    return(fsTypePart.SourceName);
                }
            }

            return(typeElement.ShortName);
        }
Beispiel #4
0
        public static bool IsUnionWithPublicNestedTypes([NotNull] this TypeElement typeElement)
        {
            foreach (var part in typeElement.EnumerateParts())
            {
                if (part is IUnionPart unionPart && unionPart.HasPublicNestedTypes)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #5
0
        public static bool IsCliMutableRecord([NotNull] this TypeElement typeElement)
        {
            // todo: climutable attr can be on anon part (`type R`)
            foreach (var part in typeElement.EnumerateParts())
            {
                if (part is IRecordPart recordPart && recordPart.CliMutable)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #6
0
        public static AccessRights GetRepresentationAccessRights([NotNull] this TypeElement typeElement)
        {
            foreach (var part in typeElement.EnumerateParts())
            {
                switch (part)
                {
                case IUnionPart unionPart:
                    if (unionPart.RepresentationAccessRights != AccessRights.PUBLIC)
                    {
                        return(AccessRights.INTERNAL);
                    }
                    break;

                case UnionCasePart casePart:
                    if (casePart.Parent is IUnionPart parent && parent.RepresentationAccessRights != AccessRights.PUBLIC)
                    {
                        return(AccessRights.INTERNAL);
                    }
                    break;
                }
            }

            return(AccessRights.PUBLIC);
        }