Fixed generated code when a class extends multiple classes (#38)
* . * . * pnp * ok * compiles * ? * e * set * .ToArray() * n * ... * ok * pnp * . * . * mapster
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using CSharp.SourceGenerators.Extensions;
|
||||
using CSharp.SourceGenerators.Extensions.Models;
|
||||
using FluentAssertions;
|
||||
@@ -180,92 +179,6 @@ namespace ProxyInterfaceSourceGeneratorTests
|
||||
proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassPersonFilename}"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateFiles_ForPnP_Should_GenerateCorrectFiles()
|
||||
{
|
||||
// Arrange
|
||||
var fileNames = new[]
|
||||
{
|
||||
"ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject.g.cs",
|
||||
"ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb.g.cs",
|
||||
"ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientRuntimeContext.g.cs",
|
||||
"ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientContext.g.cs",
|
||||
|
||||
"Microsoft.SharePoint.Client.ClientObjectProxy.g.cs",
|
||||
"Microsoft.SharePoint.Client.WebProxy.g.cs",
|
||||
"Microsoft.SharePoint.Client.ClientRuntimeContextProxy.g.cs",
|
||||
"Microsoft.SharePoint.Client.ClientContextProxy.g.cs"
|
||||
};
|
||||
|
||||
var pathClientObject = "./Source/PnP/IClientObject.cs";
|
||||
var sourceFileClientObject = new SourceFile
|
||||
{
|
||||
Path = pathClientObject,
|
||||
Text = File.ReadAllText(pathClientObject),
|
||||
AttributeToAddToInterface = new ExtraAttribute
|
||||
{
|
||||
Name = "ProxyInterfaceGenerator.Proxy",
|
||||
ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientObject)"
|
||||
}
|
||||
};
|
||||
|
||||
var pathWeb = "./Source/PnP/IWeb.cs";
|
||||
var sourceFileWeb = new SourceFile
|
||||
{
|
||||
Path = pathWeb,
|
||||
Text = File.ReadAllText(pathWeb),
|
||||
AttributeToAddToInterface = new ExtraAttribute
|
||||
{
|
||||
Name = "ProxyInterfaceGenerator.Proxy",
|
||||
ArgumentList = "typeof(Web)" // Only name, no namespace
|
||||
}
|
||||
};
|
||||
|
||||
var pathClientRuntimeContext = "./Source/Pnp/IClientRuntimeContext.cs";
|
||||
var sourceFileClientRuntimeContext = new SourceFile
|
||||
{
|
||||
Path = pathClientRuntimeContext,
|
||||
Text = File.ReadAllText(pathClientRuntimeContext),
|
||||
AttributeToAddToInterface = new ExtraAttribute
|
||||
{
|
||||
Name = "ProxyInterfaceGenerator.Proxy",
|
||||
ArgumentList = "typeof(Microsoft.SharePoint.Client.ClientRuntimeContext)"
|
||||
}
|
||||
};
|
||||
|
||||
var pathClientContext = "./Source/PnP/IClientContext.cs";
|
||||
var sourceFileClientContext = new SourceFile
|
||||
{
|
||||
Path = pathClientContext,
|
||||
Text = File.ReadAllText(pathClientContext),
|
||||
AttributeToAddToInterface = new ExtraAttribute
|
||||
{
|
||||
Name = "ProxyInterfaceGenerator.Proxy",
|
||||
ArgumentList = "typeof(ClientContext)" // Only name, no namespace
|
||||
}
|
||||
};
|
||||
|
||||
// Act
|
||||
var result = _sut.Execute(new[]
|
||||
{
|
||||
sourceFileClientObject,
|
||||
sourceFileWeb,
|
||||
sourceFileClientRuntimeContext,
|
||||
sourceFileClientContext
|
||||
});
|
||||
|
||||
// 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}"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user