本文整理汇总了C#中MockMetadataImporter类的典型用法代码示例。如果您正苦于以下问题:C# MockMetadataImporter类的具体用法?C# MockMetadataImporter怎么用?C# MockMetadataImporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MockMetadataImporter类属于命名空间,在下文中一共展示了MockMetadataImporter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: FieldsThatAreNotUsableFromScriptAreNotImported
public void FieldsThatAreNotUsableFromScriptAreNotImported() {
var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = c => ConstructorScriptSemantics.Unnamed(skipInInitializer: c.DeclaringType.IsKnownType(KnownTypeCode.Object)), GetFieldSemantics = f => FieldScriptSemantics.NotUsableFromScript() };
Compile(new[] { "class C { public int SomeField; }" }, metadataImporter: metadataImporter);
FindClass("C").UnnamedConstructor.Body.Statements.Should().BeEmpty();
FindClass("C").StaticInitStatements.Should().BeEmpty();
FindClass("C").InstanceMethods.Should().BeEmpty();
FindClass("C").StaticMethods.Should().BeEmpty();
}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:8,代码来源:FieldConversionTests.cs
示例17: ConstructorsCanBeOverloadedWithDifferentImplementations
public void ConstructorsCanBeOverloadedWithDifferentImplementations() {
var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = ctor => ctor.DeclaringType.IsKnownType(KnownTypeCode.Object) ? ConstructorScriptSemantics.Unnamed(skipInInitializer: true) : (ctor.Parameters[0].Type.Name == "String" ? ConstructorScriptSemantics.Named("StringCtor") : ConstructorScriptSemantics.StaticMethod("IntCtor")) };
Compile(new[] { "class C { C(int i) {} C(string s) {} }" }, metadataImporter: metadataImporter);
FindClass("C").NamedConstructors.Should().HaveCount(1);
FindClass("C").StaticMethods.Should().HaveCount(1);
FindNamedConstructor("C.StringCtor").Should().NotBeNull();
FindStaticMethod("C.IntCtor").Should().NotBeNull();
}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:8,代码来源:ConstructorConversionTests.cs
示例18: ImportingMultipleFieldsInTheSameDeclarationWorks
public void ImportingMultipleFieldsInTheSameDeclarationWorks() {
var metadataImporter = new MockMetadataImporter { GetFieldSemantics = f => FieldScriptSemantics.Field("$" + f.Name) };
Compile(new[] { "class C { public int Field1, Field2; }" }, metadataImporter: metadataImporter);
FindInstanceFieldInitializer("C.$Field1").Should().NotBeNull();
FindInstanceFieldInitializer("C.$Field2").Should().NotBeNull();
FindClass("C").StaticInitStatements.Should().BeEmpty();
FindClass("C").InstanceMethods.Should().BeEmpty();
FindClass("C").StaticMethods.Should().BeEmpty();
}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:9,代码来源:FieldConversionTests.cs
示例19: InstanceAutoPropertiesWithGetSetMethodsWithNoCodeAreCorrectlyImported
public void InstanceAutoPropertiesWithGetSetMethodsWithNoCodeAreCorrectlyImported() {
var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = c => ConstructorScriptSemantics.Unnamed(skipInInitializer: c.DeclaringType.IsKnownType(KnownTypeCode.Object)),
GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_" + p.Name, generateCode: false), MethodScriptSemantics.NormalMethod("set_" + p.Name, generateCode: false)),
};
Compile(new[] { "class C { public string SomeProp { get; set; } }" }, metadataImporter: metadataImporter);
FindClass("C").InstanceMethods.Should().BeEmpty();
FindInstanceFieldInitializer("C.$SomeProp").Should().NotBeNull();
}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:9,代码来源:PropertyConversionTests.cs
示例20: InstanceAutoPropertiesWithGetSetMethodsWithNoCodeAreCorrectlyImported
public void InstanceAutoPropertiesWithGetSetMethodsWithNoCodeAreCorrectlyImported() {
var metadataImporter = new MockMetadataImporter { GetConstructorSemantics = c => ConstructorScriptSemantics.Unnamed(skipInInitializer: c.DeclaringType.IsKnownType(KnownTypeCode.Object)),
GetPropertySemantics = p => PropertyScriptSemantics.GetAndSetMethods(MethodScriptSemantics.NormalMethod("get_" + p.Name, generateCode: false), MethodScriptSemantics.NormalMethod("set_" + p.Name, generateCode: false)),
GetAutoPropertyBackingFieldName = p => { throw new InvalidOperationException("Shouldn't be called"); }
};
Compile(new[] { "class C { public string SomeProp { get; set; } }" }, metadataImporter: metadataImporter);
FindClass("C").InstanceMethods.Should().BeEmpty();
FindClass("C").UnnamedConstructor.Body.Statements.Should().BeEmpty();
}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:9,代码来源:PropertyConversionTests.cs
注:本文中的MockMetadataImporter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论