Skip to content

Commit 486320b

Browse files
authored
Merge pull request #5 from darthfabar/development
[FIX] filter framework type properties
2 parents 67a5902 + c121ca5 commit 486320b

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

Source/ContractModelsAttributeCheck/AttributeChecker.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private void SearchPropertyForUsedTypes(DistinctTypeList distinctTypeList, Prope
137137
_ = ShouldSkipType(distinctTypeList, currentType) ||
138138
SearchForTypesWhenItIsAnArray(currentType, distinctTypeList) ||
139139
SearchForTypesWhenItIsAGenericType(currentType, distinctTypeList) ||
140+
ShouldSkipFrameworkType(currentType) ||
140141
SearchForTypesWhenItIsAClass(currentType, distinctTypeList);
141142
}
142143

Tests/ContractModelsAttributeCheck.Test/AttributeCheckerTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ public void Array_Should_Not_Add_ArrayProperties()
9696
missingAttributes.Count.Should().Be(0);
9797
}
9898

99+
[Fact]
100+
public void Should_Not_Contain_Uri_Properties()
101+
{
102+
var results = _attributeChecker.CheckPropertiesForAttributes(typeof(TestClassWithSystemTypeProperty), _attributes);
103+
104+
var missingAttributes = results.Where(w => !w.HasRequiredAttribute).ToList();
105+
missingAttributes.Count.Should().Be(1);
106+
107+
}
108+
99109
[Fact]
100110
public void Validate_DistinctTypeList()
101111
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#nullable disable
2+
using System;
3+
4+
namespace ContractModelsAttributeCheck.Test.TestTypes
5+
{
6+
public class TestClassWithSystemTypeProperty
7+
{
8+
public Uri Url { get; set; }
9+
}
10+
}

Tests/ContractModelsAttributeCheck.Test/TestTypes/TestClassWithoutAttributes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#nullable disable
2+
using System;
23
using System.Collections.Generic;
34

45
namespace ContractModelsAttributeCheck.Test.TestTypes

0 commit comments

Comments
 (0)