diff --git a/InterfaceGenerator.Tests/RecordInterfaceGenerationTests.cs b/InterfaceGenerator.Tests/RecordInterfaceGenerationTests.cs index d300119..b69bc15 100644 --- a/InterfaceGenerator.Tests/RecordInterfaceGenerationTests.cs +++ b/InterfaceGenerator.Tests/RecordInterfaceGenerationTests.cs @@ -42,6 +42,23 @@ namespace InterfaceGenerator.Tests _sut.RecordMethod(); } + + [Fact] + public void Deconstruct_IsGenerated() + { + var method = typeof(ITestRecord).GetMethod( + nameof(TestRecord.Deconstruct)); + + method.Should().NotBeNull(); + method.ReturnType.Should().Be(typeof(void)); + + var parameters = method.GetParameters(); + parameters.Length.Should().Be(1); + + var parameter = parameters[0]; + parameter.ParameterType.Should().Be(typeof(int).MakeByRefType()); + parameter.IsOut.Should().BeTrue(); + } } [GenerateAutoInterface] diff --git a/InterfaceGenerator/AutoInterfaceGenerator.cs b/InterfaceGenerator/AutoInterfaceGenerator.cs index 056602a..b06f513 100644 --- a/InterfaceGenerator/AutoInterfaceGenerator.cs +++ b/InterfaceGenerator/AutoInterfaceGenerator.cs @@ -273,9 +273,10 @@ namespace InterfaceGenerator return; } - if (methodSymbol.IsImplicitlyDeclared) + if (methodSymbol.IsImplicitlyDeclared && methodSymbol.Name != "Deconstruct") { - // omit methods that are auto generated by the compiler (eg. record's methods) + // omit methods that are auto generated by the compiler (eg. record's methods), + // except for the record Deconstruct method return; } diff --git a/InterfaceGenerator/InterfaceGenerator.csproj b/InterfaceGenerator/InterfaceGenerator.csproj index 83495a2..e30788b 100644 --- a/InterfaceGenerator/InterfaceGenerator.csproj +++ b/InterfaceGenerator/InterfaceGenerator.csproj @@ -3,7 +3,7 @@ netstandard2 9.0 enable - 1.0.6 + 1.0.7 true false diff --git a/InterfaceGenerator/TextWriterExtensions.cs b/InterfaceGenerator/TextWriterExtensions.cs index cc77368..2c25a61 100644 --- a/InterfaceGenerator/TextWriterExtensions.cs +++ b/InterfaceGenerator/TextWriterExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; namespace InterfaceGenerator {