CheckForWarning() public method

public CheckForWarning ( PropertyData, propertyData, bool isBeforeAfter ) : string
propertyData PropertyData,
isBeforeAfter bool
return string
コード例 #1
0
    public void IsIndexer()
    {
        var checker = new WarningChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType<IndexerClass>().Properties.First();

        var message = checker.CheckForWarning(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  NotificationAddedDirectly = false
                                                              },false);
        Assert.IsNotNull(message);
    }
コード例 #2
0
    public void NonAbstract()
    {
        var checker = new WarningChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType<BaseClass>().Properties.First(x => x.Name == "NonAbstractProperty");

        var message = checker.CheckForWarning(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  NotificationAddedDirectly = false
                                                              }, false);
        Assert.IsNull(message);
    }
コード例 #3
0
    public void WithGet()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty<BeforeAfterWithNoGetInfoCheckerTest>("PropertyWithGet");

        var message = checker.CheckForWarning(new PropertyData
                                                {
                                                    PropertyDefinition = propertyDefinition,
                                                    NotificationAddedDirectly = true,
                                                }, true);
        Assert.IsNull(message);
    }
コード例 #4
0
    public void IsAbstract()
    {
        var checker            = new WarningChecker(null, null);
        var propertyDefinition = DefinitionFinder.FindType <BaseClass>().Properties.First(x => x.Name == "AbstractProperty");

        var message = checker.CheckForWarning(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = false
        }, false);

        Assert.IsNotNull(message);
    }
    public void WithoutBackingField()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty<CheckForEqualityWithNoBackingFieldSetInfoCheckerTest>("WithoutBackingFieldProperty");

        var warning = checker.CheckForWarning(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  CheckForEquality = true,
                                                                  BackingFieldReference = null,
                                                              }, false);
        Assert.IsNotNull(warning);
    }
    public void WithBackingField()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty(() => WithBackingFieldProperty);

        var warning = checker.CheckForWarning(new PropertyData
                                                              {
                                                                  PropertyDefinition = propertyDefinition,
                                                                  CheckForEquality = true,
                                                                  BackingFieldReference = propertyDefinition.DeclaringType.Fields[0]
                                                              }, false);
        Assert.IsNull(warning);
    }
    public void WithGet()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty <BeforeAfterWithNoGetInfoCheckerTest>("PropertyWithGet");

        var message = checker.CheckForWarning(new PropertyData
        {
            PropertyDefinition        = propertyDefinition,
            NotificationAddedDirectly = true,
        }, true);

        Assert.IsNull(message);
    }
コード例 #8
0
    public void WithBackingField()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty(() => WithBackingFieldProperty);

        var warning = checker.CheckForWarning(new PropertyData
        {
            PropertyDefinition    = propertyDefinition,
            CheckForEquality      = true,
            BackingFieldReference = propertyDefinition.DeclaringType.Fields[0]
        }, false);

        Assert.IsNull(warning);
    }
コード例 #9
0
    public void WithoutBackingField()
    {
        var checker = new WarningChecker(null, null);

        var propertyDefinition = DefinitionFinder.FindProperty <CheckForEqualityWithNoBackingFieldSetInfoCheckerTest>("WithoutBackingFieldProperty");

        var warning = checker.CheckForWarning(new PropertyData
        {
            PropertyDefinition    = propertyDefinition,
            CheckForEquality      = true,
            BackingFieldReference = null,
        }, false);

        Assert.IsNotNull(warning);
    }