Fix static properties not being ignored

This commit is contained in:
daver32
2021-07-24 22:20:18 +02:00
parent 73b82d676e
commit 35f8b0a159
3 changed files with 31 additions and 0 deletions
@@ -106,6 +106,15 @@ namespace InterfaceGenerator.Tests
prop.Should().BeNull();
}
[Fact]
public void StaticProperty_IsOmitted()
{
var prop = typeof(IAccessorsTestsService)
.GetProperty(nameof(AccessorsTestsService.StaticProperty));
prop.Should().BeNull();
}
}
// ReSharper disable UnusedMember.Local, ValueParameterNotUsed
@@ -130,6 +139,8 @@ namespace InterfaceGenerator.Tests
[AutoInterfaceIgnore]
public string IgnoredProperty { get; set; }
public static string StaticProperty { get; set; }
}
// ReSharper enable UnusedMember.Local, ValueParameterNotUsed
}
@@ -233,6 +233,16 @@ namespace InterfaceGenerator.Tests
method.Should().BeNull();
}
[Fact]
public void StaticMethod_IsOmitted()
{
var method = typeof(IMethodsTestService)
.GetMethods()
.FirstOrDefault(x => x.Name == nameof(MethodsTestService.StaticMethod));
method.Should().BeNull();
}
}
[GenerateAutoInterface]
@@ -300,6 +310,11 @@ namespace InterfaceGenerator.Tests
{
}
public static void StaticMethod()
{
}
}
[GenerateAutoInterface]
@@ -215,6 +215,11 @@ namespace InterfaceGenerator
private static void GeneratePropertyDefinition(IndentedTextWriter writer, IPropertySymbol propertySymbol)
{
if (propertySymbol.IsStatic)
{
return;
}
bool hasPublicGetter = propertySymbol.GetMethod is not null &&
IsPublicOrInternal(propertySymbol.GetMethod);