AdaskoTheBeAsT / Typewriter

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

How to get current class in base Method #320 #25

Open luizfbicalho opened 1 year ago

luizfbicalho commented 1 year ago

copied from https://github.com/frhagn/Typewriter/issues/320

I have this method im my angular service tst

 IEnumerable<Method> BaseClassMethods(Class clas) 
{ 
return clas.BaseClass.Methods;
 }

Because my controller has a base controller that is generic, a crud controller. How can I get in my base method, the current class to replace the method return type from generic to specific?

AdaskoTheBeAsT commented 7 months ago

did you try to use ProduceResponsesType attribute

https://github.com/AdaskoTheBeAsT/NetCoreTypewriterRecipes/blob/master/src/AngularWebApiSample2/Controllers/ComplexController.cs

https://github.com/AdaskoTheBeAsT/NetCoreTypewriterRecipes/blob/master/src/AngularWebApiSample2/ClientApp/apps/client-app/src/api/services/_AutogeneratedServices.tst

luizfbicalho commented 6 months ago

I think that this is very incomplete

Let me explain better

I havea Generic CrudController class

and in this method

IEnumerable<Method> BaseClassMethods(Class clas) 
{ 
return clas.BaseClass.Methods;
 }

I would lik to get back the current class

So in the template I would have

$BaseClassMethods[

]

and I would like to have a way to get the current class back, my last try is something like that

IEnumerable<(Class,Method)> BaseClassMethods(Class clas) 
{ 
return clas.BaseClass.Methods;
 }

And then each access in the template would expect a tuple and not a method, would that work?

AdaskoTheBeAsT commented 6 months ago

not possible to do this in such way - iteration is not possible on tuples

luizfbicalho commented 6 months ago

Any option or I would need one class and 2 methods?

AdaskoTheBeAsT commented 6 months ago

do small reproductible sample and I will take a look