Skip to content

Commit

Permalink
Merge pull request #28 from Frederik91/issue/27
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
Frederik91 committed Jan 17, 2024
2 parents f2c79db + abf25c2 commit f5c46a2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MakeInterface.Contracts/MakeInterface.Contracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputType>library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>MakeInterface.Contracts</PackageId>
<Version>0.3.2</Version>
<Version>0.3.3</Version>
<Authors>Frederik Tegnander</Authors>
<Company>COWI</Company>
<PackageDescription>Contains attriubutes to use with Interfaces.SourceGenerator</PackageDescription>
Expand Down
3 changes: 2 additions & 1 deletion MakeInterface.Generator/InterfaceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ private void Generate(SourceProductionContext ctx, (SemanticModel, CompilationUn

var newAccessor = accessor
.WithBody(null)
.WithExpressionBody(null)
.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken));

newAccessors = newAccessors.Add(newAccessor);
}
newProperty = newProperty.WithAccessorList(SyntaxFactory.AccessorList(newAccessors));
Expand Down
2 changes: 1 addition & 1 deletion MakeInterface.Generator/MakeInterface.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<OutputType>library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>MakeInterface.Generator</PackageId>
<Version>0.3.2</Version>
<Version>0.3.3</Version>
<Authors>Frederik Tegnander</Authors>
<Company>COWI</Company>
<PackageTags>Interfaces;SourceGenerator;MakeInterface</PackageTags>
Expand Down
22 changes: 22 additions & 0 deletions MakeInterface.Tests/InterfaceGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,28 @@ public interface IGeneric<T>
void Test<T>();
}
}
""";

return TestHelper.Verify(source);
}

[Fact]
public Task PropertyWithBackingField()
{
var source = """
namespace MakeInterface.Tests
{
[GenerateInterface]
public class Class1
{
private string _test;
public string Test
{
get => _test;
set => _test = value;
}
}
}
""";

return TestHelper.Verify(source);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: ITest.g.cs
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace MakeInterface.Tests
{
public partial interface IClass1
{
string Test { get => _test; set => _test = value; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//HintName: ITest.g.cs
// <auto-generated/>
#pragma warning disable
#nullable enable
namespace MakeInterface.Tests
{
public partial interface IClass1
{
string Test { get; set; }
}
}

0 comments on commit f5c46a2

Please sign in to comment.