2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00
This commit is contained in:
2024-11-09 01:46:00 +03:00
parent 2006c47013
commit 2dc373770c
30 changed files with 155 additions and 114 deletions

View File

@ -18,6 +18,7 @@ using Esiur.Core;
namespace Esiur.Proxy;
[Generator]
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1036:Specify analyzer banned API enforcement setting", Justification = "<Pending>")]
public class ResourceGenerator : ISourceGenerator
{
@ -182,7 +183,10 @@ public class ResourceGenerator : ISourceGenerator
{
var code = @$"using Esiur.Resource;
using Esiur.Core;
using Esiur.Core;
#nullable enable
namespace {ci.ClassSymbol.ContainingNamespace.ToDisplayString()} {{
";
@ -192,8 +196,8 @@ namespace {ci.ClassSymbol.ContainingNamespace.ToDisplayString()} {{
{
code +=
@$" public partial class {ci.Name} : IResource {{
public virtual Instance Instance {{ get; set; }}
public virtual event DestroyedEvent OnDestroy;
public virtual Instance? Instance {{ get; set; }}
public virtual event DestroyedEvent? OnDestroy;
public virtual void Destroy() {{ OnDestroy?.Invoke(this); }}
";

View File

@ -270,6 +270,8 @@ public static class TemplateGenerator
var rt = new StringBuilder();
rt.AppendLine("using System;\r\nusing Esiur.Resource;\r\nusing Esiur.Core;\r\nusing Esiur.Data;\r\nusing Esiur.Net.IIP;");
rt.AppendLine("#nullable enable");
rt.AppendLine($"namespace {nameSpace} {{");
if (template.Annotation != null)