Only generate setters and getters for public properties (#47)

* Only generate setters and getters for public properties

* .
This commit is contained in:
Stef Heyenrath
2022-12-13 19:18:30 +01:00
committed by GitHub
parent 72a40e6f6a
commit d340c6af7c
10 changed files with 158 additions and 12 deletions
@@ -92,6 +92,48 @@ namespace ProxyInterfaceSourceGeneratorTests
}
}
[Fact]
public void GenerateFiles_When_MixedVisibility_Should_GenerateCorrectFiles()
{
// Arrange
var fileNames = new[]
{
"ProxyInterfaceSourceGeneratorTests.Source.IMixedVisibility.g.cs",
"ProxyInterfaceSourceGeneratorTests.Source.MixedVisibilityProxy.g.cs"
};
var path = "./Source/IMixedVisibility.cs";
var sourceFile = new SourceFile
{
Path = path,
Text = File.ReadAllText(path),
AttributeToAddToInterface = new ExtraAttribute
{
Name = "ProxyInterfaceGenerator.Proxy",
ArgumentList = "typeof(ProxyInterfaceSourceGeneratorTests.Source.MixedVisibility)"
}
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
// Assert
result.Valid.Should().BeTrue();
result.Files.Should().HaveCount(fileNames.Length + 1);
foreach (var fileName in fileNames.Select((fileName, index) => new { fileName, index }))
{
var builder = result.Files[fileName.index + 1]; // +1 means skip the attribute
builder.Path.Should().EndWith(fileName.fileName);
if (Write) File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
[Fact]
public void GenerateFiles_ForSingleClass_Should_GenerateCorrectFiles()
{