GetMappings() public static method

public static GetMappings ( TypeDefinition typeDefinition ) : IEnumerable
typeDefinition TypeDefinition
return IEnumerable
Exemplo n.º 1
0
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithAutoPropertiesAndDodgyField>()).ToList();

        Assert.AreEqual("<Property1>k__BackingField", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("<Property2>k__BackingField", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
    public void WithLowerUnderScoreBackingFields()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithUnderScoreBackingFields>()).ToList();

        Assert.AreEqual("_property1", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("_property2", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <ClassWithSingleBackingFieldsSet>()).ToList();

        Assert.AreEqual("propertya", memberMappings.First(x => x.PropertyDefinition.Name == "Property1").FieldDefinition.Name);
        Assert.AreEqual("propertyb", memberMappings.First(x => x.PropertyDefinition.Name == "Property2").FieldDefinition.Name);
    }
Exemplo n.º 4
0
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <Person>();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual(0, node.PropertyDependencies.Count);
    }
Exemplo n.º 5
0
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <TestClass>();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual(1, node.PropertyDependencies.Count);
        Assert.AreEqual("PropertyWithLambda", node.PropertyDependencies[0].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("Property1", node.PropertyDependencies[0].WhenPropertyIsSet.Name);
    }
Exemplo n.º 6
0
    public void Run()
    {
        var typeDefinition = DefinitionFinder.FindType <Person <int> >();
        var node           = new TypeNode
        {
            TypeDefinition = typeDefinition,
            Mappings       = MappingFinder.GetMappings(typeDefinition).ToList()
        };

        new IlGeneratedByDependencyReader(node).Process();
        Assert.AreEqual("FullName", node.PropertyDependencies[0].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("GivenNames", node.PropertyDependencies[0].WhenPropertyIsSet.Name);
        Assert.AreEqual("FullName", node.PropertyDependencies[1].ShouldAlsoNotifyFor.Name);
        Assert.AreEqual("FamilyName", node.PropertyDependencies[1].WhenPropertyIsSet.Name);
    }
    public void Run()
    {
        var memberMappings = MappingFinder.GetMappings(DefinitionFinder.FindType <Model>()).ToList();

        Assert.IsNull(memberMappings.First().FieldDefinition);
    }