Example #1
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;
            }
            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

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

            origOptions   = options;
            IsNestedType  = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
            TypeKind      = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
            TypeLayout    = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
            TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
            PackingSize   = new NullableUInt16VM(a => HasErrorUpdated());
            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();
            TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
Example #2
0
 void InitializeFrom(MethodDefOptions options)
 {
     ImplAttributes            = options.ImplAttributes;
     Attributes                = options.Attributes;
     Name                      = options.Name;
     MethodSig                 = options.MethodSig;
     ImplMap                   = options.ImplMap;
     CodeType.SelectedItem     = (Method.CodeType)((int)(options.ImplAttributes & MethodImplAttributes.CodeTypeMask) >> 0);
     ManagedType.SelectedItem  = (Method.ManagedType)((int)(options.ImplAttributes & MethodImplAttributes.ManagedMask) >> 2);
     MethodAccess.SelectedItem = (Method.MethodAccess)((int)(options.Attributes & MethodAttributes.MemberAccessMask) >> 0);
     VtableLayout.SelectedItem = (Method.VtableLayout)((int)(options.Attributes & MethodAttributes.VtableLayoutMask) >> 8);
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
     DeclSecuritiesVM.InitializeFrom(options.DeclSecurities);
     ParamDefsVM.InitializeFrom(options.ParamDefs);
     GenericParamsVM.InitializeFrom(options.GenericParameters);
     MethodOverridesVM.InitializeFrom(options.Overrides);
 }
Example #3
0
 void InitializeFrom(TypeDefOptions options)
 {
     Attributes                    = options.Attributes;
     Namespace                     = options.Namespace;
     Name                          = options.Name;
     PackingSize.Value             = options.PackingSize;
     ClassSize.Value               = options.ClassSize;
     BaseTypeSig                   = options.BaseType.ToTypeSig();
     TypeVisibility.SelectedItem   = (Types.TypeVisibility)((int)(options.Attributes & TypeAttributes.VisibilityMask) >> 0);
     TypeLayout.SelectedItem       = (Types.TypeLayout)(((int)options.Attributes >> 3) & 3);
     TypeSemantics.SelectedItem    = (Types.TypeSemantics)(((int)options.Attributes >> 5) & 1);
     TypeStringFormat.SelectedItem = (Types.TypeStringFormat)(((int)options.Attributes >> 16) & 3);
     TypeCustomFormat.SelectedItem = (Types.TypeCustomFormat)(((int)options.Attributes >> 22) & 3);
     CustomAttributesVM.InitializeFrom(options.CustomAttributes);
     DeclSecuritiesVM.InitializeFrom(options.DeclSecurities);
     GenericParamsVM.InitializeFrom(options.GenericParameters);
     InterfaceImplsVM.InitializeFrom(options.Interfaces);
 }
Example #4
0
        public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = ownerMethod == null || ownerMethod.GenericParameters.Count > 0,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }

            var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions);

            methodSigCreatorOptions.IsPropertySig = false;
            MethodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions);
            MethodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged;
            MethodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged;
            MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true;
            MethodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr      = false;

            CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, ownerMethod);
            DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, ownerMethod);
            ParamDefsVM        = new ParamDefsVM(ownerModule, decompilerService, ownerType, ownerMethod);
            GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerService, ownerType, ownerMethod);
            MethodOverridesVM  = new MethodOverridesVM(ownerModule, decompilerService, ownerType, ownerMethod);

            origOptions = options;

            ImplMapVM = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
Example #5
0
        public MethodOptionsVM(MethodDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                IsLocal = false,
                CanAddGenericTypeVar = true,
                CanAddGenericMethodVar = ownerMethod == null || ownerMethod.GenericParameters.Count > 0,
                OwnerType = ownerType,
                OwnerMethod = ownerMethod,
            };
            if (ownerType != null && ownerType.GenericParameters.Count == 0)
                typeSigCreatorOptions.CanAddGenericTypeVar = false;

            var methodSigCreatorOptions = new MethodSigCreatorOptions(typeSigCreatorOptions);
            methodSigCreatorOptions.IsPropertySig = false;
            this.methodSigCreator = new MethodSigCreatorVM(methodSigCreatorOptions);
            this.methodSigCreator.PropertyChanged += methodSigCreator_PropertyChanged;
            this.methodSigCreator.ParametersCreateTypeSigArray.PropertyChanged += methodSigCreator_PropertyChanged;
            this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.ShowTypeFullName = true;
            this.methodSigCreator.ParametersCreateTypeSigArray.TypeSigCreator.CanAddFnPtr = false;

            this.customAttributesVM = new CustomAttributesVM(ownerModule, language, ownerType, ownerMethod);
            this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, ownerType, ownerMethod);
            this.paramDefsVM = new ParamDefsVM(ownerModule, language, ownerType, ownerMethod);
            this.genericParamsVM = new GenericParamsVM(ownerModule, language, ownerType, ownerMethod);
            this.methodOverridesVM = new MethodOverridesVM(ownerModule, language, ownerType, ownerMethod);

            this.origOptions = options;

            this.implMapVM = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
Example #6
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;
			TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
			TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

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

			origOptions = options;
			IsNestedType = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
			TypeKind = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
			TypeLayout = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
			TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
			PackingSize = new NullableUInt16VM(a => HasErrorUpdated());
			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();
			TypeSigCreator.CanAddFnPtr = false;
			Reinitialize();
		}