From 0b8f443718e1ff2d1fb7662d51d51dc62bb37699 Mon Sep 17 00:00:00 2001 From: Morteza Karimi <2769101+karimi@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:51:00 -0700 Subject: [PATCH] Don't include internal members (#143) --- src/Parse/JsonBuilder.cs | 17 ++++++++++++----- src/Program.cs | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Parse/JsonBuilder.cs b/src/Parse/JsonBuilder.cs index 1d9a7ec1..58e559c4 100755 --- a/src/Parse/JsonBuilder.cs +++ b/src/Parse/JsonBuilder.cs @@ -274,16 +274,12 @@ static string WriteTypeAsObject(ParsedType type, Dictionary sb.Append(KeyValString(4, "deprecated", type.Deprecated, asJavascript)); } //Morteza: debugging only - if (type.FullName == "Rhino.Geometry.SubDToBrepOptions"){ + if (type.FullName == "Rhino.DocObjects.RhinoObject"){ var inspecting = type; } string delegates = MembersAsJsonArray(type, ParsedMemberType.Delegate, asJavascript); string values = MembersAsJsonArray(type, ParsedMemberType.EnumValue, asJavascript); string constructors = MembersAsJsonArray(type, ParsedMemberType.Constructor, asJavascript); - if (constructors==null){ - //Try to add default constructor - constructors = DefaultConstructorAsJson(type, asJavascript); - } string properties = MembersAsJsonArray(type, ParsedMemberType.Property, asJavascript); string methods = MembersAsJsonArray(type, ParsedMemberType.Method, asJavascript); string events = MembersAsJsonArray(type, ParsedMemberType.Event, asJavascript); @@ -569,6 +565,7 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool StringBuilder sb = new StringBuilder(); sb.AppendLine("["); bool memberAdded = false; + bool internalConstructorSkipped = false; foreach (var member in type.Members) { if (filter == ParsedMemberType.Property && member.MemberType == ParsedMemberType.Indexer){ @@ -578,6 +575,11 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool if (filter != member.MemberType) continue; } + if (member.IsInternal){ + if (member.MemberType == ParsedMemberType.Constructor) + internalConstructorSkipped = true; + continue; + } if (memberAdded) sb.AppendLine(","); sb.AppendLine(" {"); @@ -589,6 +591,11 @@ static string MembersAsJsonArray(ParsedType type, ParsedMemberType filter, bool sb.AppendLine(); sb.Append(" ]"); + if (!memberAdded && filter == ParsedMemberType.Constructor){ + if (!internalConstructorSkipped) + return DefaultConstructorAsJson(type, asJavascript); + } + return memberAdded ? sb.ToString() : null; } diff --git a/src/Program.cs b/src/Program.cs index c168a668..8c4d6d4c 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -93,13 +93,13 @@ static void Docify(string projDir, string examplesDir, string outputDir) } foreach (var parsedItem in parsedItems) { + if (parsedItem.Signature(false).Contains("RhinoObject()")){ + var inspecting = parsedItem; + } if (!parsedItem.ParentIsPublic) continue; - if (!parsedItem.IsPublic && !parsedItem.IsProtected) + if (!parsedItem.IsPublic && !parsedItem.IsProtected && !parsedItem.IsInternal) //We'll skip the internal members when we write the json, we need to know if a constructor is internal so we don't write default constructor continue; - if (parsedItem.Signature(false).Contains("explodeNestedInstances")){ - var inspecting = parsedItem; - } string className = parsedItem.ClassPath; if (className != null){ if (!allMembers.ContainsKey(className))