Skip to content

Commit

Permalink
fix(jsii-dotnet-generator): Use FQ type returns in conflict. (#258)
Browse files Browse the repository at this point in the history
Use fully-qualified types in return values when there is a conflict.

Fixes #252
  • Loading branch information
costleya authored and Elad Ben-Israel committed Oct 10, 2018
1 parent 879d5db commit a78784a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Base>(new object[]{});
return InvokeInstanceMethod<Amazon.JSII.Tests.CalculatorNamespace.BaseNamespace.Base>(new object[]{});
}
}
}

0 comments on commit a78784a

Please sign in to comment.