Fix static properties not being ignored
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user