From a78784ad5bb8475ef910a5c532b870969aac4f8f Mon Sep 17 00:00:00 2001 From: Aaron Costley Date: Tue, 9 Oct 2018 21:19:34 -0700 Subject: [PATCH] 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 --- .../src/Amazon.JSII.Generator/SymbolMap.cs | 17 +++++++++-------- .../Tests/CalculatorNamespace/UseCalcBase.cs | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/SymbolMap.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/SymbolMap.cs index eb5a9a3175..a174727ee2 100644 --- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/SymbolMap.cs +++ b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/SymbolMap.cs @@ -1,11 +1,12 @@ -using Amazon.JSII.JsonModel.Spec; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using System; +using System; using System.Collections.Generic; using System.Linq; +using Amazon.JSII.JsonModel.Spec; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory; using Type = Amazon.JSII.JsonModel.Spec.Type; +using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind; namespace Amazon.JSII.Generator { @@ -53,7 +54,7 @@ TypeMetadata GetMetadata(Type type) { switch (type.Kind) { - case JsonModel.Spec.TypeKind.Class: + case TypeKind.Class: { var classType = (ClassType) type; if (classType.IsAbstract) @@ -62,11 +63,11 @@ TypeMetadata GetMetadata(Type type) } return new ClassTypeMetadata((ClassType)type, assembly); } - case JsonModel.Spec.TypeKind.Enum: + case TypeKind.Enum: { return new EnumTypeMetadata((EnumType)type, assembly); } - case JsonModel.Spec.TypeKind.Interface: + case TypeKind.Interface: { return new InterfaceTypeMetadata((InterfaceType)type, assembly); } @@ -415,7 +416,7 @@ public TypeSyntax GetTypeSyntax(TypeReference typeReference) { Type type = GetTypeFromFullyQualifiedName(typeReference.FullyQualifiedName); - return SF.ParseTypeName(GetName(type)); + return SF.ParseTypeName(GetName(type, true)); } throw new ArgumentException("Invalid type reference", nameof(typeReference)); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseCalcBase.cs b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseCalcBase.cs index a93601c43d..030ef296ac 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseCalcBase.cs +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon/JSII/Tests/CalculatorNamespace/UseCalcBase.cs @@ -20,9 +20,9 @@ protected UseCalcBase(DeputyProps props): base(props) } [JsiiMethod("hello", "{\"fqn\":\"@scope/jsii-calc-base.Base\"}", "[]")] - public virtual Base Hello() + public virtual Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace.Base Hello() { - return InvokeInstanceMethod(new object[]{}); + return InvokeInstanceMethod(new object[]{}); } } } \ No newline at end of file