Пример #1
0
        /// <summary>
        /// Builds a graph of simple metadata test data.
        /// </summary>
        private static Writer.ScopeDefinition BuildSimpleTestData()
        {
            // Scope for System.Runtime, 4.0.0.0
            var systemRuntimeScope = new Writer.ScopeDefinition
            {
                Name = (Writer.ConstantStringValue)"System.Runtime",
                MajorVersion = 4,
            };

            // Root namespace (".")
            var rootNamespaceDefinition = new Writer.NamespaceDefinition
            {
                ParentScopeOrNamespace = systemRuntimeScope,
            };
            systemRuntimeScope.RootNamespaceDefinition = rootNamespaceDefinition;

            // The <Module> type
            var moduleTypeDefinition = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Abstract | TypeAttributes.Public,
                Name = (Writer.ConstantStringValue)"<Module>",
                NamespaceDefinition = rootNamespaceDefinition,
            };
            rootNamespaceDefinition.TypeDefinitions.Add(moduleTypeDefinition);

            // System namespace
            var systemNamespaceDefinition = new Writer.NamespaceDefinition
            {
                Name = (Writer.ConstantStringValue)"System",
                ParentScopeOrNamespace = rootNamespaceDefinition,
            };
            rootNamespaceDefinition.NamespaceDefinitions.Add(systemNamespaceDefinition);

            // System.Object type
            var objectType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Public | TypeAttributes.SequentialLayout,
                Name = (Writer.ConstantStringValue)"Object",
                NamespaceDefinition = systemNamespaceDefinition
            };
            systemNamespaceDefinition.TypeDefinitions.Add(objectType);

            // System.ValueType type
            var valueTypeType = new Writer.TypeDefinition
            {
                BaseType = objectType,
                Flags = TypeAttributes.Public,
                Name = (Writer.ConstantStringValue)"ValueType",
                NamespaceDefinition = systemNamespaceDefinition
            };
            systemNamespaceDefinition.TypeDefinitions.Add(valueTypeType);

            // System.Void type
            var voidType = new Writer.TypeDefinition
            {
                BaseType = valueTypeType,
                Flags = TypeAttributes.Public,
                Name = (Writer.ConstantStringValue)"Void",
                NamespaceDefinition = systemNamespaceDefinition
            };
            systemNamespaceDefinition.TypeDefinitions.Add(voidType);

            // System.String type
            var stringType = new Writer.TypeDefinition
            {
                BaseType = objectType,
                Flags = TypeAttributes.Public,
                Name = (Writer.ConstantStringValue)"String",
                NamespaceDefinition = systemNamespaceDefinition
            };
            systemNamespaceDefinition.TypeDefinitions.Add(stringType);

            // System.Object..ctor() method
            var objectCtorMethod = new Writer.Method
            {
                Flags = MethodAttributes.Public
                    | MethodAttributes.RTSpecialName
                    | MethodAttributes.SpecialName,
                Name = (Writer.ConstantStringValue)".ctor",
                Signature = new Writer.MethodSignature
                {
                    CallingConvention = CallingConventions.HasThis,
                    ReturnType = new Writer.ReturnTypeSignature
                    {
                        Type = voidType
                    }
                },
            };
            objectType.Methods.Add(objectCtorMethod);

            // System.String..ctor() method
            var stringCtorMethod = new Writer.Method
            {
                Flags = MethodAttributes.Public
                    | MethodAttributes.RTSpecialName
                    | MethodAttributes.SpecialName,
                Name = (Writer.ConstantStringValue)".ctor",
                Signature = new Writer.MethodSignature
                {
                    CallingConvention = CallingConventions.HasThis,
                    ReturnType = new Writer.ReturnTypeSignature
                    {
                        Type = voidType
                    }
                },
            };
            stringType.Methods.Add(stringCtorMethod);

            return systemRuntimeScope;
        }
Пример #2
0
        private static Writer.ScopeDefinition BuildSimpleTestDefinitionData()
        {
            // Scope for System.Runtime, 4.0.0.0
            var systemRuntimeScope = new Writer.ScopeDefinition
            {
                Name         = (Writer.ConstantStringValue) "System.Runtime",
                MajorVersion = 4,
            };

            // Root namespace (".")
            var rootNamespaceDefinition = new Writer.NamespaceDefinition
            {
                ParentScopeOrNamespace = systemRuntimeScope,
            };

            systemRuntimeScope.RootNamespaceDefinition = rootNamespaceDefinition;

            // The <Module> type
            var moduleTypeDefinition = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Abstract | TypeAttributes.Public,
                Name  = (Writer.ConstantStringValue) "<Module>",
                NamespaceDefinition = rootNamespaceDefinition,
            };

            rootNamespaceDefinition.TypeDefinitions.Add(moduleTypeDefinition);

            // System namespace
            var systemNamespaceDefinition = new Writer.NamespaceDefinition
            {
                Name = (Writer.ConstantStringValue) "System",
                ParentScopeOrNamespace = rootNamespaceDefinition,
            };

            rootNamespaceDefinition.NamespaceDefinitions.Add(systemNamespaceDefinition);

            // System.Object type
            var objectType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Public | TypeAttributes.SequentialLayout,
                Name  = (Writer.ConstantStringValue) "Object",
                NamespaceDefinition = systemNamespaceDefinition
            };

            systemNamespaceDefinition.TypeDefinitions.Add(objectType);

            // System.Object+Nested type
            var nestedType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.SequentialLayout | TypeAttributes.NestedPublic,
                Name  = (Writer.ConstantStringValue) "Nested",
                NamespaceDefinition = null,
                EnclosingType       = objectType
            };

            objectType.NestedTypes.Add(nestedType);

            // System.Object+Nested+ReallyNested type
            var reallyNestedType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.SequentialLayout | TypeAttributes.NestedPublic,
                Name  = (Writer.ConstantStringValue) "ReallyNested",
                NamespaceDefinition = null,
                EnclosingType       = nestedType
            };

            nestedType.NestedTypes.Add(reallyNestedType);

            return(systemRuntimeScope);
        }
Пример #3
0
        /// <summary>
        /// Builds a graph of simple metadata test data.
        /// </summary>
        private static Writer.ScopeDefinition BuildSimpleTestData()
        {
            // Scope for System.Runtime, 4.0.0.0
            var systemRuntimeScope = new Writer.ScopeDefinition
            {
                Name         = (Writer.ConstantStringValue) "System.Runtime",
                MajorVersion = 4,
            };

            // Root namespace (".")
            var rootNamespaceDefinition = new Writer.NamespaceDefinition
            {
                ParentScopeOrNamespace = systemRuntimeScope,
            };

            systemRuntimeScope.RootNamespaceDefinition = rootNamespaceDefinition;

            // The <Module> type
            var moduleTypeDefinition = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Abstract | TypeAttributes.Public,
                Name  = (Writer.ConstantStringValue) "<Module>",
                NamespaceDefinition = rootNamespaceDefinition,
            };

            rootNamespaceDefinition.TypeDefinitions.Add(moduleTypeDefinition);

            // System namespace
            var systemNamespaceDefinition = new Writer.NamespaceDefinition
            {
                Name = (Writer.ConstantStringValue) "System",
                ParentScopeOrNamespace = rootNamespaceDefinition,
            };

            rootNamespaceDefinition.NamespaceDefinitions.Add(systemNamespaceDefinition);

            // System.Object type
            var objectType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Public | TypeAttributes.SequentialLayout,
                Name  = (Writer.ConstantStringValue) "Object",
                NamespaceDefinition = systemNamespaceDefinition
            };

            systemNamespaceDefinition.TypeDefinitions.Add(objectType);

            // System.ValueType type
            var valueTypeType = new Writer.TypeDefinition
            {
                BaseType            = objectType,
                Flags               = TypeAttributes.Public,
                Name                = (Writer.ConstantStringValue) "ValueType",
                NamespaceDefinition = systemNamespaceDefinition
            };

            systemNamespaceDefinition.TypeDefinitions.Add(valueTypeType);

            // System.Void type
            var voidType = new Writer.TypeDefinition
            {
                BaseType            = valueTypeType,
                Flags               = TypeAttributes.Public,
                Name                = (Writer.ConstantStringValue) "Void",
                NamespaceDefinition = systemNamespaceDefinition
            };

            systemNamespaceDefinition.TypeDefinitions.Add(voidType);

            // System.String type
            var stringType = new Writer.TypeDefinition
            {
                BaseType            = objectType,
                Flags               = TypeAttributes.Public,
                Name                = (Writer.ConstantStringValue) "String",
                NamespaceDefinition = systemNamespaceDefinition
            };

            systemNamespaceDefinition.TypeDefinitions.Add(stringType);

            // System.Object..ctor() method
            var objectCtorMethod = new Writer.Method
            {
                Flags = MethodAttributes.Public
                        | MethodAttributes.RTSpecialName
                        | MethodAttributes.SpecialName,
                Name      = (Writer.ConstantStringValue) ".ctor",
                Signature = new Writer.MethodSignature
                {
                    CallingConvention = CallingConventions.HasThis,
                    ReturnType        = voidType,
                },
            };

            objectType.Methods.Add(objectCtorMethod);

            // System.String..ctor() method
            var stringCtorMethod = new Writer.Method
            {
                Flags = MethodAttributes.Public
                        | MethodAttributes.RTSpecialName
                        | MethodAttributes.SpecialName,
                Name      = (Writer.ConstantStringValue) ".ctor",
                Signature = new Writer.MethodSignature
                {
                    CallingConvention = CallingConventions.HasThis,
                    ReturnType        = voidType,
                },
            };

            stringType.Methods.Add(stringCtorMethod);

            return(systemRuntimeScope);
        }
Пример #4
0
        private static Writer.ScopeDefinition BuildSimpleTestDefinitionData()
        {
            // Scope for System.Runtime, 4.0.0.0
            var systemRuntimeScope = new Writer.ScopeDefinition
            {
                Name = (Writer.ConstantStringValue)"System.Runtime",
                MajorVersion = 4,
            };

            // Root namespace (".")
            var rootNamespaceDefinition = new Writer.NamespaceDefinition
            {
                ParentScopeOrNamespace = systemRuntimeScope,
            };
            systemRuntimeScope.RootNamespaceDefinition = rootNamespaceDefinition;

            // The <Module> type
            var moduleTypeDefinition = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Abstract | TypeAttributes.Public,
                Name = (Writer.ConstantStringValue)"<Module>",
                NamespaceDefinition = rootNamespaceDefinition,
            };
            rootNamespaceDefinition.TypeDefinitions.Add(moduleTypeDefinition);

            // System namespace
            var systemNamespaceDefinition = new Writer.NamespaceDefinition
            {
                Name = (Writer.ConstantStringValue)"System",
                ParentScopeOrNamespace = rootNamespaceDefinition,
            };
            rootNamespaceDefinition.NamespaceDefinitions.Add(systemNamespaceDefinition);

            // System.Object type
            var objectType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.Public | TypeAttributes.SequentialLayout,
                Name = (Writer.ConstantStringValue)"Object",
                NamespaceDefinition = systemNamespaceDefinition
            };
            systemNamespaceDefinition.TypeDefinitions.Add(objectType);

            // System.Object+Nested type
            var nestedType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.SequentialLayout | TypeAttributes.NestedPublic,
                Name = (Writer.ConstantStringValue)"Nested",
                NamespaceDefinition = null,
                EnclosingType = objectType
            };
            objectType.NestedTypes.Add(nestedType);

            // System.Object+Nested+ReallyNested type
            var reallyNestedType = new Writer.TypeDefinition
            {
                Flags = TypeAttributes.SequentialLayout | TypeAttributes.NestedPublic,
                Name = (Writer.ConstantStringValue)"ReallyNested",
                NamespaceDefinition = null,
                EnclosingType = nestedType
            };
            nestedType.NestedTypes.Add(reallyNestedType);

            return systemRuntimeScope;
        }