frhagn / Typewriter

Automatic TypeScript template generation from C# source files
http://frhagn.github.io/Typewriter
Apache License 2.0
536 stars 132 forks source link

Classes from Nuget package #103

Open Kavorka79 opened 8 years ago

Kavorka79 commented 8 years ago

Hi,

First of Thanks for a awesome tool! Absolutly love it!

But I have an problem I can't resolve... I a class library as a nuget package, from a service solution, that I reference in my Asp.Net5 Client.

What I want is to template all classes in the nuget package, Already have a template thats working for the project in the same solution. But when I add the nuget reference it cant be found....

17:35:40.319 WARNING: Cannot find project named 'Backend.Queries'

How can I do this or is it not supported? If not I guess I could move the Dtos, Commands and Queries project to the client solution and make the backend consume the nuget packages.

But stil it would be nice for packages you don't have control over.

Thanks!

$Classes(c => AcceptableClass(c.Name))[   
    // Generated.
    // Do NOT edit this file manually.
    $Imports
    $Properties[$Type[$CreatePropertyImport]]

    export class $ClassName $Inheritance {
        constructor($Properties[public $name: $Type[$TypeScriptName]][,]) {
        }
    }
]
    bool AcceptableClass(string className)
    {
        if(className.EndsWith("Dto") ||
          className.EndsWith("Query") || 
          className.EndsWith("Command"))
          {
            return true;
          }
        return false;
    }
    Template(Settings settings)
    {
        settings.IncludeProject("Pixie.Backend"); //Project in the same solution
        settings.IncludeProject("Backend.Queries"); //Nuget package references in project.json
        settings.IncludeReferencedProjects();
        settings.OutputExtension = ".ts";
    }
frhagn commented 8 years ago

Hi @Kavorka79 Thanks, I'm glad you like it.

The problem is that external references is unsupported. Typewriter needs a project reference to be able to get the source metadata so you'll have to add the Backend.Queries project to the solution.

I'm looking into adding support for this scenario in a future version, but for now this is the only way to do it.

Kavorka79 commented 8 years ago

Thanks for the quick reply! Ok guess we have a decision to make then... =)

External reference support would be extremly good to have for larger projects, I know you have lots to do but I hope to see it in the future.

Thanks!

madcamp commented 7 years ago

External reference would be great! We have a Class Library with ViewModels that we use across some projects and it would be great if we could generate TypeScript for these classes.

gravidThoughts commented 7 years ago

Another vote for this feature. Please excuse my ignorance, does reflection not get you what you need?

agustinbcu01 commented 6 years ago

MEF can help. If you Generates a nuGet Package with the Document object model we can create a extensions easily and the that extension can be loaded thru MEF.

andrewbusch7 commented 6 years ago

@agustinbcu01 what is MEF?

Edit: ah I see, Managed Extensibility Framework - https://docs.microsoft.com/en-us/dotnet/framework/mef/

agustinbcu01 commented 6 years ago

Managed Extensibility Framework https://en.m.wikipedia.org/wiki/Managed_Extensibility_Framework

On Jul 15, 2018, at 9:54 PM, andrewb273 notifications@github.com wrote:

@agustinbcu01 what is MEF?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.