Example #1
0
        internal static bool IsVisibleTo(Type type, Assembly accessingAssembly, XamlSchemaContext schemaContext)
        {
            TypeVisibility visibility = GetVisibility(type);

            if (visibility == TypeVisibility.NotVisible)
            {
                return(false);
            }
            if (visibility == TypeVisibility.Internal &&
                !schemaContext.AreInternalsVisibleTo(type.Assembly, accessingAssembly))
            {
                return(false);
            }
            if (type.IsGenericType)
            {
                foreach (Type typeArg in type.GetGenericArguments())
                {
                    if (!IsVisibleTo(typeArg, accessingAssembly, schemaContext))
                    {
                        return(false);
                    }
                }
            }
            else if (type.HasElementType)
            {
                return(IsVisibleTo(type.GetElementType(), accessingAssembly, schemaContext));
            }
            return(true);
        }
Example #2
0
        public TypeOptionsVM(TypeDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            this.TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            this.TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, null);
            this.DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, null);
            this.GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerService, ownerType, null);
            this.InterfaceImplsVM   = new TypeDefOrRefAndCAsVM <InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerService, ownerType, null);

            this.origOptions   = options;
            this.IsNestedType  = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
            this.TypeKind      = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
            this.TypeLayout    = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
            this.TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
            this.PackingSize   = new NullableUInt16VM(a => HasErrorUpdated());
            this.ClassSize     = new NullableUInt32VM(a => HasErrorUpdated());

            Types.TypeVisibility start, end;
            if (!IsNestedType)
            {
                start = Types.TypeVisibility.NotPublic;
                end   = Types.TypeVisibility.Public;
            }
            else
            {
                start = Types.TypeVisibility.NestedPublic;
                end   = Types.TypeVisibility.NestedFamORAssem;
            }
            for (var t = Types.TypeVisibility.NotPublic; t <= Types.TypeVisibility.NestedFamORAssem; t++)
            {
                if (t < start || t > end)
                {
                    TypeVisibility.Items.RemoveAt(TypeVisibility.GetIndex(t));
                }
            }

            InitializeTypeKind();
            this.TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
Example #3
0
        private static void LoadSharedPreferences()
        {
            s_BracesOnNewLine = EditorPrefs.GetBool("ScriptTemplates.Shared.BracesOnNewLine", false);

            s_EditorScript      = EditorPrefs.GetBool("ScriptTemplates.Shared.EditorScript", false);
            s_InitializeOnLoad  = EditorPrefs.GetBool("ScriptTemplates.Shared.InitializeOnLoad", false);
            s_StaticConstructor = EditorPrefs.GetBool("ScriptTemplates.Shared.StaticConstructor", false);

            s_TypeVisibility = (TypeVisibility)EditorPrefs.GetInt("ScriptTemplates.Shared.TypeVisibility", (int)TypeVisibility.Public);
            s_StaticClass    = EditorPrefs.GetBool("ScriptTemplates.Shared.StaticClass", false);
            s_PartialClass   = EditorPrefs.GetBool("ScriptTemplates.Shared.PartialClass", false);
        }
Example #4
0
            private void __WriteTypeVisibilitySpecifier(TypeVisibility visibility)
            {
                switch (visibility)
                {
                case TypeVisibility.Private:
                    this.WriteKeyword("private");
                    goto writespace;

                case TypeVisibility.Public:
                    this.WriteKeyword("public");
                    goto writespace;
writespace:
                    this.Write(" ");
                    break;

                case TypeVisibility.NestedPublic:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.Public, false);
                    break;

                case TypeVisibility.NestedPrivate:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.Private, false);
                    break;

                case TypeVisibility.NestedFamily:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.Protected, false);
                    break;

                case TypeVisibility.NestedAssembly:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.Internal, false);
                    break;

                case TypeVisibility.NestedFamilyAndAssembly:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.PrivateProtected, false);
                    break;

                case TypeVisibility.NestedFamilyOrAssembly:
                    this.__WriteVisibilitySpecifier(AccessSpecifier.InternalProtected, false);
                    break;
                }
            }
Example #5
0
 public Fonction (String nom, String type, TypeVisibility visibility, Boolean Static)
 {
     this.nom = nom;
     this.type = type;
     this.visibility = visibility;
 }
 private void ShowPublicTypes()
 {
     _typeVisibilityFilter = TypeVisibility.Public;
     TriggerSearch();
 }
 private void ShowInternalTypes()
 {
     _typeVisibilityFilter = TypeVisibility.Internal;
     TriggerSearch();
 }
 private void ShowAnyVisibility()
 {
     _typeVisibilityFilter = TypeVisibility.Any;
     TriggerSearch();
 }
Example #9
0
 private void ShowInternalTypes()
 {
     _typeVisibilityFilter = TypeVisibility.Internal;
     TriggerSearch();
 }
Example #10
0
 private void ShowPublicTypes()
 {
     _typeVisibilityFilter = TypeVisibility.Public;
     TriggerSearch();
 }
Example #11
0
 private void ShowAnyVisibility()
 {
     _typeVisibilityFilter = TypeVisibility.Any;
     TriggerSearch();
 }
        private static void LoadSharedPreferences()
        {
            s_BracesOnNewLine = EditorPrefs.GetBool("ScriptTemplates.Shared.BracesOnNewLine", false);

            s_EditorScript = EditorPrefs.GetBool("ScriptTemplates.Shared.EditorScript", false);
            s_InitializeOnLoad = EditorPrefs.GetBool("ScriptTemplates.Shared.InitializeOnLoad", false);
            s_StaticConstructor = EditorPrefs.GetBool("ScriptTemplates.Shared.StaticConstructor", false);

            s_TypeVisibility = (TypeVisibility)EditorPrefs.GetInt("ScriptTemplates.Shared.TypeVisibility", (int)TypeVisibility.Public);
            s_StaticClass = EditorPrefs.GetBool("ScriptTemplates.Shared.StaticClass", false);
            s_PartialClass = EditorPrefs.GetBool("ScriptTemplates.Shared.PartialClass", false);
        }
Example #13
0
        public override void Parse(CLRMetaDataParser parser)
        {
            m_childClasses = new List<CLRTypeDefRow>();
            m_implementedInterfaces = new List<CLRTableRow>();
            m_methodImpls = new List<CLRMethodImplRow>();

            GenericParameters = null;

            uint flags = parser.ReadU32();

            uint vis = flags & 0x07;
            if (vis > 0x07)
                throw new ParseFailedException("Invalid visibility");

            uint layout = flags & 0x18;
            if (layout != 0x0 && layout != 0x08 && layout != 0x10)
                throw new ParseFailedException("Invalid layout");

            uint semantics = flags & 0x20;
            if (semantics != 0 && semantics != 0x20)
                throw new ParseFailedException("Invalid semantics");

            Visibility = (TypeVisibility)vis;
            ClassLayout = (TypeClassLayout)layout;
            Semantics = (TypeSemantics)semantics;
            IsAbstract = (flags & 0x80) != 0;
            IsSealed = (flags & 0x100) != 0;
            IsSpecialName = (flags & 0x400) != 0;
            IsImported = (flags & 0x1000) != 0;
            IsSerializable = (flags & 0x2000) != 0;
            StringFormat = (TypeStringFormat)(flags & 0x30000);
            CustomStringFormat = (byte)((flags & 0xc00000) >> 22);
            IsBeforeFieldInit = (flags & 0x100000) != 0;
            IsRTSpecialName = (flags & 0x800) != 0;
            HasSecurity = (flags & 0x40000) != 0;
            IsTypeForwarder = (flags & 0x200000) != 0;

            TypeName = parser.ReadString();
            TypeNamespace = parser.ReadString();
            Extends = parser.ReadTypeDefOrRefOrSpec();
            m_firstField = parser.ReadTableRawRow(CLRMetaDataTables.TableIndex.Field);
            m_firstMethodDef = parser.ReadTableRawRow(CLRMetaDataTables.TableIndex.MethodDef);

            if (m_firstField == 0 || m_firstMethodDef == 0)
                throw new ParseFailedException("Invalid method/field def span");
        }
 public void WriteTypeVisibility(TypeVisibility visibility, IFormatter formatter)
 {
     switch (visibility)
     {
         case TypeVisibility.Public: formatter.WriteKeyword("public"); break;
         case TypeVisibility.NestedPublic: formatter.WriteKeyword("public"); break;
         case TypeVisibility.Private: formatter.WriteKeyword("strict private"); break;
         case TypeVisibility.NestedAssembly: formatter.WriteKeyword("private"); break;
         case TypeVisibility.NestedPrivate: formatter.WriteKeyword("strict private"); break;
         case TypeVisibility.NestedFamily: formatter.WriteKeyword("strict protected"); break;
         case TypeVisibility.NestedFamilyAndAssembly: formatter.WriteKeyword("protected"); break;
         case TypeVisibility.NestedFamilyOrAssembly: formatter.WriteKeyword("protected");
             formatter.Write(" ");
             formatter.WriteComment("{internal}"); break;
         default: throw new NotSupportedException();
     }
     formatter.Write(" ");
 }