Do not redefine interfaces. (#67)

* Do not redefine interfaces.

* Improve code style, readability and performance after initial code review

* Implemented unit tests for the interface inheritance

* Cleaned up unit tests.

* Completely remove output helper.
This commit is contained in:
David
2024-04-23 10:52:52 +02:00
committed by GitHub
parent d2d1115753
commit 6b6e5d04a0
15 changed files with 340 additions and 11 deletions
@@ -0,0 +1,6 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public class Child : Parent
{
}
}
@@ -0,0 +1,25 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public class Explicit : IDisposable, IUpdate<string>
{
string IUpdate<string>.Name => throw new NotSupportedException();
event EventHandler<string>? IUpdate<string>.Update
{
add
{
throw new NotSupportedException();
}
remove
{
throw new NotSupportedException();
}
}
void IDisposable.Dispose()
{
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,6 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IChild
{
}
}
@@ -0,0 +1,6 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IExplicit
{
}
}
@@ -0,0 +1,6 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public partial interface IParent
{
}
}
@@ -0,0 +1,9 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public interface IUpdate<T>
{
event EventHandler<T>? Update;
string Name { get; }
}
}
@@ -0,0 +1,45 @@
namespace ProxyInterfaceSourceGeneratorTests.Source.Disposable
{
public class Parent : IDisposable, IUpdate<string>
{
private bool disposedValue;
public event EventHandler<string>? Update;
public string Name => nameof(Parent);
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public bool Empty()
{
return false;
}
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: dispose managed state (managed objects)
}
// TODO: free unmanaged resources (unmanaged objects) and override finalizer
// TODO: set large fields to null
disposedValue = true;
}
}
// // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
// ~TrashCan()
// {
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false);
// }
}
}