Skip to content

Roslyn #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
2,350 changes: 2,067 additions & 283 deletions .editorconfig

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/LazyCoder/BaseCoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected virtual TsInterface Rewrite(CsStruct csStruct)
};
}

protected virtual TsTypeMember? Rewrite(CsTypeMember csTypeMember)
protected virtual TsTypeMember? Rewrite(CsMember csTypeMember)
{
switch (csTypeMember)
{
Expand Down
22 changes: 12 additions & 10 deletions src/LazyCoder/CSharp/CsAccessModifier.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace LazyCoder.CSharp
{
public enum CsAccessModifier
{
Public,
Private,
Protected,
Internal
}
}
namespace LazyCoder.CSharp
{
public enum CsAccessModifier
{
Public,
Private,
Protected,
Internal,
ProtectedAndInternal,
ProtectedOrInternal
}
}
2 changes: 2 additions & 0 deletions src/LazyCoder/CSharp/CsAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using Microsoft.CodeAnalysis;

namespace LazyCoder.CSharp
{
public class CsAttribute
{
public string Name { get; set; }
public Type OriginalType { get; set; }
public ITypeSymbol TypeSymbol { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/LazyCoder/CSharp/CsBaseTypeDeclaration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using Microsoft.CodeAnalysis;

namespace LazyCoder.CSharp
{
public abstract class CsBaseTypeDeclaration: CsDeclaration
{
protected CsBaseTypeDeclaration(Type type): base(type)
{
}

protected CsBaseTypeDeclaration(ITypeSymbol type): base(type)
{
}
}
}
32 changes: 17 additions & 15 deletions src/LazyCoder/CSharp/CsClass.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;

namespace LazyCoder.CSharp
{
public class CsClass: CsDeclaration
{
public CsClass(Type type): base(type)
{
}

public CsTypeMember[] Members { get; set; } = Array.Empty<CsTypeMember>();
public string[] TypeParameters { get; set; } = Array.Empty<string>();
}
}
using System;
using Microsoft.CodeAnalysis;

namespace LazyCoder.CSharp
{
public class CsClass: CsTypeDeclaration
{
public CsClass(Type type): base(type)
{
}

public CsClass(ITypeSymbol typeSymbol)
: base(typeSymbol)
{
}
}
}
17 changes: 16 additions & 1 deletion src/LazyCoder/CSharp/CsDeclaration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Microsoft.CodeAnalysis;

namespace LazyCoder.CSharp
{
Expand All @@ -19,9 +20,23 @@ protected CsDeclaration(Type type)
.ToArray();
}

protected CsDeclaration(ITypeSymbol type)
{
Name = type.Name;
Namespace = type.ContainingNamespace.Name;
CsType = new CsType(type);
Attributes = type.GetAttributes()
.Select(x => new CsAttribute
{
Name = x.AttributeClass.Name,
TypeSymbol = x.AttributeClass
})
.ToArray();
}

public string Name { get; }
public string Namespace { get; }
public CsAttribute[] Attributes { get; } = Array.Empty<CsAttribute>();
public CsType CsType { get; }
}
}
}
31 changes: 18 additions & 13 deletions src/LazyCoder/CSharp/CsEnum.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;

namespace LazyCoder.CSharp
{
public class CsEnum: CsDeclaration
{
public CsEnum(Type type): base(type)
{
}

public CsEnumValue[] Values { get; set; } = Array.Empty<CsEnumValue>();
}
}
using System;
using Microsoft.CodeAnalysis;

namespace LazyCoder.CSharp
{
public class CsEnum: CsBaseTypeDeclaration
{
public CsEnum(Type type): base(type)
{
}

public CsEnum(ITypeSymbol typeSymbol): base(typeSymbol)
{
}

public CsEnumValue[] Values { get; set; } = Array.Empty<CsEnumValue>();
}
}
2 changes: 1 addition & 1 deletion src/LazyCoder/CSharp/CsField.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LazyCoder.CSharp
{
public class CsField: CsTypeMember
public class CsField: CsMember
{
public CsType Type { get; set; }
public CsLiteral? Value { get; set; }
Expand Down
8 changes: 2 additions & 6 deletions src/LazyCoder/CSharp/CsInterface.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;

namespace LazyCoder.CSharp
{
public class CsInterface: CsDeclaration
public class CsInterface: CsTypeDeclaration
{
public CsInterface(Type type): base(type)
{
}

public CsTypeMember[] Members { get; set; } = Array.Empty<CsTypeMember>();
public string[] TypeParameters { get; set; } = Array.Empty<string>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace LazyCoder.CSharp
{
public abstract class CsTypeMember
public abstract class CsMember
{
public string Name { get; set; }
public bool IsStatic { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/LazyCoder/CSharp/CsMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace LazyCoder.CSharp
{
public class CsMethod: CsTypeMember
public class CsMethod: CsMember
{
public CsType ReturnType { get; set; }
public CsMethodParameter[] Parameters { get; set; } = Array.Empty<CsMethodParameter>();
Expand Down
2 changes: 1 addition & 1 deletion src/LazyCoder/CSharp/CsProperty.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace LazyCoder.CSharp
{
public class CsProperty: CsTypeMember
public class CsProperty: CsMember
{
public CsType Type { get; set; }
}
Expand Down
7 changes: 2 additions & 5 deletions src/LazyCoder/CSharp/CsStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace LazyCoder.CSharp
{
public class CsStruct: CsDeclaration
public class CsStruct: CsTypeDeclaration
{
public CsStruct(Type type): base(type)
{
}

public CsTypeMember[] Members { get; set; } = Array.Empty<CsTypeMember>();
public string[] TypeParameters { get; set; } = Array.Empty<string>();
}
}
}
Loading