コード例 #1
0
    public void EqualityNestedTest()
    {
        var instructions = GetInstructions("EqualityNested");
        var field        = GetField("intField");

        Assert.IsTrue(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #2
0
    public void EqualsNestedInverseTest()
    {
        var instructions = GetInstructions("EqualsNestedInverse");
        var field        = GetField("stringField");

        Assert.IsTrue(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #3
0
    public void NoEqualityTest()
    {
        var instructions = GetInstructions("NoEquality");
        var field        = GetField("stringField");

        Assert.IsFalse(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #4
0
    public void NoEqualsNoFieldTest()
    {
        var instructions = GetInstructions("NoEqualsNoField");
        var field        = GetField("intField");

        Assert.IsFalse(HasEqualityChecker.AlreadyHasEquality(instructions, null));
    }
コード例 #5
0
    public void StringEqualsOrdinalTest()
    {
        var instructions = GetInstructions("StringEqualsOrdinal");
        var field        = GetField("stringField");

        Assert.IsTrue(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #6
0
    public void EqualsShortCutTest()
    {
        var instructions = GetInstructions("EqualsShortCut");
        var field        = GetField("stringField");

        Assert.True(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #7
0
    public void EqualityShortCutInverseTest()
    {
        var instructions = GetInstructions("EqualityShortCutInverse");
        var field        = GetField("intField");

        Assert.True(HasEqualityChecker.AlreadyHasEquality(instructions, field));
    }
コード例 #8
0
    void ProcessTypes(List <TypeNode> notifyNodes)
    {
        foreach (var node in notifyNodes)
        {
            if (node.EventInvoker == null)
            {
                continue;
            }
            LogInfo("\t" + node.TypeDefinition.FullName);

            foreach (var propertyData in node.PropertyDatas)
            {
                var body = propertyData.PropertyDefinition.SetMethod.Body;

                var alreadyHasEquality = HasEqualityChecker.AlreadyHasEquality(propertyData.PropertyDefinition, propertyData.BackingFieldReference);

                body.SimplifyMacros();

                body.MakeLastStatementReturn();

                var propertyWeaver = new PropertyWeaver(this, propertyData, node, ModuleDefinition.TypeSystem);
                propertyWeaver.Execute();

                if (!alreadyHasEquality)
                {
                    var equalityCheckWeaver = new EqualityCheckWeaver(propertyData, this);
                    equalityCheckWeaver.Execute();
                }

                body.InitLocals = true;
                body.OptimizeMacros();
            }
            ProcessTypes(node.Nodes);
        }
    }
コード例 #9
0
    public void EqualsNoFieldTest()
    {
        var instructions = GetInstructions("EqualsNoField");

        Assert.True(HasEqualityChecker.AlreadyHasEquality(instructions, null));
    }