Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion AutomaticInterface/DotnetAutomaticInterface/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ bool nullableContextEnabled
)
{
var addNullable = new AddNullableAnnotationSyntaxRewriter();
// Modify the full parameter display string to add the nullable annotation
return addNullable
.Visit(param.DeclaringSyntaxReferences.First().GetSyntax())
.Visit(
SyntaxFactory.ParseParameterList(
param.ToDisplayString(FullyQualifiedDisplayFormat)
)
)
.ToFullString();
}
return param.ToDisplayString(FullyQualifiedDisplayFormat);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//--------------------------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.
// </auto-generated>
//--------------------------------------------------------------------------------------------------

#nullable enable
namespace AutomaticInterfaceExample
{
[global::System.CodeDom.Compiler.GeneratedCode("DotnetAutomaticInterface", "")]
public partial interface IDemoClass
{
/// <inheritdoc cref="AutomaticInterfaceExample.DemoClass.TryStartTransaction(int?, AutomaticInterfaceExample.Types.Model{AutomaticInterfaceExample.Types.Model2})" />
bool TryStartTransaction(int? param, global::AutomaticInterfaceExample.Types.Model<global::AutomaticInterfaceExample.Types.Model2>? modelParam = null);

}
}
#nullable restore
31 changes: 31 additions & 0 deletions AutomaticInterface/Tests/Methods/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@ public bool TryStartTransaction(int? param, int param2 = 0, string data = null,
await Verify(Infrastructure.GenerateCode(code));
}

[Fact]
public async Task FullyQualifyOptionalNullableGenericTypes()
{
const string code = """

using DotnetAutomaticInterface;


namespace AutomaticInterfaceExample {

namespace Types {
public class Model<T>;
public class Model2;
}

[GenerateAutomaticInterface]
public class DemoClass
{
public bool TryStartTransaction(int? param, Types.Model<Types.Model2> modelParam = null)
{
return true;
}
}

}


""";
await Verify(Infrastructure.GenerateCode(code));
}

[Fact]
public async Task AddsPublicMethodToInterface()
{
Expand Down