Skip to content

Commit a78784a

Browse files
costleyaElad Ben-Israel
authored and
Elad Ben-Israel
committed
fix(jsii-dotnet-generator): Use FQ type returns in conflict. (#258)
Use fully-qualified types in return values when there is a conflict. Fixes #252
1 parent 879d5db commit a78784a

File tree

2 files changed

+11
-10
lines changed
  • packages
    • jsii-dotnet-generator/src/Amazon.JSII.Generator
    • jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace

2 files changed

+11
-10
lines changed

packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/SymbolMap.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using Amazon.JSII.JsonModel.Spec;
2-
using Microsoft.CodeAnalysis;
3-
using Microsoft.CodeAnalysis.CSharp.Syntax;
4-
using System;
1+
using System;
52
using System.Collections.Generic;
63
using System.Linq;
4+
using Amazon.JSII.JsonModel.Spec;
5+
using Microsoft.CodeAnalysis;
6+
using Microsoft.CodeAnalysis.CSharp.Syntax;
77
using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
88
using Type = Amazon.JSII.JsonModel.Spec.Type;
9+
using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind;
910

1011
namespace Amazon.JSII.Generator
1112
{
@@ -53,7 +54,7 @@ TypeMetadata GetMetadata(Type type)
5354
{
5455
switch (type.Kind)
5556
{
56-
case JsonModel.Spec.TypeKind.Class:
57+
case TypeKind.Class:
5758
{
5859
var classType = (ClassType) type;
5960
if (classType.IsAbstract)
@@ -62,11 +63,11 @@ TypeMetadata GetMetadata(Type type)
6263
}
6364
return new ClassTypeMetadata((ClassType)type, assembly);
6465
}
65-
case JsonModel.Spec.TypeKind.Enum:
66+
case TypeKind.Enum:
6667
{
6768
return new EnumTypeMetadata((EnumType)type, assembly);
6869
}
69-
case JsonModel.Spec.TypeKind.Interface:
70+
case TypeKind.Interface:
7071
{
7172
return new InterfaceTypeMetadata((InterfaceType)type, assembly);
7273
}
@@ -415,7 +416,7 @@ public TypeSyntax GetTypeSyntax(TypeReference typeReference)
415416
{
416417
Type type = GetTypeFromFullyQualifiedName(typeReference.FullyQualifiedName);
417418

418-
return SF.ParseTypeName(GetName(type));
419+
return SF.ParseTypeName(GetName(type, true));
419420
}
420421

421422
throw new ArgumentException("Invalid type reference", nameof(typeReference));

packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseCalcBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ protected UseCalcBase(DeputyProps props): base(props)
2020
}
2121

2222
[JsiiMethod("hello", "{\"fqn\":\"@scope/jsii-calc-base.Base\"}", "[]")]
23-
public virtual Base Hello()
23+
public virtual Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace.Base Hello()
2424
{
25-
return InvokeInstanceMethod<Base>(new object[]{});
25+
return InvokeInstanceMethod<Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace.Base>(new object[]{});
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)