frhagn / typewriter Goto Github PK
View Code? Open in Web Editor NEWAutomatic TypeScript template generation from C# source files
Home Page: http://frhagn.github.io/Typewriter
License: Apache License 2.0
Automatic TypeScript template generation from C# source files
Home Page: http://frhagn.github.io/Typewriter
License: Apache License 2.0
Improve error handling and log meaningful messages to the Typewriter console output
Seems like a sane type mapping:
public class Thing {
public dynamic Value { get; set; }
}
Converted to:
public class Thing {
Value: any;
}
Is there anyway to generate typescript definition with optional type? This is especially important when trying to generate typescript interfaces automatically
With TypeScript 1.6 knocking on the door (already in beta), typescript has support for React's JSX-syntax via .tsx-files.
C# IntelliSense for custom methods and inline lambda filters
In order to implement proper IntelliSense for custom methods we need to change the lambda style syntax of custom methods to a more standard c# method syntax.
So instead of
var LoudName = (Class c) => c.Name.ToUpper();
The new syntax will look like this
string LoudName(Class class)
{
return class.Name.ToUpper();
}
define Cache(IMethodInfo m)
{
return m.Attributes.Any(a => a.Name == "Cache");
}
Please add the full support for all declaration types including events and delegates.
Currently, I use TypeWriter to generate a custom websocket wrapper which is able at the javascript side to invoke methods on the server (exposed using typewriter) and to listen to events raised at the server end and invoke subscriber functions (handwriten but could be exposed by typewriter as well).
Thanks so much for a perfectly working extension.
List<List<MyClass>>
should give Array<Array<MyClass>>
when using $Type.
It gives List[]
not a valid type.
Given class like this:
public class TestClass {
public class NestedClass {
public void Method(TestClass tc, NestedClass nc) {
}
}
}
With a typescript-template like this:
$Classes[module App$IsNested[$Parent[.$Name]] {
export class $name { $Methods[
$name ($Parameters[$name: $Type])]{
}
}
}
Should return this:
module App {
export class TestClass {
}
}
module App.TestClass {
export class NestedClass {
method(tc: TestClass, nc: TestClass.NestedClass) {
}
}
}
Knockout models
Angular models
Controllers
A possible solution would be to use the name of the template to determine the file extension for the output files, e.g. Models.d.tst whould create *.d.ts output files.
Syntactical errors e.g. missing semicolons, invalid identifiers etc. in code blocks and lambda filters.
Also highlight missing closing braces.
Try to remove limitation to referenced projects, at least for roslyn-based generation.
A new property on nested classes, interfaces and enums to access the containing class
To enable advanced template scenarios the templating engine should be able to load external dll´s. eg.
${
import "..\Extensions.dll";
}
This extension stops working on the RTM version of Visual Studio 2015. it might be just my installation. Is there any log that I can check?
To enable simpler access to nested properties eg. $Type.IsGeneric[...]
all classes returns "Object" as baseClass (since all types inherits object).
should be empty if no inheritance exists.
using template $Name extends $BaseClass
public class WithoutBase { }
should return WithoutBase extends
. (now returns WithoutBase extends Object
)
public class WithBase : WithoutBase { }
should return WithBase extends WithoutBase
Thx!
I tried using the angular and model templates and some of the helpers don't seem to be working.
I'm not seeing any references to $rootnamespace$
in the code.
_.(App|Shared)._Models
Similar to the Web API extensions e.g. Url
, Route
, RequestData
and HttpMethod
If I have an array ([]
) type in my C#-code an try to access $Type.IsPrimitive
in VS 2015 i get the following exception:
System.NullReferenceException: Object reference not set to an instance of an object. at Typewriter.Metadata.Roslyn.Extensions.GetFullName(ISymbol symbol) at Typewriter.Metadata.Roslyn.Extensions.GetFullName(ISymbol symbol) at Typewriter.Metadata.Roslyn.RoslynTypeMetadata.get_FullName() at Typewriter.CodeModel.Helpers.IsPrimitive(ITypeMetadata metadata) at Typewriter.CodeModel.Implementation.TypeImpl.get_IsPrimitive() at __Typewriter.__Code.<>c.<DataParameter>b__8_0(Parameter p) at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source, Func2 predicate) at __Typewriter.__Code.DataParameter(Method m)
Any type of Array seems to reproduce this problem.
Ensure that all braces have a matching open and close brace. Throw error if they don't.
Take lambda filter types from the current context.
Similar to the Web API extensions e.g. Url
, Route
, RequestData
and HttpMethod
If you have a C# method with a parameter that starts with a @ to use a reserved word:
void ProcessEvent(SomeEvent @event) { ... }
The @ sign needs to be removed for $Name, etc...
Does Typewriter support inheritance?
public class Report {}
public class SpecificReport : Report {}
public MyGenericClass<int>
should give MyGenericClass<int>
when using $Type
public List<MyGenericClass<int>>
should give MyGenericClass<int>[]
when using $Type
public class MyGenericClass<T> { private T genericProperty }
should give T
when using $Type
for the property.
eg. "define $InnerType = $IsGeneric[$Type[$GenericTypeArguments[$Type]]][$Type]"
Hey All,
I was wondering how to debug these templates? I'm writing some custom extension methods and i'm not getting a lot of feedback on why the code is not generating.
Thanks!
public class MyController : Controller {
public MyViewModel Get() {
//...
return new MyViewModel();
}
}
$Classes(*Controller) [
$Dependencies [
$Classes [
//Generate dependencies for instance MyViewModel
]
]
]
Since methods can be generic the IsGeneric
property must be removed. In order to have a unified API the other type shortcuts (IsEnum
, IsEnumerable
, IsNullable
, IsPrimitive
) should also be removed.
Changes in the project structure in Visual Studio breaks the file nesting and metadata features required by Typewriter for vNext projects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.