Category: skinny
-
AutoActions for Skinny controllers–custom template
Now I want to let the user make his own template. For this,I have enriched the attribute AutoActionsAttribute with a public string CustomTemplateFileName { get; set; } The code was pretty easy,just reading from GeneratorExecutionContext . AdditionalFiles instead of reading from the template in the dll There are 2 small catches 1…
-
AutoActions for Skinny controllers–code improvements and more docs
I realized that this code Assembly.GetExecutingAssembly(); was executing for each controller. So I decided to move to a class variable and attribute once. Also,I may want to have all fields – so I decided to express via a special field * The code modifications were,thanks to Linq,pretty small: bool All = fields.Contains(“*”); var memberFields =…
-
AutoActions for Skinny controllers-documentation improvements
One improvement is to move Initialize in other partial class. . It was difficult every time I need to activate the debugger public void Initialize(GeneratorInitializationContext context) { context.RegisterForSyntaxNotifications(() => new SyntaxReceiverFields()); //in development //Debugger.Launch(); } Second was to improve the Nuget package description. I have added <Version>2020.11.28.2108</Version> <Authors>Andrei Ignat</Authors> <PackageTags>RoslynCodeGenerators C# CSharp SkinnyControllers</PackageTags> <PackageProjectUrl>https://github.com/ignatandrei/AOP_With_Roslyn</PackageProjectUrl> …
-
AutoActions for Skinny controllers–second template
The second template was pretty easy. All the date was inside the class definition : class ClassDefinition { public string ClassName; public string NamespaceName; public Dictionary<string,MethodDefinition[]> DictNameField_Methods; public string version = ThisAssembly.Info.Version; } class MethodDefinition { public string Name { get; set; } public string FieldName { get; set; } public string ReturnType; public…
-
AutoActions for Skinny controllers- templating-part2
Now I want to add templates to my controller generators . But this feature changed the whole perspective about the project. Why ? Because a template do not apply just to a field – but to the whole controller. So instead of having attributes on the field [AutoActions] private readonly RepositoryWF repository; I will have…
-
AutoActions for Skinny controllers–user customization
The generation of controllers actions is now very rude: Http Method: if the method has no arguments,I assume GET . Else it is POST How I can handle pure full REST API generation ? How I can handle level 3 REST API – https://martinfowler.com/articles/richardsonMaturityModel.html ? How I can handle any other models,like https://blog.ploeh.dk/2020/10/26/fit-urls/ What is…
-
AutoActions for Skinny controllers-Templating-part1
In order to do templating,I have transform all text generation into classes Example: code.AppendLine($”{fieldName}.{ms.Name}({parametersCall});”); into class MethodDefinition { public string ClassName { get; set; } public string Name { get; set; } public Type ReturnType; public bool ReturnsVoid; //name,type public Dictionary<string,string> Parameters; } ( of course,this definition has changed multiple times…) Then I have added…
-
AutoActions for Skinny controllers–small customizations
Logging Roslyn Code Generator: For each program that you develop,it is important ( if not vital ) to see logging. In the Roslyn Analyzer / Code Generators,the diagnostics are logged with DiagnosticDescriptor and Diagnostic – think that you should see in the output console when compiling and this will become clear. More,the enum DiagnosticSeverity Enum…
-
AutoActions for Skinny controllers–deploying at NuGet
First time I was thinking that is enough to do dotnet pack to make a Nuget package to deploy on NUGET. It was not. I realized that the generator was not starting at all! And it was not in the project Dependencies=>Analyzers . Time to read more from https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.cookbook.md,I realized that I was wrong –…
-
AutoActions for Skinny controllers–first implementation
Now with the implementation. First,I find all the fields declarations that had the Autonotify if (syntaxNode is FieldDeclarationSyntax fieldDeclarationSyntax && fieldDeclarationSyntax.AttributeLists.Count > 0) { foreach(var al in fieldDeclarationSyntax.AttributeLists) { var att = al.Attributes; foreach(var at in att) { var x = at.Name as IdentifierNameSyntax; if(autoActions.Contains(x.Identifier.Text)) { CandidateFields.Add(fieldDeclarationSyntax); return; } } } } Second,I must…