diff --git a/InterfaceGenerator.Tests/AccessorsGenerationTests.cs b/InterfaceGenerator.Tests/AccessorsGenerationTests.cs index 90267a4..9d6aa61 100644 --- a/InterfaceGenerator.Tests/AccessorsGenerationTests.cs +++ b/InterfaceGenerator.Tests/AccessorsGenerationTests.cs @@ -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 } \ No newline at end of file diff --git a/InterfaceGenerator.Tests/MethodGenerationTests.cs b/InterfaceGenerator.Tests/MethodGenerationTests.cs index c0ca273..53aec89 100644 --- a/InterfaceGenerator.Tests/MethodGenerationTests.cs +++ b/InterfaceGenerator.Tests/MethodGenerationTests.cs @@ -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] diff --git a/InterfaceGenerator/AutoInterfaceGenerator.cs b/InterfaceGenerator/AutoInterfaceGenerator.cs index b89febc..1e1a290 100644 --- a/InterfaceGenerator/AutoInterfaceGenerator.cs +++ b/InterfaceGenerator/AutoInterfaceGenerator.cs @@ -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);