Add test for new _Instance but removing if option is used
This commit is contained in:
@@ -31,15 +31,15 @@ It supports:
|
||||
|
||||
## Install
|
||||
|
||||
[](https://www.nuget.org/packages/ProxyInterfaceGenerator)
|
||||
[](https://www.nuget.org/packages/Speckle.ProxyGenerator)
|
||||
|
||||
You can install from NuGet using the following command in the package manager window:
|
||||
|
||||
`Install-Package ProxyInterfaceGenerator`
|
||||
`Install-Package Speckle.ProxyGenerator`
|
||||
|
||||
Or via the Visual Studio NuGet package manager or if you use the `dotnet` command:
|
||||
|
||||
`dotnet add package ProxyInterfaceGenerator`
|
||||
`dotnet add package Speckle.ProxyGenerator`
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -300,11 +300,6 @@ internal abstract class BaseGenerator
|
||||
if (useFullQualifiedMappedTypeName)
|
||||
{
|
||||
//is a candidate and overrides
|
||||
if (candidate?.FullQualifiedMappedTypeName != null)
|
||||
{
|
||||
extendsProxyClasses.Add(candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>0.1.5</Version>
|
||||
<Version>0.1.6</Version>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
|
||||
{
|
||||
public partial interface IClientContext
|
||||
{
|
||||
new global::Microsoft.SharePoint.Client.ClientContext _Instance { get; }
|
||||
global::Microsoft.SharePoint.Client.ClientContext _Instance { get; }
|
||||
|
||||
global::ProxyInterfaceSourceGeneratorTests.Source.PnP.IWeb Web { get; }
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
|
||||
{
|
||||
public partial interface ISecurableObject : global::ProxyInterfaceSourceGeneratorTests.Source.PnP.IClientObject
|
||||
{
|
||||
new global::Microsoft.SharePoint.Client.SecurableObject _Instance { get; }
|
||||
global::Microsoft.SharePoint.Client.SecurableObject _Instance { get; }
|
||||
|
||||
[Microsoft.SharePoint.Client.RemoteAttribute]
|
||||
global::ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject FirstUniqueAncestorSecurableObject { get; }
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace ProxyInterfaceSourceGeneratorTests.Source.PnP
|
||||
{
|
||||
public partial interface IWeb : global::ProxyInterfaceSourceGeneratorTests.Source.PnP.ISecurableObject
|
||||
{
|
||||
new global::Microsoft.SharePoint.Client.Web _Instance { get; }
|
||||
global::Microsoft.SharePoint.Client.Web _Instance { get; }
|
||||
|
||||
[Microsoft.SharePoint.Client.RemoteAttribute]
|
||||
string AccessRequestListUrl { get; }
|
||||
|
||||
@@ -106,6 +106,39 @@ public class InheritedInterfaceTests
|
||||
Assert.Equal(nameof(IUpdate<string>), type2.Right.Identifier.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenerateFiles_InheritedInterface_Should_InheritTheInterfaceAndNotNew()
|
||||
{
|
||||
var className1 = "LocationPoint";
|
||||
var interfaceName1 = "IRevitLocationPointProxy";
|
||||
var proxyName1 = $"{className1}Proxy";
|
||||
|
||||
// Arrange
|
||||
var path1 = $"./Source/Disposable/{interfaceName1}.cs";
|
||||
|
||||
var sourceFile1 = CreateSourceFile(path1, className1, ImplementationOptions.ProxyForBaseInterface | ImplementationOptions.UseExtendedInterfaces);
|
||||
var className2 = "Location";
|
||||
var interfaceName2 = "IRevitLocationProxy";
|
||||
var proxyName2 = $"{className2}Proxy";
|
||||
|
||||
// Arrange
|
||||
var path2 = $"./Source/Disposable/{interfaceName2}.cs";
|
||||
var sourceFile2 = CreateSourceFile(path2, className2, ImplementationOptions.ProxyForBaseInterface | ImplementationOptions.UseExtendedInterfaces);
|
||||
|
||||
// Act
|
||||
var result = _sut.Execute([sourceFile1, sourceFile2]);
|
||||
string[] fileNames = [$"{Namespace}.{interfaceName1}.g.cs", $"{Namespace}.{proxyName1}.g.cs",
|
||||
$"{Namespace}.{interfaceName2}.g.cs", $"{Namespace}.{proxyName2}.g.cs"];
|
||||
|
||||
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
|
||||
File.WriteAllText($"{OutputPath}{fileName.fileName}", builder.Text);
|
||||
}
|
||||
}
|
||||
[Fact]
|
||||
public void GenerateFiles_InheritedInterface_Should_Not_InheritExplicitImplementedInterfaces()
|
||||
{
|
||||
@@ -145,7 +178,7 @@ public class InheritedInterfaceTests
|
||||
var o = string.Empty;
|
||||
foreach (var val in Enum.GetValues<ImplementationOptions>())
|
||||
{
|
||||
if (!options.HasFlag(val))
|
||||
if (val == ImplementationOptions.None || !options.HasFlag(val))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -154,7 +187,7 @@ public class InheritedInterfaceTests
|
||||
o += " | ";
|
||||
}
|
||||
|
||||
o += "ImplementationOptions." + val.ToString();
|
||||
o += "ImplementationOptions." + val;
|
||||
}
|
||||
if (o.Length == 0)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,13 @@
|
||||
<Compile Update="Source\Foo3.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Update="Source\Disposable\IRevitLocationPointProxy.cs">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Destination\Disposable\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable;
|
||||
|
||||
public partial interface IRevitLocationPointProxy : IRevitLocationPoint { }
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable;
|
||||
|
||||
public partial interface IRevitLocationProxy : IRevitLocation { }
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable;
|
||||
|
||||
|
||||
|
||||
public interface IRevitLocationPoint : IRevitLocation
|
||||
{
|
||||
}
|
||||
|
||||
public interface IRevitLocationCurve : IRevitLocation
|
||||
{
|
||||
IRevitCurve Curve { get; }
|
||||
}
|
||||
|
||||
public class LocationPoint : Location
|
||||
{
|
||||
public XYZ Point => throw new NotImplementedException();
|
||||
}
|
||||
public class Location : APIObject { }
|
||||
public class APIObject { }
|
||||
public class XYZ { }
|
||||
public interface IRevitLocation
|
||||
{
|
||||
}
|
||||
public interface IRevitCurve
|
||||
{
|
||||
double Length { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user