• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CSharpCompilation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax)
 {
     var method = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetObjectAtAddressMethodName,
         (c, n, s) =>
         {
             var parameterType = compilation.GetSpecialType(SpecialType.System_UInt64);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 this.Type,
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)));
         });
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_address),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     Debug.Assert(call.Type == this.Type);
     return call;
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:ObjectAddressLocalSymbol.cs


示例2: GetSymbolsForReferences

        internal static AssemblySymbol[] GetSymbolsForReferences(
            CSharpCompilation[] compilations = null,
            byte[][] bytes = null,
            MetadataReference[] mrefs = null,
            CSharpCompilationOptions options = null)
        {
            var refs = new List<MetadataReference>();

            if (compilations != null)
            {
                foreach (var c in compilations)
                {
                    refs.Add(new CSharpCompilationReference(c));
                }
            }

            if (bytes != null)
            {
                foreach (var b in bytes)
                {
                    refs.Add(new MetadataImageReference(b.AsImmutableOrNull()));
                }
            }

            if (mrefs != null)
            {
                refs.AddRange(mrefs);
            }

            var tc1 = CSharpCompilation.Create(assemblyName: "Dummy", options: options ?? TestOptions.ReleaseDll, syntaxTrees: new SyntaxTree[0], references: refs);

           return (from @ref in refs select tc1.GetReferencedAssemblySymbol(@ref)).ToArray();
        }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:33,代码来源:MetadataTestHelpers.cs


示例3: PlaceholderLocalRewriter

 private PlaceholderLocalRewriter(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, DiagnosticBag diagnostics)
 {
     _compilation = compilation;
     _container = container;
     _declaredLocals = declaredLocals;
     _diagnostics = diagnostics;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:PlaceholderLocalRewriter.cs


示例4: Rewrite

        internal static BoundNode Rewrite(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, BoundNode node)
        {
            var builder = ArrayBuilder<BoundStatement>.GetInstance();
            bool hasChanged;

            // Rewrite top-level declarations only.
            switch (node.Kind)
            {
                case BoundKind.LocalDeclaration:
                    RewriteLocalDeclaration(compilation, container, declaredLocals, builder, (BoundLocalDeclaration)node);
                    hasChanged = true;
                    break;
                case BoundKind.MultipleLocalDeclarations:
                    foreach (var declaration in ((BoundMultipleLocalDeclarations)node).LocalDeclarations)
                    {
                        RewriteLocalDeclaration(compilation, container, declaredLocals, builder, declaration);
                    }
                    hasChanged = true;
                    break;
                default:
                    hasChanged = false;
                    break;
            }

            if (hasChanged)
            {
                node = new BoundBlock(node.Syntax, ImmutableArray<LocalSymbol>.Empty, builder.ToImmutable()) { WasCompilerGenerated = true };
            }

            builder.Free();
            return node;
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:32,代码来源:LocalDeclarationRewriter.cs


示例5: ResolveBounds

        /// <summary>
        /// Determine the effective base type, effective interface set, and set of type
        /// parameters (excluding cycles) from the type parameter constraints. Conflicts
        /// within the constraints and constraint types are returned as diagnostics.
        /// 'inherited' should be true if the type parameters are from an overridden
        /// generic method. In those cases, additional constraint checks are applied.
        /// </summary>
        public static TypeParameterBounds ResolveBounds(
            this TypeParameterSymbol typeParameter,
            AssemblySymbol corLibrary,
            ConsList<TypeParameterSymbol> inProgress,
            ImmutableArray<TypeSymbol> constraintTypes,
            bool inherited,
            CSharpCompilation currentCompilation,
            DiagnosticBag diagnostics)
        {
            var diagnosticsBuilder = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
            ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
            var bounds = typeParameter.ResolveBounds(corLibrary, inProgress, constraintTypes, inherited, currentCompilation, diagnosticsBuilder, ref useSiteDiagnosticsBuilder);

            if (useSiteDiagnosticsBuilder != null)
            {
                diagnosticsBuilder.AddRange(useSiteDiagnosticsBuilder);
            }

            foreach (var pair in diagnosticsBuilder)
            {
                diagnostics.Add(new CSDiagnostic(pair.DiagnosticInfo, pair.TypeParameter.Locations[0]));
            }

            diagnosticsBuilder.Free();
            return bounds;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:33,代码来源:ConstraintsHelper.cs


示例6: CheckCompilationSyntaxTrees

        private static void CheckCompilationSyntaxTrees(CSharpCompilation compilation, params SyntaxTree[] expectedSyntaxTrees)
        {
            ImmutableArray<SyntaxTree> actualSyntaxTrees = compilation.SyntaxTrees;

            int numTrees = expectedSyntaxTrees.Length;

            Assert.Equal(numTrees, actualSyntaxTrees.Length);
            for (int i = 0; i < numTrees; i++)
            {
                Assert.Equal(expectedSyntaxTrees[i], actualSyntaxTrees[i]);
            }

            for (int i = 0; i < numTrees; i++)
            {
                for (int j = 0; j < numTrees; j++)
                {
                    Assert.Equal(Math.Sign(compilation.CompareSyntaxTreeOrdering(expectedSyntaxTrees[i], expectedSyntaxTrees[j])), Math.Sign(i.CompareTo(j)));
                }
            }

            var types = expectedSyntaxTrees.Select(tree => compilation.GetSemanticModel(tree).GetDeclaredSymbol(tree.GetCompilationUnitRoot().Members.Single())).ToArray();
            for (int i = 0; i < numTrees; i++)
            {
                for (int j = 0; j < numTrees; j++)
                {
                    Assert.Equal(Math.Sign(compilation.CompareSourceLocations(types[i].Locations[0], types[j].Locations[0])), Math.Sign(i.CompareTo(j)));
                }
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:29,代码来源:CompilationCreationTests.cs


示例7: RewriteLocalInternal

 private static BoundExpression RewriteLocalInternal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, LocalSymbol local)
 {
     var parameterType = compilation.GetSpecialType(SpecialType.System_String);
     var getValueMethod = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetVariableValueMethodName,
         (c, n, s) =>
         {
             var returnType = compilation.GetSpecialType(SpecialType.System_Object);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 returnType,
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)));
         });
     var getAddressMethod = container.GetOrAddSynthesizedMethod(
         ExpressionCompilerConstants.GetVariableAddressMethodName,
         (c, n, s) =>
         {
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 m => ImmutableArray.Create<TypeParameterSymbol>(new SimpleTypeParameterSymbol(m, 0, "<>T")),
                 m => m.TypeParameters[0], // return type is <>T&
                 m => ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(m, parameterType, ordinal: 0, refKind: RefKind.None)),
                 returnValueIsByRef: true);
         });
     return new BoundPseudoVariable(
         syntax,
         local,
         new ObjectIdExpressions(compilation, getValueMethod, getAddressMethod),
         local.Type);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:34,代码来源:ObjectIdLocalSymbol.cs


示例8: CompilationContext

        /// <summary>
        /// Create a context to compile expressions within a method scope.
        /// </summary>
        internal CompilationContext(
            CSharpCompilation compilation,
            MethodSymbol currentFrame,
            ImmutableArray<LocalSymbol> locals,
            InScopeHoistedLocals inScopeHoistedLocals,
            MethodDebugInfo<TypeSymbol, LocalSymbol> methodDebugInfo,
            CSharpSyntaxNode syntax)
        {
            Debug.Assert((syntax == null) || (syntax is ExpressionSyntax) || (syntax is LocalDeclarationStatementSyntax));

            // TODO: syntax.SyntaxTree should probably be added to the compilation,
            // but it isn't rooted by a CompilationUnitSyntax so it doesn't work (yet).
            _currentFrame = currentFrame;
            _syntax = syntax;
            _methodNotType = !locals.IsDefault;

            // NOTE: Since this is done within CompilationContext, it will not be cached.
            // CONSIDER: The values should be the same everywhere in the module, so they
            // could be cached.  
            // (Catch: what happens in a type context without a method def?)
            this.Compilation = GetCompilationWithExternAliases(compilation, methodDebugInfo.ExternAliasRecords);

            // Each expression compile should use a unique compilation
            // to ensure expression-specific synthesized members can be
            // added (anonymous types, for instance).
            Debug.Assert(this.Compilation != compilation);

            this.NamespaceBinder = CreateBinderChain(
                this.Compilation,
                (PEModuleSymbol)currentFrame.ContainingModule,
                currentFrame.ContainingNamespace,
                methodDebugInfo.ImportRecordGroups);

            if (_methodNotType)
            {
                _locals = locals;
                ImmutableArray<string> displayClassVariableNamesInOrder;
                GetDisplayClassVariables(
                    currentFrame,
                    _locals,
                    inScopeHoistedLocals,
                    out displayClassVariableNamesInOrder,
                    out _displayClassVariables,
                    out _hoistedParameterNames);
                Debug.Assert(displayClassVariableNamesInOrder.Length == _displayClassVariables.Count);
                _localsForBinding = GetLocalsForBinding(_locals, displayClassVariableNamesInOrder, _displayClassVariables);
            }
            else
            {
                _locals = ImmutableArray<LocalSymbol>.Empty;
                _displayClassVariables = ImmutableDictionary<string, DisplayClassVariable>.Empty;
                _localsForBinding = ImmutableArray<LocalSymbol>.Empty;
            }

            // Assert that the cheap check for "this" is equivalent to the expensive check for "this".
            Debug.Assert(
                _displayClassVariables.ContainsKey(GeneratedNames.ThisProxyFieldName()) ==
                _displayClassVariables.Values.Any(v => v.Kind == DisplayClassVariableKind.This));
        }
开发者ID:rgani,项目名称:roslyn,代码行数:62,代码来源:CompilationContext.cs


示例9: RewriteLocalInternal

 private static BoundExpression RewriteLocalInternal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, LocalSymbol local)
 {
     return new BoundPseudoVariable(
         syntax,
         local,
         new ObjectIdExpressions(compilation),
         local.Type);
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:ObjectIdLocalSymbol.cs


示例10: GetAwaitExpressionInfo

 private AwaitExpressionInfo GetAwaitExpressionInfo(string text, out CSharpCompilation compilation, params DiagnosticDescription[] diagnostics)
 {
     var tree = Parse(text, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp5));
     var comp = CreateCompilationWithMscorlib45(new SyntaxTree[] { tree }, new MetadataReference[] { SystemRef });
     comp.VerifyDiagnostics(diagnostics);
     compilation = comp;
     var syntaxNode = (AwaitExpressionSyntax)tree.FindNodeOrTokenByKind(SyntaxKind.AwaitExpression).AsNode();
     var treeModel = comp.GetSemanticModel(tree);
     return treeModel.GetAwaitExpressionInfo(syntaxNode);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:10,代码来源:AwaitExpressionTests.cs


示例11: RewriteLocalDeclaration

        private static void RewriteLocalDeclaration(
            CSharpCompilation compilation,
            EENamedTypeSymbol container,
            HashSet<LocalSymbol> declaredLocals,
            ArrayBuilder<BoundStatement> statements,
            BoundLocalDeclaration node)
        {
            Debug.Assert(node.ArgumentsOpt.IsDefault);

            var local = node.LocalSymbol;
            var syntax = node.Syntax;

            declaredLocals.Add(local);

            var voidType = compilation.GetSpecialType(SpecialType.System_Void);
            var objectType = compilation.GetSpecialType(SpecialType.System_Object);
            var typeType = compilation.GetWellKnownType(WellKnownType.System_Type);
            var stringType = compilation.GetSpecialType(SpecialType.System_String);

            // <>CreateVariable(Type type, string name)
            var method = container.GetOrAddSynthesizedMethod(
                ExpressionCompilerConstants.CreateVariableMethodName,
                (c, n, s) => new PlaceholderMethodSymbol(
                    c,
                    s,
                    n,
                    voidType,
                    m => ImmutableArray.Create<ParameterSymbol>(
                        new SynthesizedParameterSymbol(m, typeType, ordinal: 0, refKind: RefKind.None),
                        new SynthesizedParameterSymbol(m, stringType, ordinal: 1, refKind: RefKind.None))));
            var type = new BoundTypeOfOperator(syntax, new BoundTypeExpression(syntax, aliasOpt: null, type: local.Type), null, typeType);
            var name = new BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType);
            var call = BoundCall.Synthesized(
                syntax,
                receiverOpt: null,
                method: method,
                arguments: ImmutableArray.Create<BoundExpression>(type, name));
            statements.Add(new BoundExpressionStatement(syntax, call));

            var initializer = node.InitializerOpt;
            if (initializer != null)
            {
                // Generate assignment to local. The assignment will
                // be rewritten in PlaceholderLocalRewriter.
                var assignment = new BoundAssignmentOperator(
                    syntax,
                    new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type),
                    initializer,
                    RefKind.None,
                    local.Type);
                statements.Add(new BoundExpressionStatement(syntax, assignment));
            }
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:53,代码来源:LocalDeclarationRewriter.cs


示例12: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax, DiagnosticBag diagnostics)
 {
     var method = GetIntrinsicMethod(compilation, ExpressionCompilerConstants.GetReturnValueMethodName);
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_index),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     return ConvertToLocalType(compilation, call, this.Type, diagnostics);
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:14,代码来源:ReturnValueLocalSymbol.cs


示例13: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, SyntaxNode syntax, DiagnosticBag diagnostics)
 {
     var method = GetIntrinsicMethod(compilation, ExpressionCompilerConstants.GetObjectAtAddressMethodName);
     var argument = new BoundLiteral(
         syntax,
         Microsoft.CodeAnalysis.ConstantValue.Create(_address),
         method.Parameters[0].Type);
     var call = BoundCall.Synthesized(
         syntax,
         receiverOpt: null,
         method: method,
         arguments: ImmutableArray.Create<BoundExpression>(argument));
     Debug.Assert(call.Type == this.Type);
     return call;
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:15,代码来源:ObjectAddressLocalSymbol.cs


示例14: LambdaSymbol

 public LambdaSymbol(
     CSharpCompilation compilation,
     Symbol containingSymbol,
     UnboundLambda unboundLambda,
     ImmutableArray<ParameterSymbol> delegateParameters,
     TypeSymbol returnType)
 {
     this.containingSymbol = containingSymbol;
     this.messageID = unboundLambda.Data.MessageID;
     this.syntax = unboundLambda.Syntax;
     this.returnType = returnType;
     this.isSynthesized = unboundLambda.WasCompilerGenerated;
     this.isAsync = unboundLambda.IsAsync;
     // No point in making this lazy. We are always going to need these soon after creation of the symbol.
     this.parameters = MakeParameters(compilation, unboundLambda, delegateParameters);
 }
开发者ID:afrog33k,项目名称:csnative,代码行数:16,代码来源:LambdaSymbol.cs


示例15: RewriteLocalDeclaration

        private static void RewriteLocalDeclaration(
            CSharpCompilation compilation,
            EENamedTypeSymbol container,
            HashSet<LocalSymbol> declaredLocals,
            ArrayBuilder<BoundStatement> statements,
            BoundLocalDeclaration node)
        {
            Debug.Assert(node.ArgumentsOpt.IsDefault);

            var local = node.LocalSymbol;
            var syntax = node.Syntax;

            declaredLocals.Add(local);

            var typeType = compilation.GetWellKnownType(WellKnownType.System_Type);
            var stringType = compilation.GetSpecialType(SpecialType.System_String);
            var guidConstructor = (MethodSymbol)compilation.GetWellKnownTypeMember(WellKnownMember.System_Guid__ctor);

            // CreateVariable(Type type, string name)
            var method = PlaceholderLocalSymbol.GetIntrinsicMethod(compilation, ExpressionCompilerConstants.CreateVariableMethodName);
            var type = new BoundTypeOfOperator(syntax, new BoundTypeExpression(syntax, aliasOpt: null, type: local.Type), null, typeType);
            var name = new BoundLiteral(syntax, ConstantValue.Create(local.Name), stringType);

            bool hasCustomTypeInfoPayload;
            var customTypeInfoPayload = GetCustomTypeInfoPayload(local, syntax, compilation, out hasCustomTypeInfoPayload);
            var customTypeInfoPayloadId = GetCustomTypeInfoPayloadId(syntax, guidConstructor, hasCustomTypeInfoPayload);
            var call = BoundCall.Synthesized(
                syntax,
                receiverOpt: null,
                method: method,
                arguments: ImmutableArray.Create(type, name, customTypeInfoPayloadId, customTypeInfoPayload));
            statements.Add(new BoundExpressionStatement(syntax, call));

            var initializer = node.InitializerOpt;
            if (initializer != null)
            {
                // Generate assignment to local. The assignment will
                // be rewritten in PlaceholderLocalRewriter.
                var assignment = new BoundAssignmentOperator(
                    syntax,
                    new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type),
                    initializer,
                    RefKind.None,
                    local.Type);
                statements.Add(new BoundExpressionStatement(syntax, assignment));
            }
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:47,代码来源:LocalDeclarationRewriter.cs


示例16: CompareConstructedErrorTypes

        private void CompareConstructedErrorTypes(CSharpCompilation compilation, bool missingTypes, bool fromSource)
        {
            // Get all root types.
            var allTypes = compilation.GlobalNamespace.GetTypeMembers();

            // Get base class for each type named "C?".
            var types = new[] { "C1", "C2", "C3", "C4", "C5", "C6", "C7" }.Select(name => allTypes.First(t => t.Name == name).BaseType).ToArray();
            foreach (var type in types)
            {
                var constructedFrom = type.ConstructedFrom;
                Assert.NotEqual(type, constructedFrom);
                if (missingTypes)
                {
                    Assert.True(type.IsErrorType());
                    Assert.True(constructedFrom.IsErrorType());
                    var extendedError = constructedFrom as ExtendedErrorTypeSymbol;
                    if (fromSource)
                    {
                        Assert.NotNull(extendedError);
                    }
                    else
                    {
                        Assert.Null(extendedError);
                    }
                }
                else
                {
                    Assert.False(type.IsErrorType());
                    Assert.False(constructedFrom.IsErrorType());
                }
            }

            // Compare pairs of types. The only error types that
            // should compare equal are C6 and C7.
            const int n = 7;
            for (int i = 0; i < n - 1; i++)
            {
                var typeA = types[i];
                for (int j = i + 1; j < n; j++)
                {
                    var typeB = types[j];
                    bool expectedEqual = (i == 5) && (j == 6);
                    Assert.Equal(typeA == typeB, expectedEqual);
                }
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:46,代码来源:ErrorTypeSymbolTests.cs


示例17: CreateTypeContext

        internal static EvaluationContext CreateTypeContext(
            CSharpCompilation compilation,
            Guid moduleVersionId,
            int typeToken)
        {
            Debug.Assert(MetadataTokens.Handle(typeToken).Kind == HandleKind.TypeDefinition);

            var currentType = compilation.GetType(moduleVersionId, typeToken);
            Debug.Assert((object)currentType != null);
            var currentFrame = new SynthesizedContextMethodSymbol(currentType);
            return new EvaluationContext(
                null,
                compilation,
                currentFrame,
                default(ImmutableArray<LocalSymbol>),
                InScopeHoistedLocals.Empty,
                MethodDebugInfo<TypeSymbol, LocalSymbol>.None);
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:18,代码来源:EvaluationContext.cs


示例18: EvaluationContext

        private EvaluationContext(
            MethodContextReuseConstraints? methodContextReuseConstraints,
            CSharpCompilation compilation,
            MethodSymbol currentFrame,
            ImmutableArray<LocalSymbol> locals,
            InScopeHoistedLocals inScopeHoistedLocals,
            MethodDebugInfo<TypeSymbol, LocalSymbol> methodDebugInfo)
        {
            Debug.Assert(inScopeHoistedLocals != null);
            Debug.Assert(methodDebugInfo != null);

            this.MethodContextReuseConstraints = methodContextReuseConstraints;
            this.Compilation = compilation;
            _currentFrame = currentFrame;
            _locals = locals;
            _inScopeHoistedLocals = inScopeHoistedLocals;
            _methodDebugInfo = methodDebugInfo;
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:18,代码来源:EvaluationContext.cs


示例19: RewriteLocal

 internal override BoundExpression RewriteLocal(CSharpCompilation compilation, EENamedTypeSymbol container, CSharpSyntaxNode syntax)
 {
     Debug.Assert(this.Name == this.Name.ToLowerInvariant());
     var method = container.GetOrAddSynthesizedMethod(
         this.Name,
         (c, n, s) =>
         {
             var returnType = compilation.GetWellKnownType(WellKnownType.System_Exception);
             return new PlaceholderMethodSymbol(
                 c,
                 s,
                 n,
                 returnType,
                 m => ImmutableArray<ParameterSymbol>.Empty);
         });
     var call = BoundCall.Synthesized(syntax, receiverOpt: null, method: method);
     return ConvertToLocalType(compilation, call, this.Type);
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:18,代码来源:ExceptionLocalSymbol.cs


示例20: ClassDependsClosure

        private static void ClassDependsClosure(TypeSymbol type, CSharpCompilation currentCompilation, HashSet<Symbol> partialClosure)
        {
            if ((object)type == null)
            {
                return;
            }

            var namedType = type.OriginalDefinition as NamedTypeSymbol;
            if ((object)namedType != null && partialClosure.Add(namedType))
            {
                ClassDependsClosure(namedType.GetDeclaredBaseType(null), currentCompilation, partialClosure);

                // containment is interesting only for the current compilation
                if (currentCompilation != null && namedType.IsFromCompilation(currentCompilation))
                {
                    ClassDependsClosure(namedType.ContainingType, currentCompilation, partialClosure);
                }
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:19,代码来源:BaseTypeAnalysis.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharpCompilationOptions类代码示例发布时间:2022-05-24
下一篇:
C# CSharpBinderFlags类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap