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


C# EvaluationContext.CompileExpression方法代码示例

本文整理汇总了C#中EvaluationContext.CompileExpression方法的典型用法代码示例。如果您正苦于以下问题:C# EvaluationContext.CompileExpression方法的具体用法?C# EvaluationContext.CompileExpression怎么用?C# EvaluationContext.CompileExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EvaluationContext的用法示例。


在下文中一共展示了EvaluationContext.CompileExpression方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VerifyNoThis

        private static void VerifyNoThis(EvaluationContext context)
        {
            string error;
            var testData = new CompilationTestData();
            context.CompileExpression("this", out error, testData);
            Assert.Contains(error, new[]
            {
                "error CS0026: Keyword 'this' is not valid in a static property, static method, or static field initializer",
                "error CS0027: Keyword 'this' is not available in the current context",
            });

            testData = new CompilationTestData();
            context.CompileExpression("base.ToString()", out error, testData);
            Assert.Contains(error, new[]
            {
                "error CS1511: Keyword 'base' is not available in a static method",
                "error CS1512: Keyword 'base' is not available in the current context",
            });

            var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
            string typeName;
            testData = new CompilationTestData();
            var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
            Assert.NotNull(assembly);
            AssertEx.None(locals, l => l.LocalName.Contains("this"));
            locals.Free();
        }
开发者ID:hyldrim,项目名称:roslyn,代码行数:27,代码来源:HoistedThisTests.cs

示例2: VerifyHasThis

        private static void VerifyHasThis(EvaluationContext context, string expectedType, string expectedIL)
        {
            var locals = ArrayBuilder<LocalAndMethod>.GetInstance();
            string typeName;
            var testData = new CompilationTestData();
            var assembly = context.CompileGetLocals(locals, argumentsOnly: false, typeName: out typeName, testData: testData);
            Assert.NotNull(assembly);
            Assert.NotEqual(assembly.Count, 0);
            var localAndMethod = locals.Single(l => l.LocalName == "this");
            if (expectedIL != null)
            {
                VerifyMethodData(testData.Methods.Single(m => m.Key.Contains(localAndMethod.MethodName)).Value, expectedType, expectedIL);
            }
            locals.Free();

            string error;
            testData = new CompilationTestData();
            context.CompileExpression("this", out error, testData);
            Assert.Null(error);
            if (expectedIL != null)
            {
                VerifyMethodData(testData.Methods.Single(m => m.Key.Contains("<>m0")).Value, expectedType, expectedIL);
            }
        }
开发者ID:hyldrim,项目名称:roslyn,代码行数:24,代码来源:HoistedThisTests.cs

示例3: CheckResultFlags

 private static void CheckResultFlags(EvaluationContext context, string expr, DkmClrCompilationResultFlags expectedFlags, string expectedError = null)
 {
     ResultProperties resultProperties;
     string error;
     var testData = new CompilationTestData();
     var result = context.CompileExpression(expr, out resultProperties, out error, testData);
     Assert.Equal(expectedError, error);
     Assert.NotEqual(expectedError == null, result == null);
     Assert.Equal(expectedFlags, resultProperties.Flags);
 }
开发者ID:rgani,项目名称:roslyn,代码行数:10,代码来源:ExpressionCompilerTests.cs

示例4: CompileDeclaration

        private static void CompileDeclaration(EvaluationContext context, string declaration, out DkmClrCompilationResultFlags flags, out CompilationTestData testData)
        {
            testData = new CompilationTestData();

            ResultProperties resultProperties;
            string error;
            ImmutableArray<AssemblyIdentity> missingAssemblyIdentities;
            var result = context.CompileExpression(
                declaration,
                DkmEvaluationFlags.None,
                NoAliases,
                DebuggerDiagnosticFormatter.Instance,
                out resultProperties,
                out error,
                out missingAssemblyIdentities,
                EnsureEnglishUICulture.PreferredOrNull,
                testData);
            Assert.Null(error);
            Assert.Empty(missingAssemblyIdentities);

            flags = resultProperties.Flags;
        }
开发者ID:natidea,项目名称:roslyn,代码行数:22,代码来源:DeclarationTests.cs

示例5: VerifyErrorResultProperties

 private static void VerifyErrorResultProperties(EvaluationContext context, string expr)
 {
     ResultProperties resultProperties;
     string error;
     context.CompileExpression(expr, out resultProperties, out error);
     Assert.NotNull(error);
     Assert.Equal(default(ResultProperties), resultProperties);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:ResultPropertiesTests.cs

示例6: GetResultProperties

 private static ResultProperties GetResultProperties(EvaluationContext context, string expr)
 {
     ResultProperties resultProperties;
     string error;
     context.CompileExpression(expr, out resultProperties, out error);
     Assert.Null(error);
     return resultProperties;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:ResultPropertiesTests.cs

示例7: CompileExpression

 private static string CompileExpression(EvaluationContext context, string expr)
 {
     string error;
     var testData = new CompilationTestData();
     var result = context.CompileExpression(expr, out error, testData);
     Assert.NotNull(result.Assembly);
     Assert.Null(error);
     return testData.GetMethodData(result.TypeName + "." + result.MethodName).GetMethodIL();
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:DebuggerDisplayAttributeTests.cs


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