当前位置: 首页>>代码示例>>C#>>正文


C# Compiler.AssemblyNode类代码示例

本文整理汇总了C#中System.Compiler.AssemblyNode的典型用法代码示例。如果您正苦于以下问题:C# AssemblyNode类的具体用法?C# AssemblyNode怎么用?C# AssemblyNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AssemblyNode类属于System.Compiler命名空间,在下文中一共展示了AssemblyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExtractorVisitor

        public ExtractorVisitor(ContractNodes /*!*/ contractNodes,
            AssemblyNode ultimateTargetAssembly,
            AssemblyNode realAssembly,
            bool verbose,
            bool fSharp)
        {
            Contract.Requires(contractNodes != null);
            Contract.Requires(realAssembly != null);

            this.contractNodes = contractNodes;
            this.verbose = verbose;
            this.fSharp = fSharp;
            this.visibility = new VisibilityHelper();
            this.errorFound = false;
            this.extractionFinalizer = new ExtractionFinalizer(contractNodes);
            this.ultimateTargetAssembly = ultimateTargetAssembly;
            this.realAssembly = realAssembly;

            this.contractNodes.ErrorFound += delegate(CompilerError error)
            {
                // Commented out because the ErrorFound event already had a handler that was printing out a message
                // and so error messages were getting printed out twice
                //if (!error.IsWarning || warningLevel > 0) {
                //  Console.WriteLine(error.ToString());
                //}
                errorFound |= !error.IsWarning;
            };

            this.TaskType = new Cache<TypeNode>(() => HelperMethods.FindType(realAssembly, Identifier.For("System.Threading.Tasks"), Identifier.For("Task")));

            this.GenericTaskType = new Cache<TypeNode>(() =>
                HelperMethods.FindType(realAssembly, Identifier.For("System.Threading.Tasks"),
                    Identifier.For("Task" + TargetPlatform.GenericTypeNamesMangleChar + "1")));
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:34,代码来源:ExtractorVisitor.cs

示例2: ClousotExtractor

 public ClousotExtractor(ContractNodes contractNodes, AssemblyNode ultimateTargetAssembly,
     AssemblyNode realAssembly, Action<System.CodeDom.Compiler.CompilerError> errorHandler)
     : base(contractNodes, ultimateTargetAssembly, realAssembly)
 {
     Contract.Requires(contractNodes != null);
     Contract.Requires(realAssembly != null);
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:7,代码来源:ClousotExtractor.cs

示例3: CurrentState

 public CurrentState(AssemblyNode assembly) {
   this.Assembly = assembly;
   this.Type = null;
   this.Method = null;
   this.assemblySuppressed = null;
   this.typeSuppressed = null;
   this.methodSuppressed = null;
 }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:8,代码来源:Checker.cs

示例4: FindShadow

        public static Method FindShadow(this Method method, AssemblyNode shadowAssembly)
        {
            var shadowParent = method.DeclaringType.FindShadow(shadowAssembly);

            if (shadowParent == null) return null;

            return shadowParent.FindShadow(method);
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:8,代码来源:ExtractorExtensions.cs

示例5: Add

 public virtual void Add(AssemblyNode assembly) {
     if (assembly == null) throw new ArgumentNullException("assembly");
     string name = assembly.StrongName;
     assembly.AssemblyReferenceResolution += new Module.AssemblyReferenceResolver(ResolveReference);
     assembly.AssemblyReferenceResolutionAfterProbingFailed += new Module.AssemblyReferenceResolver(UnresolvedReference);
     cache[name] = assembly;
     //Console.WriteLine("added {0}; cache now contains {1}", name, cache.Count);
 }
开发者ID:hnlshzx,项目名称:DotNetOpenAuth,代码行数:8,代码来源:AssemblyResolver.cs

示例6: GetTypeNodeFor

 internal TypeNode GetTypeNodeFor(AssemblyNode assembly, Type t) {
   if (t.IsArray) {
     int rank = t.GetArrayRank();
     Type et = t.GetElementType();
     TypeNode type = assembly.GetType(Identifier.For(et.Namespace), Identifier.For(et.Name));
     return type.GetArrayType(rank);
   } else {        
     return assembly.GetType(Identifier.For(t.Namespace), Identifier.For(t.Name));
   }    
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:10,代码来源:Serializer.cs

示例7: CopyOutOfBandContracts

        public CopyOutOfBandContracts(AssemblyNode targetAssembly, AssemblyNode sourceAssembly,
            ContractNodes contractNodes, ContractNodes targetContractNodes)
        {
            Contract.Requires(targetAssembly != null);
            Contract.Requires(sourceAssembly != null);
            Contract.Requires(contractNodes != null);

            if (targetAssembly == sourceAssembly)
            {
                // this happened when a reference assembly for mscorlib had the assembly name "mscorlib"
                // instead of "mscorlib.Contracts" because only one assembly named "mscorlib" can be
                // loaded
                throw new ExtractorException("CopyOutOfBandContracts was given the same assembly as both the source and target!");
            }

            this.outOfBandDuplicator = new ForwardingDuplicator(targetAssembly, null, contractNodes, targetContractNodes);
            this.targetAssembly = targetAssembly;

            FuzzilyForwardReferencesFromSource2Target(targetAssembly, sourceAssembly);

            CopyMissingMembers();

            // FixupMissingProperties(); shouldn't be needed with new duplicator
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:24,代码来源:CopyOutOfBandContracts.cs

示例8: SkipThisTypeDueToMismatchInReferenceAssemblyPlatform

        private bool SkipThisTypeDueToMismatchInReferenceAssemblyPlatform(AssemblyNode ultimateTargetAssembly,
            TypeNode typeNode)
        {
            if (ultimateTargetAssembly == null) return false;

            if (typeNode == this.contractNodes.ContractClass)
                return false; // don't skip contract methods as we need to extract their contracts

            if (HelperMethods.IsCompilerGenerated(typeNode)) return false; // don't skip closures etc.
            var typeWithSeparateContractClass = HelperMethods.IsContractTypeForSomeOtherTypeUnspecialized(typeNode, this.contractNodes);

            if (typeWithSeparateContractClass != null)
            {
                typeNode = typeWithSeparateContractClass; // see if this one is skipped
            }

            // now see if we have corresponding target type
            if (typeNode.FindShadow(ultimateTargetAssembly) != null) return false; // have target

            return true; // skip it.
        }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:21,代码来源:ExtractorVisitor.cs

示例9: GetPossiblyNestedType

        private static TypeNode GetPossiblyNestedType(AssemblyNode assem, string namespaceName, string className)
        {
            Contract.Requires(assem != null);
            Contract.Requires(className != null);

            var ns = Identifier.For(namespaceName);

            string[] pieces = className.Split('.');

            // Get outermost type
            string outerMost = pieces[0];
            TypeNode t = assem.GetType(ns, Identifier.For(outerMost));

            if (t == null) return null;

            for (int i = 1; i < pieces.Length; i++)
            {
                var piece = pieces[i];
                t = t.GetNestedType(Identifier.For(piece));
                
                if (t == null) return null;
            }

            return t;
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:25,代码来源:Program.cs

示例10: VisitForPostCheck

 public void VisitForPostCheck(AssemblyNode assemblyNode)
 {
     this.VisitAssembly(assemblyNode);
 }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:4,代码来源:PostExtractorChecker.cs

示例11: ReadAssembly

 private AssemblyNode ReadAssembly(AssemblyNode.PostAssemblyLoadProcessor postLoadEvent){
开发者ID:modulexcite,项目名称:IL2JS,代码行数:1,代码来源:Reader.cs

示例12: IdentifyContractAssemblyIfReferenced

        private static ContractNodes IdentifyContractAssemblyIfReferenced(ContractNodes contracts, AssemblyNode assemblyToVisit)
        {
            Contract.Requires(assemblyToVisit != null);

            if (contracts != null)
            {
                AssemblyNode assemblyContractsLiveIn = contracts.ContractClass == null
                    ? null
                    : contracts.ContractClass.DeclaringModule as AssemblyNode;

                if (assemblyContractsLiveIn != null)
                {
                    if (assemblyContractsLiveIn == assemblyToVisit)
                    {
                        return contracts;
                    }
                    
                    string nameOfAssemblyContainingContracts = assemblyContractsLiveIn.Name;
                    
                    Contract.Assume(assemblyToVisit.AssemblyReferences != null);
                    
                    foreach (var ar in assemblyToVisit.AssemblyReferences)
                    {
                        Contract.Assume(ar != null);

                        if (ar.Name == nameOfAssemblyContainingContracts)
                        {
                            // just do name matching to avoid loading the referenced assembly
                            return contracts;
                        }
                    }
                }
            }

            return null;
        }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:36,代码来源:Extractor.cs

示例13: GetRuntimeContractsAttributeCtor

    /// <summary>
    /// Tries to reuse or create the attribute
    /// </summary>
    private static InstanceInitializer GetRuntimeContractsAttributeCtor(AssemblyNode assembly)
    {
      EnumNode runtimeContractsFlags = assembly.GetType(ContractNodes.ContractNamespace, Identifier.For("RuntimeContractsFlags")) as EnumNode;
      Class RuntimeContractsAttributeClass = assembly.GetType(ContractNodes.ContractNamespace, Identifier.For("RuntimeContractsAttribute")) as Class;

      if (runtimeContractsFlags == null)
      {
        #region Add [Flags]
        Member flagsConstructor = RewriteHelper.flagsAttributeNode.GetConstructor();
        AttributeNode flagsAttribute = new AttributeNode(new MemberBinding(null, flagsConstructor), null, AttributeTargets.Class);
        #endregion Add [Flags]
        runtimeContractsFlags = new EnumNode(assembly,
          null, /* declaringType */
          new AttributeList(2),
          TypeFlags.Sealed,
          ContractNodes.ContractNamespace,
          Identifier.For("RuntimeContractsFlags"),
          new InterfaceList(),
          new MemberList());
        runtimeContractsFlags.Attributes.Add(flagsAttribute);
        RewriteHelper.TryAddCompilerGeneratedAttribute(runtimeContractsFlags);
        runtimeContractsFlags.UnderlyingType = SystemTypes.Int32;

        Type copyFrom = typeof(RuntimeContractEmitFlags);
        foreach (System.Reflection.FieldInfo fi in copyFrom.GetFields())
        {
          if (fi.IsLiteral)
          {
            AddEnumValue(runtimeContractsFlags, fi.Name, fi.GetRawConstantValue());
          }
        }
        assembly.Types.Add(runtimeContractsFlags);

      }


      InstanceInitializer ctor = (RuntimeContractsAttributeClass == null) ? null : RuntimeContractsAttributeClass.GetConstructor(runtimeContractsFlags);

      if (RuntimeContractsAttributeClass == null)
      {
        RuntimeContractsAttributeClass = new Class(assembly,
          null, /* declaringType */
          new AttributeList(),
          TypeFlags.Sealed,
          ContractNodes.ContractNamespace,
          Identifier.For("RuntimeContractsAttribute"),
          SystemTypes.Attribute,
          new InterfaceList(),
          new MemberList(0));

        RewriteHelper.TryAddCompilerGeneratedAttribute(RuntimeContractsAttributeClass);
        assembly.Types.Add(RuntimeContractsAttributeClass);
      }
      if (ctor == null) {

        Block returnBlock = new Block(new StatementList(new Return()));

        Block body = new Block(new StatementList());
        Block b = new Block(new StatementList());
        ParameterList pl = new ParameterList();
        Parameter levelParameter = new Parameter(Identifier.For("contractFlags"), runtimeContractsFlags);
        pl.Add(levelParameter);

        ctor = new InstanceInitializer(RuntimeContractsAttributeClass, null, pl, body);
        ctor.Flags = MethodFlags.Assembly | MethodFlags.HideBySig | MethodFlags.SpecialName | MethodFlags.RTSpecialName;

        Method baseCtor = SystemTypes.Attribute.GetConstructor();

        b.Statements.Add(new ExpressionStatement(new MethodCall(new MemberBinding(null, baseCtor), new ExpressionList(ctor.ThisParameter))));
        b.Statements.Add(returnBlock);
        body.Statements.Add(b);

        RuntimeContractsAttributeClass.Members.Add(ctor);
      }

      return ctor;
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:80,代码来源:Rewriter.cs

示例14: SetRuntimeContractFlag

    /// <summary>
    /// Adds a flag to an assembly that designates it as having runtime contract checks.
    /// Does this by defining the type of the attribute and then marking the assembly with
    /// and instance of that attribute.
    /// </summary>
    /// <param name="assembly">Assembly to flag.</param>
    private void SetRuntimeContractFlag(AssemblyNode assembly) {

      InstanceInitializer ctor = GetRuntimeContractsAttributeCtor(assembly);
      ExpressionList args = new ExpressionList();
      args.Add(new Literal(this.contractEmitFlags, ctor.Parameters[0].Type));
      AttributeNode attribute = new AttributeNode(new MemberBinding(null, ctor), args, AttributeTargets.Assembly);
      assembly.Attributes.Add(attribute);
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:14,代码来源:Rewriter.cs

示例15: VisitAssembly

    public override void VisitAssembly(AssemblyNode assembly)
    {
      // Don't rewrite assemblies twice.
      if (ContractNodes.IsAlreadyRewritten(assembly)) {
        throw new RewriteException("Cannot rewrite an assembly that has already been rewritten!");
      }

      this.module = assembly;

      this.AdaptRuntimeOptionsBasedOnAttributes(assembly.Attributes);

      // Extract all inline foxtrot contracts and place them in the object model.
      //if (this.extractContracts) {
      //  new Extractor(rewriterNodes, this.Verbose, this.Decompile).Visit(assembly);
      //}
      base.VisitAssembly(assembly);

      this.runtimeContracts.Commit();

      // Set the flag that indicates the assembly has been rewritten.
      SetRuntimeContractFlag(assembly);

      // Add wrapper types for call-site requires. We do it here to avoid visiting them multiple times
      foreach (TypeNode t in this.wrapperTypes.Values)
      {
        assembly.Types.Add(t);
      }

      // in principle we shouldn't have old and result left over, but because of the call-site requires copying
      // we end up having them in closures that were used in ensures but not needed at call site requires
#if !DEBUG || true
      CleanUpOldAndResult cuoar = new CleanUpOldAndResult();
      assembly = cuoar.VisitAssembly(assembly);
#endif
      RemoveContractClasses rcc = new RemoveContractClasses();
      rcc.VisitAssembly(assembly);
    }
开发者ID:nbulp,项目名称:CodeContracts,代码行数:37,代码来源:Rewriter.cs


注:本文中的System.Compiler.AssemblyNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。