Hide public methods

Hi there.
I have a library with several classes written in it that I use as interoperability class to exchange data between several software.

I am now trying to use the same .cs within Dynamo but I am not able to hide the public method.

public partial class Vehicle_lib_type
    {

        private System.Collections.Generic.List<Caseless_point_load_type> point_loadField;

        private System.Collections.Generic.List<Caseless_line_load_type> line_loadField;

        private System.Collections.Generic.List<Caseless_surface_load_type> surface_loadField;

        private string nameField;

        private System.Collections.Generic.List<System.Xml.XmlAttribute> anyAttrField;

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("point_load")]
        public System.Collections.Generic.List<Caseless_point_load_type> Point_load
        {
            get
            {
                return this.point_loadField;
            }
            set
            {
                this.point_loadField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("line_load")]
        public System.Collections.Generic.List<Caseless_line_load_type> Line_load
        {
            get
            {
                return this.line_loadField;
            }
            set
            {
                this.line_loadField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("surface_load")]
        public System.Collections.Generic.List<Caseless_surface_load_type> Surface_load
        {
            get
            {
                return this.surface_loadField;
            }
            set
            {
                this.surface_loadField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAttributeAttribute(AttributeName = "name")]
        public string Name
        {
            get
            {
                return this.nameField;
            }
            set
            {
                this.nameField = value;
            }
        }

        /// <remarks/>
        [System.Xml.Serialization.XmlAnyAttributeAttribute()]
        public System.Collections.Generic.List<System.Xml.XmlAttribute> AnyAttr
        {
            get
            {
                return this.anyAttrField;
            }
            set
            {
                this.anyAttrField = value;
            }
        }
    }

The interoperability file should not be touch if possible because also use for other software such as Rhino/Grasshopper.
Can you advise some solution?

What I am trying to do, it is to create a different .cs file for dynamo where I try to extend the class (reason why I am using partial class)
The main idea is to hide all the public methods in the core.cs file in order to don’t create confusion for the user.

2 Likes

You could make the class internal, if that is no problem for other projects.

Else, if you add the cs files ‘as link’ to your projects, you can add the attribute Michael mentioned. And you can work with conditional compilation symbols. F.i. “PROJECTISDYNAMO”:

#if PROJECTISDYNAMO
  [IsVisibleInDynamoLibrary(false)]
#endif
  public partial class Vehicle_lib_type {}

This way you can use the cs files in any project, even those that does not recognize the attributes.

Btw, it seems the class is still visible in DesignScript, it might help to use the attribute

[SupressImportIntoVM]

Maybe you can search for that to find more information about this issue.