2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

Custom names

This commit is contained in:
2021-11-28 05:28:43 +03:00
parent a25e5a71f2
commit 1166e93ba9
11 changed files with 57 additions and 42 deletions

View File

@ -20,8 +20,6 @@ namespace Esiur.Proxy
public class ResourceGenerator : ISourceGenerator
{
private KeyList<string, TypeTemplate[]> cache = new();
// private List<string> inProgress = new();
@ -38,9 +36,7 @@ namespace Esiur.Proxy
context.ReportDiagnostic(Diagnostic.Create(new DiagnosticDescriptor("MySG001", title, msg, category, DiagnosticSeverity.Error, true), Location.None));
}
void GenerateModel(GeneratorExecutionContext context, TypeTemplate[] templates)
{
foreach (var tmp in templates)
@ -163,10 +159,16 @@ public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
code += "public AsyncReply<bool> Trigger(ResourceTrigger trigger) => new AsyncReply<bool>(true);\r\n";
}
//Debugger.Launch();
foreach (var f in ci.Fields)
{
var givenName = f.GetAttributes().Where(x=>x.AttributeClass.Name == "PublicAttribute").FirstOrDefault()?.ConstructorArguments.FirstOrDefault().Value;
var fn = f.Name;
var pn = fn.Substring(0, 1).ToUpper() + fn.Substring(1);
var pn = givenName ?? fn.Substring(0, 1).ToUpper() + fn.Substring(1);
//System.IO.File.AppendAllText("c:\\gen\\fields.txt", fn + " -> " + pn + "\r\n");
// copy attributes
var attrs = string.Join(" ", f.GetAttributes().Select(x => $"[{x.ToString()}]"));