-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Interfaces in ScriptSharp definition generation are not emitted at full! Only the interface name and base list. Targets #41
- Loading branch information
1 parent
a41f6f9
commit 428b0c5
Showing
12 changed files
with
343 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <summary> | ||
/// ISyntaxFactory.cs | ||
/// Andrea Tino - 2017 | ||
/// </summary> | ||
|
||
namespace Rosetta.Reflection.Factories | ||
{ | ||
using System; | ||
|
||
using Microsoft.CodeAnalysis; | ||
|
||
/// <summary> | ||
/// Abstract common funcitonalities of syntax factories. | ||
/// </summary> | ||
public interface ISyntaxFactory | ||
{ | ||
|
||
/// <summary> | ||
/// Creates a <see cref="SyntaxNode"/>. | ||
/// </summary> | ||
/// <returns></returns> | ||
SyntaxNode Create(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/Reflection/factories/InterfaceDeclarationSyntaxFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/// <summary> | ||
/// InterfaceDeclarationSyntaxFactory.cs | ||
/// Andrea Tino - 2017 | ||
/// </summary> | ||
|
||
namespace Rosetta.Reflection.Factories | ||
{ | ||
using System; | ||
|
||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
using Rosetta.Reflection.Helpers; | ||
using Rosetta.Reflection.Proxies; | ||
|
||
/// <summary> | ||
/// Factory for generating a <see cref="InterfaceDeclarationSyntax"/>. | ||
/// </summary> | ||
public class InterfaceDeclarationSyntaxFactory : ISyntaxFactory | ||
{ | ||
private readonly ITypeInfoProxy interfaceInfo; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="InterfaceDeclarationSyntaxFactory"/> class. | ||
/// </summary> | ||
/// <param name="classInfo"></param> | ||
public InterfaceDeclarationSyntaxFactory(ITypeInfoProxy interfaceInfo) | ||
{ | ||
if (interfaceInfo == null) | ||
{ | ||
throw new ArgumentNullException(nameof(interfaceInfo)); | ||
} | ||
|
||
this.interfaceInfo = interfaceInfo; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the <see cref="InterfaceDeclarationSyntax"/>. | ||
/// </summary> | ||
/// <returns></returns> | ||
public SyntaxNode Create() | ||
{ | ||
var interfaceNode = SyntaxFactory.InterfaceDeclaration(this.interfaceInfo.Name); | ||
|
||
// Defining accessibility | ||
var visibility = new Visibility(this.interfaceInfo).Token; | ||
if (visibility != SyntaxKind.None) | ||
{ | ||
interfaceNode = interfaceNode.AddModifiers(SyntaxFactory.Token(visibility)); | ||
} | ||
|
||
// Extended interfaces | ||
var interfaces = this.interfaceInfo.ImplementedInterfaces; | ||
|
||
if (interfaces != null) | ||
{ | ||
foreach (var @interface in interfaces) | ||
{ | ||
interfaceNode = interfaceNode.AddBaseListTypes(SyntaxFactory.SimpleBaseType(SyntaxFactory.ParseTypeName(@interface.FullName))); | ||
} | ||
} | ||
|
||
// Methods | ||
var methods = this.interfaceInfo.DeclaredMethods; | ||
|
||
if (methods != null) | ||
{ | ||
foreach (var method in methods) | ||
{ | ||
interfaceNode = interfaceNode.AddMembers(new MethodDeclarationSyntaxFactory(method, false).Create() as MethodDeclarationSyntax); | ||
} | ||
} | ||
|
||
// Properties | ||
// TODO | ||
|
||
return interfaceNode; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.