add csharpier

This commit is contained in:
Adam Hathcock
2024-05-21 16:34:46 +01:00
parent 1734d5162a
commit e341772cbc
110 changed files with 1096 additions and 656 deletions
@@ -40,10 +40,7 @@ public class AkkaTests
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -54,8 +51,14 @@ public class AkkaTests
var builder = result.Files[fileName.index + 1]; // +1 means skip the attribute
builder.Path.Should().EndWith(fileName.fileName);
if (Write) File.WriteAllText($"../../../Destination/AkkaGenerated/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/AkkaGenerated/{fileName.fileName}"));
if (Write)
File.WriteAllText(
$"../../../Destination/AkkaGenerated/{fileName.fileName}",
builder.Text
);
builder
.Text.Should()
.Be(File.ReadAllText($"../../../Destination/AkkaGenerated/{fileName.fileName}"));
}
}
}
}
@@ -27,17 +27,17 @@ public class InheritedInterfaceTests
[Theory]
[InlineData(false, false)]
[InlineData(true, true)]
public void GenerateFiles_InheritedInterface_InheritFromBaseClass(bool proxyBaseClass, bool inheritBaseInterface)
public void GenerateFiles_InheritedInterface_InheritFromBaseClass(
bool proxyBaseClass,
bool inheritBaseInterface
)
{
var name = "Child";
var interfaceName = "I" + name;
var proxyName = name + "Proxy";
// Arrange
string[] fileNames = [
$"{Namespace}.{interfaceName}.g.cs",
$"{Namespace}.{proxyName}.g.cs"
];
string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"];
var path = $"./Source/Disposable/{interfaceName}.cs";
SourceFile sourceFile = CreateSourceFile(path, name, proxyBaseClass);
@@ -69,10 +69,7 @@ public class InheritedInterfaceTests
var proxyName = name + "Proxy";
// Arrange
string[] fileNames = [
$"{Namespace}.{interfaceName}.g.cs",
$"{Namespace}.{proxyName}.g.cs"
];
string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"];
var path = $"./Source/Disposable/{interfaceName}.cs";
SourceFile sourceFile = CreateSourceFile(path, name, true);
@@ -107,10 +104,7 @@ public class InheritedInterfaceTests
var proxyName = name + "Proxy";
// Arrange
string[] fileNames = [
$"{Namespace}.{interfaceName}.g.cs",
$"{Namespace}.{proxyName}.g.cs"
];
string[] fileNames = [$"{Namespace}.{interfaceName}.g.cs", $"{Namespace}.{proxyName}.g.cs"];
var interfaceIndex = 1;
var path = $"./Source/Disposable/{interfaceName}.cs";
SourceFile sourceFile = CreateSourceFile(path, name, true);
@@ -161,4 +155,4 @@ public class InheritedInterfaceTests
builder.Text.Should().Be(File.ReadAllText($"{OutputPath}{fileName.fileName}"));
}
}
}
}
@@ -30,7 +30,6 @@ public class PnPTests
"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.SecurableObjectProxy.g.cs",
"Microsoft.SharePoint.Client.WebProxy.g.cs",
@@ -99,14 +98,16 @@ public class PnPTests
};
// Act
var result = _sut.Execute(new[]
{
sourceFileClientObject,
sourceFileSec,
sourceFileWeb,
sourceFileClientRuntimeContext,
sourceFileClientContext
});
var result = _sut.Execute(
new[]
{
sourceFileClientObject,
sourceFileSec,
sourceFileWeb,
sourceFileClientRuntimeContext,
sourceFileClientContext
}
);
// Assert
result.Valid.Should().BeTrue();
@@ -117,8 +118,9 @@ public class PnPTests
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
}
}
@@ -72,10 +72,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -86,7 +83,6 @@ public class ProxyInterfaceSourceGeneratorTest
return Verify(results);
}
[Fact]
public Task GenerateFiles_ForClassWithIgnores()
{
@@ -105,19 +101,18 @@ public class ProxyInterfaceSourceGeneratorTest
AttributeToAddToInterface = new ExtraAttribute
{
Name = "ProxyInterfaceGenerator.Proxy",
ArgumentList = new []
ArgumentList = new[]
{
"typeof(ProxyInterfaceSourceGeneratorTests.Source.Foo2)", "false", "ProxyClassAccessibility.Public",
"typeof(ProxyInterfaceSourceGeneratorTests.Source.Foo2)",
"false",
"ProxyClassAccessibility.Public",
"new []{\"Weird\",\"NotHere\"}"
}
}
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -151,10 +146,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -165,7 +157,8 @@ public class ProxyInterfaceSourceGeneratorTest
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
@@ -193,10 +186,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -207,7 +197,8 @@ public class ProxyInterfaceSourceGeneratorTest
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
@@ -235,10 +226,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -249,15 +237,13 @@ public class ProxyInterfaceSourceGeneratorTest
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
var name = "stef";
var operatorTest = new OperatorTest
{
Name = name
};
var operatorTest = new OperatorTest { Name = name };
string name1 = (string)operatorTest;
name1.Should().Be(name);
@@ -273,11 +259,7 @@ public class ProxyInterfaceSourceGeneratorTest
public void GenerateFiles_When_NoNamespace_Should_GenerateCorrectFiles()
{
// Arrange
var fileNames = new[]
{
"INoNamespace.g.cs",
"NoNamespaceProxy.g.cs"
};
var fileNames = new[] { "INoNamespace.g.cs", "NoNamespaceProxy.g.cs" };
var path = "./Source/INoNamespace.cs";
var sourceFile = new SourceFile
@@ -292,10 +274,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -306,7 +285,8 @@ public class ProxyInterfaceSourceGeneratorTest
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
@@ -334,10 +314,7 @@ public class ProxyInterfaceSourceGeneratorTest
};
// Act
var result = _sut.Execute(new[]
{
sourceFile
});
var result = _sut.Execute(new[] { sourceFile });
// Assert
result.Valid.Should().BeTrue();
@@ -348,7 +325,8 @@ public class ProxyInterfaceSourceGeneratorTest
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);
if (Write)
File.WriteAllText($"../../../Destination/{fileName.fileName}", builder.Text);
builder.Text.Should().Be(File.ReadAllText($"../../../Destination/{fileName.fileName}"));
}
}
@@ -359,7 +337,8 @@ public class ProxyInterfaceSourceGeneratorTest
// Arrange
var attributeFilename = "ProxyInterfaceGenerator.Extra.g.cs";
var interfaceFilename = "ProxyInterfaceSourceGeneratorTests.Source.IPersonExtends.g.cs";
var proxyClassFilename = "ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs";
var proxyClassFilename =
"ProxyInterfaceSourceGeneratorTests.Source.PersonExtendsProxy.g.cs";
var path = "./Source/IPersonExtends.cs";
var sourceFile = new SourceFile
@@ -369,7 +348,11 @@ public class ProxyInterfaceSourceGeneratorTest
AttributeToAddToInterface = new ExtraAttribute
{
Name = "ProxyInterfaceGenerator.Proxy",
ArgumentList = new[] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.PersonExtends)", "true" }
ArgumentList = new[]
{
"typeof(ProxyInterfaceSourceGeneratorTests.Source.PersonExtends)",
"true"
}
}
};
@@ -389,16 +372,24 @@ public class ProxyInterfaceSourceGeneratorTest
@interface.FilePath.Should().EndWith(interfaceFilename);
var interfaceCode = @interface.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
// Assert Proxy
var proxyClass = result.Files[2].SyntaxTree;
proxyClass.FilePath.Should().EndWith(proxyClassFilename);
var proxyCode = proxyClass.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
}
[Fact]
@@ -406,7 +397,8 @@ public class ProxyInterfaceSourceGeneratorTest
{
// Arrange
var interfaceFilename = "ProxyInterfaceSourceGeneratorTests.Source.ITestClassInternal.g.cs";
var proxyClassFilename = "ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs";
var proxyClassFilename =
"ProxyInterfaceSourceGeneratorTests.Source.TestClassInternalProxy.g.cs";
var path = "./Source/ITestClassInternal.cs";
var sourceFile = new SourceFile
@@ -416,7 +408,11 @@ public class ProxyInterfaceSourceGeneratorTest
AttributeToAddToInterface = new ExtraAttribute
{
Name = "ProxyInterfaceGenerator.Proxy",
ArgumentList = new[] { "typeof(ProxyInterfaceSourceGeneratorTests.Source.TestClassInternal)", "ProxyClassAccessibility.Internal" }
ArgumentList = new[]
{
"typeof(ProxyInterfaceSourceGeneratorTests.Source.TestClassInternal)",
"ProxyClassAccessibility.Internal"
}
}
};
@@ -432,16 +428,24 @@ public class ProxyInterfaceSourceGeneratorTest
@interface.FilePath.Should().EndWith(interfaceFilename);
var interfaceCode = @interface.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
// Assert Proxy
var proxyClass = result.Files[2].SyntaxTree;
proxyClass.FilePath.Should().EndWith(proxyClassFilename);
var proxyCode = proxyClass.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
}
[Fact]
@@ -489,41 +493,56 @@ public class ProxyInterfaceSourceGeneratorTest
var attribute = result.Files[0].SyntaxTree;
attribute.FilePath.Should().EndWith(attributeFilename);
// Assert interface Human
var interfaceHuman = result.Files[1].SyntaxTree;
interfaceHuman.FilePath.Should().EndWith(interfaceHumanFilename);
var interfaceCodeHuman = interfaceHuman.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceHumanFilename}", interfaceCodeHuman);
interfaceCodeHuman.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceHumanFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{interfaceHumanFilename}", interfaceCodeHuman);
interfaceCodeHuman
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfaceHumanFilename}"));
// Assert interface Person
var interfacePerson = result.Files[2].SyntaxTree;
interfacePerson.FilePath.Should().EndWith(interfacePersonFilename);
var interfaceCodePerson = interfacePerson.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfacePersonFilename}", interfaceCodePerson);
interfaceCodePerson.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfacePersonFilename}"));
if (Write)
File.WriteAllText(
$"../../../Destination/{interfacePersonFilename}",
interfaceCodePerson
);
interfaceCodePerson
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfacePersonFilename}"));
// Assert Proxy Human
var proxyClassHuman = result.Files[3].SyntaxTree;
proxyClassHuman.FilePath.Should().EndWith(proxyClassHumanFilename);
var proxyCodeHuman = proxyClassHuman.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassHumanFilename}", proxyCodeHuman);
proxyCodeHuman.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassHumanFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{proxyClassHumanFilename}", proxyCodeHuman);
proxyCodeHuman
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassHumanFilename}"));
// Assert Proxy Person
var proxyClassPerson = result.Files[4].SyntaxTree;
proxyClassPerson.FilePath.Should().EndWith(proxyClassPersonFilename);
var proxyCode = proxyClassPerson.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassPersonFilename}", proxyCode);
proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassPersonFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{proxyClassPersonFilename}", proxyCode);
proxyCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassPersonFilename}"));
var personProxy = new PersonProxy(new Person());
@@ -538,9 +557,11 @@ public class ProxyInterfaceSourceGeneratorTest
{
// Arrange
var attributeFilename = "ProxyInterfaceGenerator.Extra.g.cs";
var interfaceIHttpClientFilename = "ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs";
var interfaceIHttpClientFilename =
"ProxyInterfaceSourceGeneratorTests.Source.IHttpClient.g.cs";
var proxyClassIHttpClientFilename = "System.Net.Http.HttpClientProxy.g.cs";
var interfaceIHttpMessageInvokerFilename = "ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs";
var interfaceIHttpMessageInvokerFilename =
"ProxyInterfaceSourceGeneratorTests.Source.IHttpMessageInvoker.g.cs";
var proxyClassIHttpMessageInvokerFilename = "System.Net.Http.HttpMessageInvokerProxy.g.cs";
var pathIHttpClient = "./Source/IHttpClient.cs";
@@ -578,41 +599,69 @@ public class ProxyInterfaceSourceGeneratorTest
var attribute = result.Files[0].SyntaxTree;
attribute.FilePath.Should().EndWith(attributeFilename);
// Assert interface IHttpClient
var interfaceIHttpClient = result.Files[1].SyntaxTree;
interfaceIHttpClient.FilePath.Should().EndWith(interfaceIHttpClientFilename);
var interfaceCodeIHttpClient = interfaceIHttpClient.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceIHttpClientFilename}", interfaceCodeIHttpClient);
interfaceCodeIHttpClient.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceIHttpClientFilename}"));
if (Write)
File.WriteAllText(
$"../../../Destination/{interfaceIHttpClientFilename}",
interfaceCodeIHttpClient
);
interfaceCodeIHttpClient
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfaceIHttpClientFilename}"));
// Assert interface IHttpMessageInvoker
var interfaceIMessageInvoker = result.Files[2].SyntaxTree;
interfaceIMessageInvoker.FilePath.Should().EndWith(interfaceIHttpMessageInvokerFilename);
var interfaceCodeIMessageInvoker = interfaceIMessageInvoker.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceIHttpMessageInvokerFilename}", interfaceCodeIMessageInvoker);
interfaceCodeIMessageInvoker.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceIHttpMessageInvokerFilename}"));
if (Write)
File.WriteAllText(
$"../../../Destination/{interfaceIHttpMessageInvokerFilename}",
interfaceCodeIMessageInvoker
);
interfaceCodeIMessageInvoker
.Should()
.NotBeNullOrEmpty()
.And.Be(
File.ReadAllText($"../../../Destination/{interfaceIHttpMessageInvokerFilename}")
);
// Assert Proxy IHttpClient
var proxyClassIHttpClient = result.Files[3].SyntaxTree;
proxyClassIHttpClient.FilePath.Should().EndWith(proxyClassIHttpClientFilename);
var proxyCodeIHttpClient = proxyClassIHttpClient.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassIHttpClientFilename}", proxyCodeIHttpClient);
proxyCodeIHttpClient.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassIHttpClientFilename}"));
if (Write)
File.WriteAllText(
$"../../../Destination/{proxyClassIHttpClientFilename}",
proxyCodeIHttpClient
);
proxyCodeIHttpClient
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassIHttpClientFilename}"));
// Assert Proxy IHttpMessageInvoker
var proxyClassIMessageInvoker = result.Files[4].SyntaxTree;
proxyClassIMessageInvoker.FilePath.Should().EndWith(proxyClassIHttpMessageInvokerFilename);
var proxyIMessageInvoker = proxyClassIMessageInvoker.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassIHttpMessageInvokerFilename}", proxyIMessageInvoker);
proxyIMessageInvoker.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassIHttpMessageInvokerFilename}"));
if (Write)
File.WriteAllText(
$"../../../Destination/{proxyClassIHttpMessageInvokerFilename}",
proxyIMessageInvoker
);
proxyIMessageInvoker
.Should()
.NotBeNullOrEmpty()
.And.Be(
File.ReadAllText($"../../../Destination/{proxyClassIHttpMessageInvokerFilename}")
);
}
[Fact]
@@ -623,8 +672,10 @@ public class ProxyInterfaceSourceGeneratorTest
foreach (var x in new[] { 1, 2 })
{
var attributeFilename = "ProxyInterfaceGenerator.Extra.g.cs";
var interfaceFilename = $"ProxyInterfaceSourceGeneratorTests.Namespace{x}.I{@class}.g.cs";
var proxyClassFilename = $"ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class}Proxy.g.cs";
var interfaceFilename =
$"ProxyInterfaceSourceGeneratorTests.Namespace{x}.I{@class}.g.cs";
var proxyClassFilename =
$"ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class}Proxy.g.cs";
var path = $"./Source/I{@class}{x}.cs";
var sourceFile = new SourceFile
@@ -634,7 +685,11 @@ public class ProxyInterfaceSourceGeneratorTest
AttributeToAddToInterface = new ExtraAttribute
{
Name = "ProxyInterfaceGenerator.Proxy",
ArgumentList = new[] { $"typeof(ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class})", "true" }
ArgumentList = new[]
{
$"typeof(ProxyInterfaceSourceGeneratorTests.Namespace{x}.{@class})",
"true"
}
}
};
@@ -654,18 +709,24 @@ public class ProxyInterfaceSourceGeneratorTest
@interface.FilePath.Should().EndWith(interfaceFilename);
var interfaceCode = @interface.ToString();
if (Write) File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{interfaceFilename}", interfaceCode);
interfaceCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{interfaceFilename}"));
// Assert Proxy
var proxyClass = result.Files[2].SyntaxTree;
proxyClass.FilePath.Should().EndWith(proxyClassFilename);
var proxyCode = proxyClass.ToString();
if (Write) File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode.Should().NotBeNullOrEmpty().And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
if (Write)
File.WriteAllText($"../../../Destination/{proxyClassFilename}", proxyCode);
proxyCode
.Should()
.NotBeNullOrEmpty()
.And.Be(File.ReadAllText($"../../../Destination/{proxyClassFilename}"));
}
}
}
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.AkkaActor
{
public partial interface ILocalActorRefProvider
{
}
}
public partial interface ILocalActorRefProvider { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.AkkaActor
{
public partial interface ILocalActorRefProvider
{
}
}
public partial interface ILocalActorRefProvider { }
}
@@ -1,5 +1,3 @@
namespace ProxyInterfaceSourceGeneratorTests.Source;
public class Bar
{
}
public class Bar { }
@@ -1,7 +1,5 @@
// ReSharper disable once CheckNamespace
namespace ProxyInterfaceSourceGeneratorTests.Namespace1
{
public class ClassInNamespace
{
}
}
public class ClassInNamespace { }
}
@@ -1,7 +1,5 @@
// ReSharper disable once CheckNamespace
namespace ProxyInterfaceSourceGeneratorTests.Namespace2
{
public class ClassInNamespace
{
}
}
public class ClassInNamespace { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public class Child : Parent
{
}
}
public class Child : Parent { }
}
@@ -6,15 +6,8 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
event EventHandler<string>? IUpdate<string>.Update
{
add
{
throw new NotSupportedException();
}
remove
{
throw new NotSupportedException();
}
add { throw new NotSupportedException(); }
remove { throw new NotSupportedException(); }
}
void IDisposable.Dispose()
@@ -22,4 +15,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
throw new NotSupportedException();
}
}
}
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IChild
{
}
}
public partial interface IChild { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IExplicit
{
}
}
public partial interface IExplicit { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IParent
{
}
}
public partial interface IParent { }
}
@@ -6,4 +6,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
string Name { get; }
}
}
}
@@ -42,4 +42,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
// Dispose(disposing: false);
// }
}
}
}
@@ -20,13 +20,15 @@ public class Foo2
//}
[SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")]
public Foo2[] Foos { get; set; }= null!;
public Foo2[] Foos { get; set; } = null!;
public Foo2[] DoSomethingAndGetAnArrayOfFoos()
{
return new[] { new Foo2() };
}
public int Weird { get; set; }
public int Weird2()
{
return 0;
@@ -7,4 +7,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
return value;
}
}
}
}
@@ -6,9 +6,6 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
public string GetterOnly => "x";
public void Dispose()
{
}
public void Dispose() { }
}
}
}
@@ -1,7 +1,5 @@
// ReSharper disable once CheckNamespace
namespace ProxyInterfaceSourceGeneratorTests.Namespace1
{
public partial interface IClassInNamespace
{
}
}
public partial interface IClassInNamespace { }
}
@@ -1,7 +1,5 @@
// ReSharper disable once CheckNamespace
namespace ProxyInterfaceSourceGeneratorTests.Namespace2
{
public partial interface IClassInNamespace
{
}
}
public partial interface IClassInNamespace { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IFoo
{
}
}
public partial interface IFoo { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IFoo2
{
}
}
public partial interface IFoo2 { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IGeneric
{
}
}
public partial interface IGeneric { }
}
@@ -1,5 +1,3 @@
namespace ProxyInterfaceSourceGeneratorTests.Source;
public partial interface IHttpClient : IHttpMessageInvoker
{
}
public partial interface IHttpClient : IHttpMessageInvoker { }
@@ -1,5 +1,3 @@
namespace ProxyInterfaceSourceGeneratorTests.Source;
public partial interface IHttpMessageInvoker
{
}
public partial interface IHttpMessageInvoker { }
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IHuman
{
}
}
public partial interface IHuman { }
}
@@ -1,5 +1,3 @@
namespace ProxyInterfaceSourceGeneratorTests.Source;
public partial interface IMixedVisibility
{
}
public partial interface IMixedVisibility { }
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IMyStruct
{
}
}
public partial interface IMyStruct { }
}
@@ -1,4 +1,2 @@
// ReSharper disable once CheckNamespace
public partial interface INoNamespace
{
}
public partial interface INoNamespace { }
@@ -1,6 +1,4 @@
// file-scoped namespace !
namespace ProxyInterfaceSourceGeneratorTests.Source;
public partial interface IOperatorTest
{
}
public partial interface IOperatorTest { }
@@ -1,6 +1,4 @@
// file-scoped namespace !
namespace ProxyInterfaceSourceGeneratorTests.Source;
public partial interface IPerson : IHuman
{
}
public partial interface IPerson : IHuman { }
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface IPersonExtends
{
}
}
public partial interface IPersonExtends { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public partial interface ITestClassInternal
{
}
}
public partial interface ITestClassInternal { }
}
@@ -6,7 +6,5 @@ using System.Threading.Tasks;
namespace ProxyInterfaceSourceGeneratorTests.Source
{
public interface IÜberGeneric
{
}
public interface IÜberGeneric { }
}
@@ -5,5 +5,5 @@ namespace ProxyInterfaceSourceGeneratorTests.Source;
public class MixedVisibility
{
[SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")]
public string Foo { get; protected set; } = null!;//<- this will generate bad code
public string Foo { get; protected set; } = null!; //<- this will generate bad code
}
@@ -3,4 +3,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source;
public struct MyStruct
{
public int Id { get; set; }
}
}
@@ -3,4 +3,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source;
public class NoNamespace
{
public bool Test { get; set; }
}
}
@@ -9,18 +9,12 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
// Operator : implicit
public static implicit operator OperatorTest(string name)
{
return new()
{
Name = name
};
return new() { Name = name };
}
public static implicit operator OperatorTest(int? id)
{
return new()
{
Id = id
};
return new() { Id = id };
}
// Operator : explicit
@@ -43,4 +37,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
var s = (string)operatorTest;
}
}
}
}
@@ -25,23 +25,25 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
public IList<Human> AddHuman(Human h)
{
return new List<Human> { h, new Human { IsAlive = true } };
return new List<Human>
{
h,
new Human { IsAlive = true }
};
}
[Display(ResourceType = typeof(PeriodicTimer))]
[SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")]
public string Name { get; set; }= null!;
public string Name { get; set; } = null!;
public string? StringNullable { get; set; }
public long? NullableLong { get; }
[SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")]
public object @object { get; set; }= null!;
public object @object { get; set; } = null!;
public void Void()
{
}
public void Void() { }
public string HelloWorld(string name)
{
@@ -68,9 +70,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
return $"Hello {ch} !";
}
public void WithParams(params string[] values)
{
}
public void WithParams(params string[] values) { }
public string Add(string s, string @string)
{
@@ -117,11 +117,14 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
return Task.FromResult((string?)"");
}
public void CreateInvokeHttpClient(int i = 5, string? appId = null, IReadOnlyDictionary<string, string>? metadata = null, CancellationToken token = default)
{
}
public void CreateInvokeHttpClient(
int i = 5,
string? appId = null,
IReadOnlyDictionary<string, string>? metadata = null,
CancellationToken token = default
) { }
public bool TryParse(string s1, [NotNullWhen(true)]params int[]? ii)
public bool TryParse(string s1, [NotNullWhen(true)] params int[]? ii)
{
ii = null;
return false;
@@ -17,18 +17,14 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
public object @object { get; set; } = null!;
public void Void()
{
}
public void Void() { }
public string HelloWorld(string name)
{
return $"Hello {name} !";
}
public void WithParams(params string[] values)
{
}
public void WithParams(params string[] values) { }
public string Add(string s, string @string)
{
@@ -67,4 +63,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
return Task.FromResult((string?)"");
}
}
}
}
@@ -2,8 +2,5 @@ using Microsoft.SharePoint.Client;
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
{
public partial interface IClientContext
{
}
}
public partial interface IClientContext { }
}
@@ -1,6 +1,4 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
{
public partial interface IClientObject
{
}
public partial interface IClientObject { }
}
@@ -1,8 +1,6 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
{
public partial interface IClientRuntimeContext
{
}
public partial interface IClientRuntimeContext { }
}
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
@@ -22,6 +20,5 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
//{
// var x = CastTo2<ClientObjectProxy>(new ClientObjectProxy(default));
//}
}
}
}
@@ -3,7 +3,5 @@ using Microsoft.SharePoint.Client;
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
{
// [ProxyInterfaceGenerator.Proxy(typeof(SecurableObject))]
public partial interface ISecurableObject : IClientObject
{
}
}
public partial interface ISecurableObject : IClientObject { }
}
@@ -2,7 +2,5 @@ using Microsoft.SharePoint.Client;
namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
{
public partial interface IWeb : ISecurableObject
{
}
}
public partial interface IWeb : ISecurableObject { }
}
@@ -4,4 +4,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
{
public bool Test { get; set; }
}
}
}
@@ -14,4 +14,4 @@ namespace ProxyInterfaceSourceGeneratorTests.Source
public TKey Test(TKey value) => value;
}
}
}