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


C# MockMetadataImporter类代码示例

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


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

示例1: StaticManualEventsWithAddRemoveMethodsAreCorrectlyImported

		public void StaticManualEventsWithAddRemoveMethodsAreCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetEventSemantics = f => EventScriptSemantics.AddAndRemoveMethods(MethodScriptSemantics.NormalMethod("add_" + f.Name), MethodScriptSemantics.NormalMethod("remove_" + f.Name)) };

			Compile(new[] { "class C { public static event System.EventHandler SomeProp { add {} remove{} } }" }, metadataImporter: metadataImporter);
			FindStaticMethod("C.add_SomeProp").Should().NotBeNull();
			FindStaticMethod("C.remove_SomeProp").Should().NotBeNull();
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:7,代码来源:EventConversionTests.cs

示例2: ShadowingMethodsAreIncluded

		public void ShadowingMethodsAreIncluded() {
			var metadataImporter = new MockMetadataImporter { GetMethodSemantics = m => MethodScriptSemantics.NormalMethod(m.DeclaringType.Name == "C" ? "XDerived" : m.Name) };
			Compile(new[] { "class B { public void X(); } class C : B { public new void X() {} }" }, metadataImporter: metadataImporter);
			var cls = FindClass("C");
			cls.InstanceMethods.Should().HaveCount(1);
			cls.InstanceMethods[0].Name.Should().Be("XDerived");
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:7,代码来源:MethodConversionTests.cs

示例3: ReadOnlyNativeIndexerIsCorrectlyImported

 public void ReadOnlyNativeIndexerIsCorrectlyImported()
 {
     var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.NativeIndexer() };
     Compile(new[] { "class C { public int this[int i] { get { return 0; } } }" }, metadataImporter: metadataImporter);
     FindClass("C").InstanceMethods.Should().BeEmpty();
     FindClass("C").StaticMethods.Should().BeEmpty();
 }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例4: InstanceAutoPropertiesThatShouldBeInstanceFieldsAreCorrectlyImported

		public void InstanceAutoPropertiesThatShouldBeInstanceFieldsAreCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.Field("$" + p.Name) };
			Compile(new[] { "class C { public string SomeProp { get; set; } }" }, metadataImporter: metadataImporter);
			FindClass("C").InstanceMethods.Should().BeEmpty();
			FindClass("C").StaticMethods.Should().BeEmpty();
			FindInstanceFieldInitializer("C.$SomeProp").Should().NotBeNull();
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:7,代码来源:PropertyConversionTests.cs

示例5: CannotUseNotUsableTypeAsAGenericArgument

        public void CannotUseNotUsableTypeAsAGenericArgument()
        {
            var nc = new MockMetadataImporter { GetTypeSemantics = t => t.Name == "C1" ? TypeScriptSemantics.NotUsableFromScript() : TypeScriptSemantics.NormalType(t.Name) };
            var er = new MockErrorReporter(false);

            Compile(new[] {
            @"class C1 {}
            class C {
            public void F1<T>() {}
            public void M() {
            F1<C1>();
            }
            }" }, metadataImporter: nc, errorReporter: er);

            Assert.That(er.AllMessagesText.Count, Is.EqualTo(1));
            Assert.That(er.AllMessagesText[0].Contains("not usable from script") && er.AllMessagesText[0].Contains("generic argument") && er.AllMessagesText[0].Contains("C1") && er.AllMessagesText[0].Contains("F1"));

            er = new MockErrorReporter(false);
            Compile(new[] {
            @"class C1 {}
            interface I1<T> {}
            class C {
            public void F1<T>() {}
            public void M() {
            F1<I1<I1<C1>>>();
            }
            }" }, metadataImporter: nc, errorReporter: er);
            Assert.That(er.AllMessagesText.Count, Is.EqualTo(1));
            Assert.That(er.AllMessagesText[0].Contains("not usable from script") && er.AllMessagesText[0].Contains("generic argument") && er.AllMessagesText[0].Contains("C1") && er.AllMessagesText[0].Contains("F1"));
        }
开发者ID:koczkatamas,项目名称:SaltarelleCompiler,代码行数:30,代码来源:InvocationTests.cs

示例6: IndexerWithGetAndSetMethodsWithNoCodeIsCorrectlyImported

		public void IndexerWithGetAndSetMethodsWithNoCodeIsCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_Item", generateCode: false), MethodScriptSemantics.NormalMethod("set_Item", generateCode: false)) };
			Compile(new[] { "class C { public int this[int i] { get { return 0; } set {} } }" }, metadataImporter: metadataImporter);
			FindInstanceMethod("C.get_Item").Should().BeNull();
			FindInstanceMethod("C.set_Item").Should().BeNull();
			FindClass("C").StaticMethods.Should().BeEmpty();
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例7: GenericMethodTypeArgumentsAreIgnoredForStaticMethodsIfTheMethodImplOptionsSaySo

 public void GenericMethodTypeArgumentsAreIgnoredForStaticMethodsIfTheMethodImplOptionsSaySo()
 {
     var metadataImporter = new MockMetadataImporter { GetMethodSemantics = m => MethodScriptSemantics.NormalMethod("X", ignoreGenericArguments: true) };
     var namer = new MockNamer { GetTypeParameterName = tp => "$$" + tp.Name };
     Compile(new[] { "class C { public static void X<U, V>() {} }" }, metadataImporter: metadataImporter, namer: namer);
     FindStaticMethod("C.X").TypeParameterNames.Should().BeEmpty();
 }
开发者ID:mattleibow,项目名称:SaltarelleCompiler,代码行数:7,代码来源:MethodConversionTests.cs

示例8: IndexerThatIsNotUsableFromScriptIsNotImported

 public void IndexerThatIsNotUsableFromScriptIsNotImported()
 {
     var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.NotUsableFromScript() };
     Compile(new[] { "class C { public int this[int i] { get {} set {} } }" }, metadataImporter: metadataImporter);
     FindClass("C").InstanceMethods.Should().BeEmpty();
     FindClass("C").StaticMethods.Should().BeEmpty();
 }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例9: CannotUseNotUsableTypeInATypeOfExpression

        public void CannotUseNotUsableTypeInATypeOfExpression()
        {
            var metadataImporter = new MockMetadataImporter { GetTypeSemantics = t => t.Name == "C1" ? TypeScriptSemantics.NotUsableFromScript() : TypeScriptSemantics.NormalType(t.Name) };
            var er = new MockErrorReporter(false);

            Compile(new[] {
            @"class C1 {}
            class C {
            public void M() {
            var t = typeof(C1);
            }
            }" }, metadataImporter: metadataImporter, errorReporter: er);

            Assert.That(er.AllMessagesText.Count, Is.EqualTo(1));
            Assert.That(er.AllMessagesText[0].Contains("not usable from script") && er.AllMessagesText[0].Contains("typeof") && er.AllMessagesText[0].Contains("C1"));

            er = new MockErrorReporter(false);
            Compile(new[] {
            @"class C1 {}
            interface I1<T> {}
            class C {
            public void M() {
            var t= typeof(I1<I1<C1>>);
            }
            }" }, metadataImporter: metadataImporter, errorReporter: er);
            Assert.That(er.AllMessagesText.Count, Is.EqualTo(1));
            Assert.That(er.AllMessagesText[0].Contains("not usable from script") && er.AllMessagesText[0].Contains("typeof") && er.AllMessagesText[0].Contains("C1"));
        }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:28,代码来源:TypeOfTests.cs

示例10: IndexerAccessorsInInterfaceHaveNullDefinition

 public void IndexerAccessorsInInterfaceHaveNullDefinition()
 {
     var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_Item"), MethodScriptSemantics.NormalMethod("set_Item")) };
     Compile(new[] { "interface I { int this[int i] { get { return 0; } set {} } }" }, metadataImporter: metadataImporter);
     FindInstanceMethod("I.get_Item").Should().NotBeNull();
     FindInstanceMethod("I.set_Item").Should().NotBeNull();
 }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例11: AbstractIndexerHasANullDefinition

 public void AbstractIndexerHasANullDefinition()
 {
     var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_Item"), MethodScriptSemantics.NormalMethod("set_Item")) };
     Compile(new[] { "abstract class C { public abstract int this[int i] { get; set; } }" }, metadataImporter: metadataImporter);
     FindInstanceMethod("C.get_Item").Definition.Should().BeNull();
     FindInstanceMethod("C.set_Item").Definition.Should().BeNull();
 }
开发者ID:JimmyJune,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例12: WriteOnlyIndexerWithGetAndSetMethodsIsCorrectlyImported

		public void WriteOnlyIndexerWithGetAndSetMethodsIsCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_Item"), MethodScriptSemantics.NormalMethod("set_Item")) };
			Compile(new[] { "class C { public int this[int i] { set {} } }" }, metadataImporter: metadataImporter);
			FindInstanceMethod("C.get_Item").Should().BeNull();
			FindInstanceMethod("C.set_Item").Should().NotBeNull();
			FindClass("C").StaticMethods.Should().BeEmpty();
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:7,代码来源:IndexerConversionTests.cs

示例13: InstanceFieldsAreCorrectlyImported

		public void InstanceFieldsAreCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetFieldSemantics = f => FieldScriptSemantics.Field("$SomeProp") };
			Compile(new[] { "class C { public int SomeField; }" }, metadataImporter: metadataImporter);
			FindInstanceFieldInitializer("C.$SomeProp").Should().NotBeNull();
			FindClass("C").StaticInitStatements.Should().BeEmpty();
			FindClass("C").InstanceMethods.Should().BeEmpty();
			FindClass("C").StaticMethods.Should().BeEmpty();
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:8,代码来源:FieldConversionTests.cs

示例14: StaticFieldsAreCorrectlyImported

		public void StaticFieldsAreCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = c => ConstructorScriptSemantics.Unnamed(skipInInitializer: c.DeclaringType.IsKnownType(KnownTypeCode.Object)) };
			Compile(new[] { "class C { public static int SomeField; }" }, metadataImporter: metadataImporter);
			FindStaticFieldInitializer("C.$SomeField").Should().NotBeNull();
			FindClass("C").UnnamedConstructor.Body.Statements.Should().BeEmpty();
			FindClass("C").InstanceMethods.Should().BeEmpty();
			FindClass("C").StaticMethods.Should().BeEmpty();
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:8,代码来源:FieldConversionTests.cs

示例15: InstanceAutoEventsWithAddRemoveMethodsWithNoCodeAreCorrectlyImported

		public void InstanceAutoEventsWithAddRemoveMethodsWithNoCodeAreCorrectlyImported() {
			var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = c => ConstructorScriptSemantics.Unnamed(skipInInitializer: c.DeclaringType.IsKnownType(KnownTypeCode.Object)),
			                                                  GetEventSemantics = e => EventScriptSemantics.AddAndRemoveMethods(MethodScriptSemantics.NormalMethod("add_" + e.Name, generateCode: false), MethodScriptSemantics.NormalMethod("remove_" + e.Name, generateCode: false)),
			                                                };
			Compile(new[] { "class C { public event System.EventHandler SomeProp; }" }, metadataImporter: metadataImporter);
			FindClass("C").InstanceMethods.Should().BeEmpty();
			FindInstanceFieldInitializer("C.$SomeProp").Should().NotBeNull();
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:8,代码来源:EventConversionTests.cs


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