Added record's Deconstruct method support
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<TargetFramework>netstandard2</TargetFramework>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
<PackageVersion>1.0.6</PackageVersion>
|
||||
<PackageVersion>1.0.7</PackageVersion>
|
||||
|
||||
<developmentDependency>true</developmentDependency>
|
||||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace InterfaceGenerator
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user