To Reproduce
Run this test code:
var code =
"""
using Rocks;
[assembly: Rock(typeof(IAuditTrail<>), BuildType.Create | BuildType.Make)]
public interface IAuditTrail
{
void Work() { }
}
public interface IAuditTrail<T>
: IAuditTrail
{
void Perform() { }
}
""";
Expected behavior
Rocks generates code with no issues.
Actual behavior
The following diagnostics are generated:
error CS0102: The type 'IAuditTrailCreateExpectations<T>.Mock' already contains a definition for 'shimForIAuditTrail'
error CS0229: Ambiguity between 'IAuditTrailCreateExpectations<T>.Mock.shimForIAuditTrail' and 'IAuditTrailCreateExpectations<T>.Mock.shimForIAuditTrail'
Additional context
The problem is that Rocks doesn't generate unique names for the shim field names:
private sealed class Mock
: global::IAuditTrail<T>
{
private readonly global::IAuditTrail<T> shimForIAuditTrail;
private readonly global::IAuditTrail shimForIAuditTrail;
// ...
}
Looks like the generic type parameter names should be added, similar to what is done for the file names. Something like this:
private readonly global::IAuditTrail<T> shimForIAuditTrailT;
If there are multiple, just append them together, something like this:
private readonly global::IAuditTrail<T1, T2, T3> shimForIAuditTrailT1T2T3;
This was found on DotNext.IO, DotNext.IO.Log.IAuditTrail<>
To Reproduce
Run this test code:
Expected behavior
Rocks generates code with no issues.
Actual behavior
The following diagnostics are generated:
Additional context
The problem is that Rocks doesn't generate unique names for the shim field names:
Looks like the generic type parameter names should be added, similar to what is done for the file names. Something like this:
If there are multiple, just append them together, something like this:
This was found on
DotNext.IO, DotNext.IO.Log.IAuditTrail<>