Esempio n. 1
0
 private void WriteInterface(Interface contract) {
     // writer.WriteStartElement("implement");
     WriteTypeReference(contract);
     // writer.WriteAttributeString("interface", namer.GetTypeName(contract));
     // writer.WriteEndElement();
 }
Esempio n. 2
0
        private static void ClearStatics()
        {
            AttributeUsageAttribute = null;
            ConditionalAttribute = null;
            DefaultMemberAttribute = null;
            InternalsVisibleToAttribute = null;
            ObsoleteAttribute = null;

            GenericICollection = null;
            GenericIEnumerable = null;
            GenericIList = null;
            ICloneable = null;
            ICollection = null;
            IEnumerable = null;
            IList = null;

            //Special attributes    
            AllowPartiallyTrustedCallersAttribute = null;
            AssemblyCompanyAttribute = null;
            AssemblyConfigurationAttribute = null;
            AssemblyCopyrightAttribute = null;
            AssemblyCultureAttribute = null;
            AssemblyDelaySignAttribute = null;
            AssemblyDescriptionAttribute = null;
            AssemblyFileVersionAttribute = null;
            AssemblyFlagsAttribute = null;
            AssemblyInformationalVersionAttribute = null;
            AssemblyKeyFileAttribute = null;
            AssemblyKeyNameAttribute = null;
            AssemblyProductAttribute = null;
            AssemblyTitleAttribute = null;
            AssemblyTrademarkAttribute = null;
            AssemblyVersionAttribute = null;
            ClassInterfaceAttribute = null;
            CLSCompliantAttribute = null;
            ComImportAttribute = null;
            ComRegisterFunctionAttribute = null;
            ComSourceInterfacesAttribute = null;
            ComUnregisterFunctionAttribute = null;
            ComVisibleAttribute = null;
            DebuggableAttribute = null;
            DebuggerHiddenAttribute = null;
            DebuggerStepThroughAttribute = null;
            DebuggingModes = null;
            DllImportAttribute = null;
            FieldOffsetAttribute = null;
            FlagsAttribute = null;
            GuidAttribute = null;
            ImportedFromTypeLibAttribute = null;
            InAttribute = null;
            IndexerNameAttribute = null;
            InterfaceTypeAttribute = null;
            MethodImplAttribute = null;
            NonSerializedAttribute = null;
            OptionalAttribute = null;
            OutAttribute = null;
            ParamArrayAttribute = null;
            RuntimeCompatibilityAttribute = null;
            SatelliteContractVersionAttribute = null;
            SerializableAttribute = null;
            SecurityAttribute = null;
            SecurityCriticalAttribute = null;
            SecurityTransparentAttribute = null;
            SecurityTreatAsSafeAttribute = null;
            STAThreadAttribute = null;
            StructLayoutAttribute = null;
            SuppressMessageAttribute = null;
            SuppressUnmanagedCodeSecurityAttribute = null;
            SecurityAction = null;

            //Classes need for System.TypeCode
            DBNull = null;
            DateTime = null;
            TimeSpan = null;

            //Classes and interfaces used by the Framework
            Activator = null;
            AppDomain = null;
            ApplicationException = null;
            ArgumentException = null;
            ArgumentNullException = null;
            ArgumentOutOfRangeException = null;
            ArrayList = null;
            AsyncCallback = null;
            Assembly = null;
            CodeAccessPermission = null;
            CollectionBase = null;
            CultureInfo = null;
            DictionaryBase = null;
            DictionaryEntry = null;
            DuplicateWaitObjectException = null;
            Environment = null;
            EventArgs = null;
            ExecutionEngineException = null;
            GenericArraySegment = null;
            GenericArrayToIEnumerableAdapter = null;
            GenericDictionary = null;
            GenericIComparable = null;
            GenericIComparer = null;
            GenericIDictionary = null;
            GenericIEnumerator = null;
            GenericKeyValuePair = null;
            GenericList = null;
            GenericNullable = null;
            GenericQueue = null;
            GenericSortedDictionary = null;
            GenericStack = null;
            GC = null;
            Guid = null;
            __HandleProtector = null;
            HandleRef = null;
            Hashtable = null;
            IASyncResult = null;
            IComparable = null;
            IDictionary = null;
            IComparer = null;
            IDisposable = null;
            IEnumerator = null;
            IFormatProvider = null;
            IHashCodeProvider = null;
            IMembershipCondition = null;
            IndexOutOfRangeException = null;
            InvalidCastException = null;
            InvalidOperationException = null;
            IPermission = null;
            ISerializable = null;
            IStackWalk = null;
            Marshal = null;
            MarshalByRefObject = null;
            MemberInfo = null;
            NativeOverlapped = null;
            Monitor = null;
            NotSupportedException = null;
            NullReferenceException = null;
            OutOfMemoryException = null;
            ParameterInfo = null;
            Queue = null;
            ReadOnlyCollectionBase = null;
            ResourceManager = null;
            ResourceSet = null;
            SerializationInfo = null;
            Stack = null;
            StackOverflowException = null;
            Stream = null;
            StreamingContext = null;
            StringBuilder = null;
            StringComparer = null;
            StringComparison = null;
            SystemException = null;
            Thread = null;
            WindowsImpersonationContext = null;
        }
Esempio n. 3
0
        // Interfaces

        private void WriteImplementors(Interface contract) {
            List < TypeNode > implementors;
            if (!implementorIndex.TryGetValue(contract, out implementors)) return;
            if ((implementors == null) || (implementors.Count == 0)) return;
            writer.WriteStartElement("implementors");
            StartElementCallbacks("implementors", implementors);
            foreach (TypeNode implementor in implementors) {
                WriteTypeReference(implementor);
            }
            writer.WriteEndElement();
            EndElementCallbacks("implementors", implementors);
        }
 public EventingVisitor(Action<Interface> visitInterface) { VisitedInterface += visitInterface; } public event Action<Interface> VisitedInterface; public override Interface VisitInterface(Interface Interface) { if (VisitedInterface != null) VisitedInterface(Interface); return base.VisitInterface(Interface); }
Esempio n. 5
0
        public static void Initialize(bool doNotLockFile, bool getDebugInfo)
        {
            if (SystemTypes.Initialized)
            {
                SystemTypes.Clear();
                CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo);
            }
            else if (!CoreSystemTypes.Initialized)
            {
                CoreSystemTypes.Initialize(doNotLockFile, getDebugInfo);
            }

            if (TargetPlatform.TargetVersion == null)
            {
                TargetPlatform.TargetVersion = SystemAssembly.Version;
                if (TargetPlatform.TargetVersion == null)
                    TargetPlatform.TargetVersion = typeof(object).Module.Assembly.GetName().Version;
            }
            //TODO: throw an exception when the result is null

            AttributeUsageAttribute = (Class)GetTypeNodeFor("System", "AttributeUsageAttribute", ElementType.Class);
            ConditionalAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "ConditionalAttribute", ElementType.Class);
            DefaultMemberAttribute = (Class)GetTypeNodeFor("System.Reflection", "DefaultMemberAttribute", ElementType.Class);
            InternalsVisibleToAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "InternalsVisibleToAttribute", ElementType.Class);
            ObsoleteAttribute = (Class)GetTypeNodeFor("System", "ObsoleteAttribute", ElementType.Class);

            GenericICollection = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "ICollection", 1, ElementType.Class);
            GenericIEnumerable = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IEnumerable", 1, ElementType.Class);
            GenericIList = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IList", 1, ElementType.Class);
            ICloneable = (Interface)GetTypeNodeFor("System", "ICloneable", ElementType.Class);
            ICollection = (Interface)GetTypeNodeFor("System.Collections", "ICollection", ElementType.Class);
            IEnumerable = (Interface)GetTypeNodeFor("System.Collections", "IEnumerable", ElementType.Class);
            IList = (Interface)GetTypeNodeFor("System.Collections", "IList", ElementType.Class);

            AllowPartiallyTrustedCallersAttribute = (Class)GetTypeNodeFor("System.Security", "AllowPartiallyTrustedCallersAttribute", ElementType.Class);
            AssemblyCompanyAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCompanyAttribute", ElementType.Class);
            AssemblyConfigurationAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyConfigurationAttribute", ElementType.Class);
            AssemblyCopyrightAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCopyrightAttribute", ElementType.Class);
            AssemblyCultureAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyCultureAttribute", ElementType.Class);
            AssemblyDelaySignAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyDelaySignAttribute", ElementType.Class);
            AssemblyDescriptionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyDescriptionAttribute", ElementType.Class);
            AssemblyFileVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyFileVersionAttribute", ElementType.Class);
            AssemblyFlagsAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyFlagsAttribute", ElementType.Class);
            AssemblyInformationalVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyInformationalVersionAttribute", ElementType.Class);
            AssemblyKeyFileAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyKeyFileAttribute", ElementType.Class);
            AssemblyKeyNameAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyKeyNameAttribute", ElementType.Class);
            AssemblyProductAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyProductAttribute", ElementType.Class);
            AssemblyTitleAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyTitleAttribute", ElementType.Class);
            AssemblyTrademarkAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyTrademarkAttribute", ElementType.Class);
            AssemblyVersionAttribute = (Class)GetTypeNodeFor("System.Reflection", "AssemblyVersionAttribute", ElementType.Class);
            ClassInterfaceAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ClassInterfaceAttribute", ElementType.Class);
            CLSCompliantAttribute = (Class)GetTypeNodeFor("System", "CLSCompliantAttribute", ElementType.Class);
            ComImportAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComImportAttribute", ElementType.Class);
            ComRegisterFunctionAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComRegisterFunctionAttribute", ElementType.Class);
            ComSourceInterfacesAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComSourceInterfacesAttribute", ElementType.Class);
            ComUnregisterFunctionAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComUnregisterFunctionAttribute", ElementType.Class);
            ComVisibleAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ComVisibleAttribute", ElementType.Class);
            DebuggableAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggableAttribute", ElementType.Class);
            DebuggerHiddenAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggerHiddenAttribute", ElementType.Class);
            DebuggerStepThroughAttribute = (Class)GetTypeNodeFor("System.Diagnostics", "DebuggerStepThroughAttribute", ElementType.Class);
            DebuggingModes = DebuggableAttribute == null ? null : DebuggableAttribute.GetNestedType(Identifier.For("DebuggingModes")) as EnumNode;
            DllImportAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "DllImportAttribute", ElementType.Class);
            FieldOffsetAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "FieldOffsetAttribute", ElementType.Class);
            FlagsAttribute = (Class)GetTypeNodeFor("System", "FlagsAttribute", ElementType.Class);
            Guid = (Struct)GetTypeNodeFor("System", "Guid", ElementType.ValueType);
            GuidAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "GuidAttribute", ElementType.Class);
            ImportedFromTypeLibAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "ImportedFromTypeLibAttribute", ElementType.Class);
            InAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "InAttribute", ElementType.Class);
            IndexerNameAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "IndexerNameAttribute", ElementType.Class);
            InterfaceTypeAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "InterfaceTypeAttribute", ElementType.Class);
            MethodImplAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "MethodImplAttribute", ElementType.Class);
            NonSerializedAttribute = (Class)GetTypeNodeFor("System", "NonSerializedAttribute", ElementType.Class);
            OptionalAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "OptionalAttribute", ElementType.Class);
            OutAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "OutAttribute", ElementType.Class);
            ParamArrayAttribute = (Class)GetTypeNodeFor("System", "ParamArrayAttribute", ElementType.Class);
            RuntimeCompatibilityAttribute = (Class)GetTypeNodeFor("System.Runtime.CompilerServices", "RuntimeCompatibilityAttribute", ElementType.Class);
            SatelliteContractVersionAttribute = (Class)GetTypeNodeFor("System.Resources", "SatelliteContractVersionAttribute", ElementType.Class);
            SerializableAttribute = (Class)GetTypeNodeFor("System", "SerializableAttribute", ElementType.Class);
            SecurityAttribute = (Class)GetTypeNodeFor("System.Security.Permissions", "SecurityAttribute", ElementType.Class);
            SecurityCriticalAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityCriticalAttribute", ElementType.Class);
            SecurityTransparentAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityTransparentAttribute", ElementType.Class);
            SecurityTreatAsSafeAttribute = (Class)GetTypeNodeFor("System.Security", "SecurityTreatAsSafeAttribute", ElementType.Class);
            STAThreadAttribute = (Class)GetTypeNodeFor("System", "STAThreadAttribute", ElementType.Class);
            StructLayoutAttribute = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "StructLayoutAttribute", ElementType.Class);
            SuppressMessageAttribute = (Class)GetTypeNodeFor("System.Diagnostics.CodeAnalysis", "SuppressMessageAttribute", ElementType.Class);
            SuppressUnmanagedCodeSecurityAttribute = (Class)GetTypeNodeFor("System.Security", "SuppressUnmanagedCodeSecurityAttribute", ElementType.Class);
            SecurityAction = GetTypeNodeFor("System.Security.Permissions", "SecurityAction", ElementType.ValueType) as EnumNode;
            DBNull = (Class)GetTypeNodeFor("System", "DBNull", ElementType.Class);
            DateTime = (Struct)GetTypeNodeFor("System", "DateTime", ElementType.ValueType);
            TimeSpan = (Struct)GetTypeNodeFor("System", "TimeSpan", ElementType.ValueType);
            Activator = (Class)GetTypeNodeFor("System", "Activator", ElementType.Class);
            AppDomain = (Class)GetTypeNodeFor("System", "AppDomain", ElementType.Class);
            ApplicationException = (Class)GetTypeNodeFor("System", "ApplicationException", ElementType.Class);
            ArgumentException = (Class)GetTypeNodeFor("System", "ArgumentException", ElementType.Class);
            ArgumentNullException = (Class)GetTypeNodeFor("System", "ArgumentNullException", ElementType.Class);
            ArgumentOutOfRangeException = (Class)GetTypeNodeFor("System", "ArgumentOutOfRangeException", ElementType.Class);
            ArrayList = (Class)GetTypeNodeFor("System.Collections", "ArrayList", ElementType.Class);
            AsyncCallback = (DelegateNode)GetTypeNodeFor("System", "AsyncCallback", ElementType.Class);
            Assembly = (Class)GetTypeNodeFor("System.Reflection", "Assembly", ElementType.Class);
            CodeAccessPermission = (Class)GetTypeNodeFor("System.Security", "CodeAccessPermission", ElementType.Class);
            CollectionBase = (Class)GetTypeNodeFor("System.Collections", "CollectionBase", ElementType.Class);
            CultureInfo = (Class)GetTypeNodeFor("System.Globalization", "CultureInfo", ElementType.Class);
            DictionaryBase = (Class)GetTypeNodeFor("System.Collections", "DictionaryBase", ElementType.Class);

            // EFW - In the .NET Micro Framework this is a class not a structure.  Few if any of these are
            // actually used, this one included.  I'm loathe to remove them as they may be used to ensure
            // assemblies are loaded.  Using the as operator rather than a direct cast prevent it from failing.
            DictionaryEntry = GetTypeNodeFor("System.Collections", "DictionaryEntry", ElementType.ValueType) as Struct;

            DuplicateWaitObjectException = (Class)GetTypeNodeFor("System", "DuplicateWaitObjectException", ElementType.Class);
            Environment = (Class)GetTypeNodeFor("System", "Environment", ElementType.Class);
            EventArgs = (Class)GetTypeNodeFor("System", "EventArgs", ElementType.Class);
            ExecutionEngineException = (Class)GetTypeNodeFor("System", "ExecutionEngineException", ElementType.Class);
            GenericArraySegment = (Struct)GetGenericRuntimeTypeNodeFor("System", "ArraySegment", 1, ElementType.ValueType);
            GenericDictionary = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Dictionary", 2, ElementType.Class);
            GenericIComparable = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IComparable", 1, ElementType.Class);
            GenericIComparer = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IComparer", 1, ElementType.Class);
            GenericIDictionary = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IDictionary", 2, ElementType.Class);
            GenericIEnumerator = (Interface)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "IEnumerator", 1, ElementType.Class);
            GenericKeyValuePair = (Struct)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "KeyValuePair", 2, ElementType.ValueType);
            GenericList = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "List", 1, ElementType.Class);
            GenericNullable = (Struct)GetGenericRuntimeTypeNodeFor("System", "Nullable", 1, ElementType.ValueType);
            GenericQueue = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Queue", 1, ElementType.Class);
            GenericSortedDictionary = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "SortedDictionary", 2, ElementType.Class);
            GenericStack = (Class)GetGenericRuntimeTypeNodeFor("System.Collections.Generic", "Stack", 1, ElementType.Class);
            GC = (Class)GetTypeNodeFor("System", "GC", ElementType.Class);
            __HandleProtector = (Class)GetTypeNodeFor("System.Threading", "__HandleProtector", ElementType.Class);
            HandleRef = (Struct)GetTypeNodeFor("System.Runtime.InteropServices", "HandleRef", ElementType.ValueType);
            Hashtable = (Class)GetTypeNodeFor("System.Collections", "Hashtable", ElementType.Class);
            IASyncResult = (Interface)GetTypeNodeFor("System", "IAsyncResult", ElementType.Class);
            IComparable = (Interface)GetTypeNodeFor("System", "IComparable", ElementType.Class);
            IComparer = (Interface)GetTypeNodeFor("System.Collections", "IComparer", ElementType.Class);
            IDictionary = (Interface)GetTypeNodeFor("System.Collections", "IDictionary", ElementType.Class);
            IDisposable = (Interface)GetTypeNodeFor("System", "IDisposable", ElementType.Class);
            IEnumerator = (Interface)GetTypeNodeFor("System.Collections", "IEnumerator", ElementType.Class);
            IFormatProvider = (Interface)GetTypeNodeFor("System", "IFormatProvider", ElementType.Class);
            IHashCodeProvider = (Interface)GetTypeNodeFor("System.Collections", "IHashCodeProvider", ElementType.Class);
            IMembershipCondition = (Interface)GetTypeNodeFor("System.Security.Policy", "IMembershipCondition", ElementType.Class);
            IndexOutOfRangeException = (Class)GetTypeNodeFor("System", "IndexOutOfRangeException", ElementType.Class);
            InvalidCastException = (Class)GetTypeNodeFor("System", "InvalidCastException", ElementType.Class);
            InvalidOperationException = (Class)GetTypeNodeFor("System", "InvalidOperationException", ElementType.Class);
            IPermission = (Interface)GetTypeNodeFor("System.Security", "IPermission", ElementType.Class);
            ISerializable = (Interface)GetTypeNodeFor("System.Runtime.Serialization", "ISerializable", ElementType.Class);
            IStackWalk = (Interface)GetTypeNodeFor("System.Security", "IStackWalk", ElementType.Class);
            Marshal = (Class)GetTypeNodeFor("System.Runtime.InteropServices", "Marshal", ElementType.Class);
            MarshalByRefObject = (Class)GetTypeNodeFor("System", "MarshalByRefObject", ElementType.Class);
            MemberInfo = (Class)GetTypeNodeFor("System.Reflection", "MemberInfo", ElementType.Class);
            Monitor = (Class)GetTypeNodeFor("System.Threading", "Monitor", ElementType.Class);
            NativeOverlapped = (Struct)GetTypeNodeFor("System.Threading", "NativeOverlapped", ElementType.ValueType);
            NotSupportedException = (Class)GetTypeNodeFor("System", "NotSupportedException", ElementType.Class);
            NullReferenceException = (Class)GetTypeNodeFor("System", "NullReferenceException", ElementType.Class);
            OutOfMemoryException = (Class)GetTypeNodeFor("System", "OutOfMemoryException", ElementType.Class);
            ParameterInfo = (Class)GetTypeNodeFor("System.Reflection", "ParameterInfo", ElementType.Class);
            Queue = (Class)GetTypeNodeFor("System.Collections", "Queue", ElementType.Class);
            ReadOnlyCollectionBase = (Class)GetTypeNodeFor("System.Collections", "ReadOnlyCollectionBase", ElementType.Class);
            ResourceManager = (Class)GetTypeNodeFor("System.Resources", "ResourceManager", ElementType.Class);
            ResourceSet = (Class)GetTypeNodeFor("System.Resources", "ResourceSet", ElementType.Class);
            SerializationInfo = (Class)GetTypeNodeFor("System.Runtime.Serialization", "SerializationInfo", ElementType.Class);
            Stack = (Class)GetTypeNodeFor("System.Collections", "Stack", ElementType.Class);
            StackOverflowException = (Class)GetTypeNodeFor("System", "StackOverflowException", ElementType.Class);
            Stream = (Class)GetTypeNodeFor("System.IO", "Stream", ElementType.Class);
            StreamingContext = (Struct)GetTypeNodeFor("System.Runtime.Serialization", "StreamingContext", ElementType.ValueType);
            StringBuilder = (Class)GetTypeNodeFor("System.Text", "StringBuilder", ElementType.Class);
            StringComparer = (Class)GetTypeNodeFor("System", "StringComparer", ElementType.Class);
            StringComparison = GetTypeNodeFor("System", "StringComparison", ElementType.ValueType) as EnumNode;
            SystemException = (Class)GetTypeNodeFor("System", "SystemException", ElementType.Class);
            Thread = (Class)GetTypeNodeFor("System.Threading", "Thread", ElementType.Class);
            WindowsImpersonationContext = (Class)GetTypeNodeFor("System.Security.Principal", "WindowsImpersonationContext", ElementType.Class);

            SystemTypes.Initialized = true;
            object dummy = TargetPlatform.AssemblyReferenceFor; //Force selection of target platform
            if (dummy == null) return;
        }
Esempio n. 6
0
 public virtual Interface VisitInterface(Interface Interface)
 {
     return (Interface)this.VisitTypeNode(Interface);
 }
        private void CheckForWrapperImplementationsForInheritedInterfaceImplementations(Class Class, Interface intf)
        {
            Contract.Requires(Class != null);
            Contract.Requires(intf != null);

            var members = intf.Members;
            // if (members == null) return;
            for (int i = 0; i < members.Count; i++)
            {
                var intfMethod = members[i] as Method;
                if (intfMethod == null) continue;

                if (Class.ExplicitImplementation(intfMethod) != null) continue;

                if (Class.GetExactMatchingMethod(intfMethod) != null) continue;

                var contractMethod = HelperMethods.GetContractMethod(intfMethod);
                if (contractMethod == null) continue;

                var contract = contractMethod.Contract;
                if (contract == null) continue;
                
                if (contract.RequiresCount + contract.EnsuresCount == 0) continue;

                // find base implementing method
                var baseMethod = FindInheritedMethod(Class.BaseClass, intfMethod);
                if (baseMethod == null) continue;
                
                var baseMethodImplementsInterfaceMethod = false;
                if (baseMethod.ImplicitlyImplementedInterfaceMethods != null)
                {
                    for (int j = 0; j < baseMethod.ImplicitlyImplementedInterfaceMethods.Count; j++)
                    {
                        if (baseMethod.ImplicitlyImplementedInterfaceMethods[j] == intfMethod)
                        {
                            baseMethodImplementsInterfaceMethod = true;
                            break;
                        }
                    }
                }

                if (baseMethodImplementsInterfaceMethod) continue;

                if (this.runtimeCheckingLevel < 3 && contract.RequiresCount == 0) continue;

                if (this.addInterfaceWrappersWhenNeeded)
                {
                    AddInterfaceImplementationWrapper(Class, intfMethod, baseMethod);
                }
                else
                {
                    this.HandleError(new Warning(1080,
                        string.Format(
                            "Type {0} implements {1} by inheriting {2} causing the interface contract to not be checked at runtime. Consider adding a wrapper method.",
                            Class.FullName, intfMethod.FullName, baseMethod.FullName),
                        default(SourceContext)));
                }
            }
        }
Esempio n. 8
0
 public override Interface VisitInterface(Interface Interface) {
   ImmutabilityChecksOnInterfaces(Interface);
   return base.VisitInterface(Interface);
 }
Esempio n. 9
0
    private void ImmutabilityChecksOnInterfaces(Interface Interface) {
      if (Interface == null) return;
      bool ifaceIsImmutable = Interface.GetAttribute(SystemTypes.ImmutableAttribute) != null;

      // A mutable interface cannot extend an immutable interface
      foreach (Interface iface in Interface.Interfaces) {
        if (iface == null) continue;
        if (iface.GetAttribute(SystemTypes.ImmutableAttribute) != null && !ifaceIsImmutable)
          this.HandleError(Interface.Name, Error.MutableIfaceExtendsImmutableIface);
      }
    }
Esempio n. 10
0
        private Class GenerateClassMethod(ZMethod zMethod, Interface x)
        {
            this.currentMethod = zMethod;
            Class newClass = (Class)Templates.GetTypeTemplateByName("ClassMethod");
            QualifiedIdentifier qi = (x == null)
                                     ? new QualifiedIdentifier(new Identifier("Z"), new Identifier("ZingMethod"))
                                     : new QualifiedIdentifier(x.Name, zMethod.Name);
            Replacer.Replace(newClass, new Identifier("__Method"), qi);

            if (x == null)
            {
                if (!zMethod.IsStatic)
                    GenerateThisParameter(newClass);
                Class interfaceClass = (Class)Templates.GetTypeTemplateByName("InterfaceMethod");
                for (int i = 0, n = interfaceClass.Members.Count; i < n; i++)
                {
                    newClass.Members.Add(interfaceClass.Members[i]);
                    interfaceClass.Members[i].DeclaringType = newClass;
                }

                Class inputsClass = (Class)Templates.GetMemberByName(newClass.Members, "InputVars");
                GenerateInputs(zMethod, inputsClass);

                Class outputsClass = (Class)Templates.GetMemberByName(newClass.Members, "OutputVars");
                GenerateOutputs(zMethod, outputsClass);
            }

            Class localsClass = (Class)Templates.GetMemberByName(newClass.Members, "LocalVars");
            GenerateLocals(zMethod, localsClass);

            Class extras = (Class)Templates.GetTypeTemplateByName(zMethod.IsStatic
                                         ? "StaticMethodExtras"
                                         : "InstanceMethodExtras");
            for (int i = 0, n = extras.Members.Count; i < n; i++)
            {
                newClass.Members.Add(extras.Members[i]);
                extras.Members[i].DeclaringType = newClass;
                Property p = extras.Members[i] as Property;

                if (p != null)
                {
                    if (p.Getter != null)
                        p.Getter.DeclaringType = newClass;
                    if (p.Setter != null)
                        p.Setter.DeclaringType = newClass;
                }
            }

            Replacer.Replace(newClass, newClass.Name, zMethod.Name);
            SetTypeId(newClass);

            ExtendMethodConstructor(newClass, zMethod);

            // If this method doesn't return concrete bool, then remove the helper
            // property for accessing bool return values.
            if (zMethod.ReturnType == SystemTypes.Boolean)
            {
                Property boolRetValProp = (Property)Templates.GetTypeTemplateByName("BooleanReturnValueProperty").Members[0];
                newClass.Members.Add(boolRetValProp);
                boolRetValProp.DeclaringType = newClass;
                newClass.Members.Add(boolRetValProp.Getter);
                boolRetValProp.Getter.DeclaringType = newClass;
            }

            // Clear the "Activated" attribute if we aren't...
            if (!zMethod.Activated)
                newClass.Attributes = new AttributeList(0);

            GenerateBasicBlocks(newClass, zMethod);
            this.currentMethod = null;

            return newClass;
        }
Esempio n. 11
0
        /// <summary>
        /// Write out implementors of an interface
        /// </summary>
        /// <param name="contract"></param>
        private void WriteImplementors(Interface contract)
        {
            List<TypeNode> implementors;

            if(!implementorIndex.TryGetValue(contract, out implementors))
                return;

            if(implementors != null && implementors.Count != 0)
            {
                writer.WriteStartElement("implementors");

                this.StartElementCallbacks("implementors", implementors);

                foreach(TypeNode implementor in implementors)
                    this.WriteTypeReference(implementor);

                writer.WriteEndElement();

                this.EndElementCallbacks("implementors", implementors);
            }
        }
Esempio n. 12
0
        private void GenerateInterface(Interface x)
        {
            TypeNode newClass = Templates.GetTypeTemplateByName("Interface");
            Replacer.Replace(newClass, newClass.Name, x.Name);
            TypeNode createMethods = (TypeNode)Templates.GetMemberByName(newClass.Members, "CreateMethods");

            for (int i = 0; i < x.Members.Count; i++)
            {
                ZMethod zMethod = x.Members[i] as ZMethod;
                Debug.Assert(zMethod != null);
                Class methodClass = GenerateInterfaceMethod(zMethod);
                newClass.Members.Add(methodClass);
                methodClass.DeclaringType = newClass;
                methodClass.Flags = (methodClass.Flags & ~TypeFlags.VisibilityMask) | TypeFlags.NestedFamORAssem;

                TypeNode tn = Templates.GetTypeTemplateByName("InterfaceExtras");
                Method member = (Method)Templates.GetMemberByName(tn.Members, "__CreateInterfaceMethod");
                member.Name = new Identifier("Create" + methodClass.Name.Name);
                Replacer.Replace(member, new Identifier("__InterfaceMethod"), methodClass.Name);
                member.DeclaringType = createMethods;
                createMethods.Members.Add(member);
            }

            // Add the emitted class to our Zing application class
            InstallType(newClass);
        }
Esempio n. 13
0
 public override Interface VisitInterfaceReference(Interface Interface)
 {
     if (Interface == null) return null;
     Write(Interface.Name.Name);
     return Interface;
 }
Esempio n. 14
0
        public override Interface VisitInterface(Interface Interface)
        {
            this.VisitAttributeList(Interface.Attributes);

            WriteStart("{0}interface ", GetTypeQualifiers(Interface));
            this.VisitIdentifier(Interface.Name);
            WriteFinish(string.Empty);

            if (Interface.Interfaces != null && Interface.Interfaces.Count > 0)
            {
                In();

                WriteStart(": ");
                this.VisitInterfaceReferenceList(Interface.Interfaces);
                WriteFinish(string.Empty);

                Out();
            }

            WriteLine("{");
            In();

            this.VisitMemberList(Interface.Members);

            Out();
            WriteLine("}");

            return Interface;
        }
Esempio n. 15
0
 public override void VisitInterface(Interface Interface) {
   // No need to think about rewriting any interface methods, so
   // just return the interface without visiting down into it.
   // NB: We need to do this otherwise some interface methods get
   // a body, but I haven't been able to figure out why.
 }
Esempio n. 16
0
 private void ParseTypeDeclaration(Namespace ns, TypeNode parentType, AttributeList attributes, TokenList modifierTokens,
   SourceContextList modifierContexts, TypeFlags flags, bool isPartial, SourceContext sctx, TokenSet followers){
   if (parentType is Interface){
     this.HandleError(Error.InterfacesCannotContainTypes);
     modifierTokens = null;
   }
   TypeNode t = null;
   InvariantCt = 0;
   switch(this.currentToken){
     case Token.Class:
       Class c = new Class();
       t = c;
       if (parentType == null)
         t.DeclaringNamespace = ns;
       else
         t.DeclaringType = parentType;
       if (modifierTokens != null)
         t.Flags |= this.NestedTypeFlags(modifierTokens, modifierContexts, t, isPartial)|TypeFlags.BeforeFieldInit;
       else{
         t.IsUnsafe = this.inUnsafeCode;
         t.Flags |= flags|TypeFlags.BeforeFieldInit;
       }
       if (t.IsAbstract && t.IsSealed && t.IsSpecialName){
         c.IsAbstractSealedContainerForStatics = true;
         c.Flags &= ~TypeFlags.SpecialName;
       }
       break;
     case Token.Interface:
       t = new Interface();
       if (parentType == null)
         t.DeclaringNamespace = ns;
       else
         t.DeclaringType = parentType;
       if (modifierTokens != null)
         t.Flags |= this.NestedTypeFlags(modifierTokens, modifierContexts, t, isPartial);
       else{
         if ((flags & TypeFlags.Abstract) != 0){
           if ((flags & TypeFlags.Sealed) != 0 && (flags & TypeFlags.SpecialName) != 0){
             this.HandleError(Error.InvalidModifier, "static");
             flags &= ~(TypeFlags.Abstract|TypeFlags.Sealed|TypeFlags.SpecialName);
           }else{
             this.HandleError(Error.InvalidModifier, "abstract");
             flags &= ~TypeFlags.Abstract;
           }
         }else if ((flags & TypeFlags.Sealed) != 0){
           this.HandleError(Error.InvalidModifier, "sealed");
           flags &= ~TypeFlags.Sealed;
         }
         t.IsUnsafe = this.inUnsafeCode;
         t.Flags |= flags|TypeFlags.BeforeFieldInit;
       }
       break;
     case Token.Struct:
       t = new Struct();
       if (parentType == null)
         t.DeclaringNamespace = ns;
       else
         t.DeclaringType = parentType;
       if (modifierTokens != null)
         t.Flags |= this.NestedTypeFlags(modifierTokens, modifierContexts, t, isPartial)|TypeFlags.BeforeFieldInit;
       else{
         if ((flags & TypeFlags.Abstract) != 0){
           if ((flags & TypeFlags.Sealed) != 0 && (flags & TypeFlags.SpecialName) != 0){
             this.HandleError(Error.InvalidModifier, "static");
             flags &= ~(TypeFlags.Abstract|TypeFlags.Sealed|TypeFlags.SpecialName);
           }else{
             this.HandleError(Error.InvalidModifier, "abstract");
             flags &= ~TypeFlags.Abstract;
           }
         }else if ((flags & TypeFlags.Sealed) != 0){
           this.HandleError(Error.InvalidModifier, "sealed");
         }
         t.IsUnsafe = this.inUnsafeCode;
         t.Flags |= flags|TypeFlags.BeforeFieldInit;
       }
       break;
     default:
       Debug.Assert(false);
       break;
   }
   t.Attributes = attributes;
   t.SourceContext = sctx;
   t.DeclaringModule = this.module;
   t.Documentation = this.LastDocComment;
   this.GetNextToken();
   t.Name = this.scanner.GetIdentifier();
   if (Parser.IdentifierOrNonReservedKeyword[this.currentToken])
     this.GetNextToken();
   else{
     this.SkipIdentifierOrNonReservedKeyword();
     if (Parser.IdentifierOrNonReservedKeyword[this.currentToken]){
       t.Name = this.scanner.GetIdentifier();
       this.GetNextToken();
     }
   }
   if (this.currentToken == Token.LessThan)
     this.ParseTypeParameters(t, followers|Token.Colon|Token.LeftBrace|Token.Where);
   if (parentType != null){
     t.Namespace = Identifier.Empty;
     if (parentType.IsGeneric) t.IsGeneric = true;
   }else
     t.Namespace = ns.FullNameId;
   Identifier mangledName = t.Name;
   if (Cci.TargetPlatform.GenericTypeNamesMangleChar != 0) {
     int numPars = t.TemplateParameters == null ? 0 : t.TemplateParameters.Count;
     if (numPars > 0){
       mangledName = new Identifier(t.Name.ToString() + Cci.TargetPlatform.GenericTypeNamesMangleChar + numPars.ToString(), t.Name.SourceContext);
       t.IsGeneric = this.useGenerics;
     }
   }
   t.PartiallyDefines = this.GetCompleteType(t, mangledName, isPartial);
   if (isPartial){
     isPartial = t.PartiallyDefines != null;
     if (!isPartial)
       t.Name = new Identifier(t.Name+" "+t.UniqueKey, t.Name.SourceContext);
   }else
     isPartial = t.PartiallyDefines != null;
   if (parentType != null){
     if (!isPartial || parentType.PartiallyDefines != null)
       parentType.Members.Add(t);
   }else{
     ns.Types.Add(t);
     if (!isPartial) this.AddTypeToModule(t);
   }
   if (this.currentToken == Token.Colon){
     this.GetNextToken();
     t.Interfaces = this.ParseInterfaceList(followers|Token.LeftBrace|Token.Where, true); //The first of these might be the base class, but that is a semantic issue
   }else
     t.Interfaces = new InterfaceList(); //TODO: omit this?
   t.InterfaceExpressions = t.Interfaces;
   while (this.currentToken == Token.Where)
     this.ParseTypeParameterConstraint(t, followers|Token.LeftBrace|Token.Where);
   t.SourceContext.EndPos = this.scanner.endPos;
   SourceContext typeBodyCtx = this.scanner.CurrentSourceContext;
   this.Skip(Token.LeftBrace);
 tryAgain:
   this.ParseTypeMembers(t, followers|Token.RightBrace);
   if (this.currentToken == Token.Namespace){
     this.HandleError(Error.InvalidMemberDecl, this.scanner.CurrentSourceContext.SourceText);
     this.currentToken = Token.Class;
     goto tryAgain;
   }
   int endCol = this.scanner.endPos;
   this.ParseBracket(t.SourceContext, Token.RightBrace, followers|Token.Semicolon, Error.ExpectedRightBrace);
   t.SourceContext.EndPos = endCol;
   t.Name = mangledName;
   if (this.currentToken == Token.Semicolon)
     this.GetNextToken();
   if (this.sink != null){
     typeBodyCtx.EndPos = endCol;
     this.sink.AddCollapsibleRegion(typeBodyCtx, false);
   }
   this.SkipTo(followers|Parser.TypeMemberStart);
   if (!followers[this.currentToken])
     this.SkipTo(followers, Error.NamespaceUnexpected);
   if (isPartial) this.MergeWithCompleteType(t);
 }
Esempio n. 17
0
 private Class CreateWrapperInterface(Interface intf)
 {
   var flags = WrapperTypeFlags(intf);
   var wrapper = new Class(this.assemblyBeingRewritten, null, null, flags, null, intf.Name, SystemTypes.Object, null, null);
   RewriteHelper.TryAddCompilerGeneratedAttribute(wrapper);
   if (intf.TemplateParameters != null)
   {
     Duplicator d = new Duplicator(this.assemblyBeingRewritten, wrapper);
     d.FindTypesToBeDuplicated(intf.TemplateParameters);
     var templateParams = CopyTypeParameterList(wrapper, intf, d);
     wrapper.TemplateParameters = templateParams;
     wrapper.IsGeneric = true;
   }
   return wrapper;
 }
Esempio n. 18
0
 private TypeNode GetCompleteType(TypeNode partialType, Identifier mangledName, bool isPartial){
   Debug.Assert(partialType != null);
   TypeNode completeType = null;
   TypeNode declaringType = partialType.DeclaringType;
   if (declaringType == null)
     completeType = this.module.GetType(partialType.Namespace, mangledName);
   else{
     if (declaringType.PartiallyDefines != null)
       declaringType = declaringType.PartiallyDefines;
     completeType = declaringType.GetNestedType(mangledName);
     declaringType.NestedTypes = null;
   }
   if (completeType == null){
     if (!isPartial) return null;
     if (partialType is Class){
       completeType = new Class();
       ((Class)completeType).BaseClass = (Class)partialType.BaseType;
     }else if (partialType is Struct)
       completeType = new Struct();
     else{
       Debug.Assert(partialType is Interface);
       completeType = new Interface();
     }
     completeType.Attributes = new AttributeList();
     completeType.Flags = partialType.Flags;
     completeType.DeclaringModule = this.module;
     completeType.DeclaringType = declaringType;
     completeType.Interfaces = new InterfaceList();
     completeType.Name = mangledName;
     completeType.Namespace = partialType.Namespace;
     //completeType.Documentation = ; //TODO: figure out if documentation gets merged
     if (declaringType == null)
       this.AddTypeToModule(completeType);
     else
       declaringType.Members.Add(completeType);
     completeType.IsDefinedBy = new TypeNodeList();
   }else{
     if (completeType.IsDefinedBy == null){
       if (isPartial)
         this.HandleError(completeType.Name.SourceContext, Error.MissingPartial, completeType.Name.ToString());
       return null;
     }else if (!isPartial){
       this.HandleError(partialType.Name.SourceContext, Error.MissingPartial, partialType.Name.ToString());
     }else if (completeType.NodeType != partialType.NodeType)
       this.HandleError(partialType.Name.SourceContext, Error.PartialTypeKindConflict, partialType.Name.ToString());
   }
   completeType.IsDefinedBy.Add(partialType);
   return completeType;
 }
Esempio n. 19
0
 public virtual Interface VisitInterfaceReference(Interface Interface)
 {
     return (Interface)this.VisitTypeReference(Interface);
 }
Esempio n. 20
0
 internal static TypeNode/*!*/ GetDummyTypeNode(AssemblyNode declaringAssembly, string/*!*/ nspace, string/*!*/ name, ElementType typeCode)
 {
     TypeNode result = null;
     switch (typeCode)
     {
         case ElementType.Object:
         case ElementType.String:
         case ElementType.Class:
             if (name.Length > 1 && name[0] == 'I' && char.IsUpper(name[1]))
                 result = new Interface();
             else if (name == "MulticastDelegate" || name == "Delegate")
                 result = new Class();
             else if (name.EndsWith("Callback") || name.EndsWith("Delegate") || name == "ThreadStart" || name == "FrameGuardGetter" || name == "GuardThreadStart")
                 result = new DelegateNode();
             else
                 result = new Class();
             break;
         default:
             if (name == "CciMemberKind")
                 result = new EnumNode();
             else
                 result = new Struct();
             break;
     }
     result.Name = Identifier.For(name);
     result.Namespace = Identifier.For(nspace);
     result.DeclaringModule = declaringAssembly;
     return result;
 }
Esempio n. 21
0
 public override Interface VisitInterfaceReference(Interface Interface)
 {
     return this.VisitTypeReference(Interface) as Interface;
 }
 public event Action<Interface> VisitedInterfaceReference; public override Interface VisitInterfaceReference(Interface Interface) { if (VisitedInterfaceReference != null) VisitedInterfaceReference(Interface); return base.VisitInterfaceReference(Interface); }