Пока что удаление IDataList из демки

This commit is contained in:
2025-03-01 15:11:11 +03:00
parent 906bda7000
commit 3c88e4f768
4 changed files with 21 additions and 71 deletions
+12
View File
@@ -0,0 +1,12 @@
using mROA.Implementation.Attributes;
namespace Example.Shared
{
// [SharedObjectInterface]
// public interface IDataList<T>
// {
// T Get(int index);
// void Add(T item);
// void Set(int index, T item);
// }
}
+6 -68
View File
@@ -30,48 +30,6 @@ namespace {Namespace}
}} }}
}}"; }}";
// public void Initialize(IncrementalGeneratorInitializationContext context)
// {
// // Filter classes annotated with the [Report] attribute. Only filtered Syntax Nodes can trigger code generation.
// var provider = context.SyntaxProvider
// .CreateSyntaxProvider(
// (s, _) => s is InterfaceDeclarationSyntax,
// (ctx, _) => GetClassDeclarationForSourceGen(ctx))
// .Where(t => t.reportAttributeFound)
// .Select((t, _) => t.Item1);
//
// // Generate the source code.
// context.RegisterSourceOutput(context.CompilationProvider.Combine(provider.Collect()),
// ((ctx, t) => GenerateCode(ctx, t.Left, t.Right)));
// }
/// <summary>
/// Checks whether the Node is annotated with the [Report] attribute and maps syntax context to the specific node type (ClassDeclarationSyntax).
/// </summary>
/// <param name="context">Syntax context, based on CreateSyntaxProvider predicate</param>
/// <returns>The specific cast and whether the attribute was found.</returns>
// private static (InterfaceDeclarationSyntax, bool reportAttributeFound) GetClassDeclarationForSourceGen(
// GeneratorSyntaxContext context)
// {
// var classDeclarationSyntax = (InterfaceDeclarationSyntax)context.Node;
//
// // Go through all attributes of the class.
// foreach (AttributeListSyntax attributeListSyntax in classDeclarationSyntax.AttributeLists)
// foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes)
// {
// if (context.SemanticModel.GetSymbolInfo(attributeSyntax).Symbol is not IMethodSymbol attributeSymbol)
// continue; // if we can't get the symbol, ignore it
//
// string attributeName = attributeSymbol.ContainingType.ToDisplayString();
//
// // Check the full name of the [Report] attribute.
// if (attributeName == "mROA.Implementation.Attributes.SharedObjectInterfaceAttribute")
// return (classDeclarationSyntax, true);
// }
//
// return (classDeclarationSyntax, false);
// }
/// <summary> /// <summary>
/// Generate code action. /// Generate code action.
/// It will be executed on specific nodes (ClassDeclarationSyntax annotated with the [Report] attribute) changed by the user. /// It will be executed on specific nodes (ClassDeclarationSyntax annotated with the [Report] attribute) changed by the user.
@@ -99,6 +57,8 @@ namespace {Namespace}
var namespaceName = classSymbol.ContainingNamespace.ToDisplayString(); var namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
// 'Identifier' means the token of the node. Get class name from the syntax node. // 'Identifier' means the token of the node. Get class name from the syntax node.
var className = classDeclarationSyntax.Identifier.Text; var className = classDeclarationSyntax.Identifier.Text;
@@ -119,7 +79,6 @@ namespace {Namespace}
methods.Add((namespaceName + "." + originalName, method)); methods.Add((namespaceName + "." + originalName, method));
var sb = new StringBuilder(); var sb = new StringBuilder();
bool isAsync = method.ReturnType.Name == "Task"; bool isAsync = method.ReturnType.Name == "Task";
bool isVoid = method.ReturnType.Name == "Void" || bool isVoid = method.ReturnType.Name == "Void" ||
method.ReturnType.ToString() == "System.Threading.Tasks.Task"; method.ReturnType.ToString() == "System.Threading.Tasks.Task";
@@ -151,30 +110,6 @@ namespace {Namespace}
if (!isVoid) if (!isVoid)
prefix = "return " + prefix; prefix = "return " + prefix;
// if (method.ReturnType.OriginalDefinition.ToString() == "System.Threading.Tasks.Task<TResult>")
// {
// var type = method.ReturnType.ToString();
// type = type.Substring(type.IndexOf('<') + 1);
// type = type.Substring(0, type.Length - 1);
// sb.AppendLine(
// $"\t\tvar response = await serialisationModule.GetFinalCommandExecution<{type}>(defaultCallRequestCodegen.CallRequestId);");
// sb.AppendLine($"\t\treturn ({type})response.Result;");
// }
// else if (!isAsync && method.ReturnType.ToDisplayString() != "void")
// {
// var type = method.ReturnType.ToDisplayString();
// sb.AppendLine(
// $"\t\tvar response = serialisationModule.GetFinalCommandExecution<{type}>(defaultCallRequestCodegen.CallRequestId).GetAwaiter().GetResult();");
// sb.AppendLine($"\t\treturn ({type})response.Result;");
// }
// else
// {
// sb.AppendLine(
// "\t\tserialisationModule.GetNextCommandExecution<FinalCommandExecution>(defaultCallRequestCodegen.CallRequestId).Wait();");
// }
//
// sb.AppendLine("\t}");
sb.AppendLine("\t\t\t" + prefix + caller + postfix + ";"); sb.AppendLine("\t\t\t" + prefix + caller + postfix + ";");
sb.AppendLine("\t\t}"); sb.AppendLine("\t\t}");
@@ -213,8 +148,11 @@ namespace {namespaceName}
if (methods.Count != 0) if (methods.Count != 0)
{ {
// var methodsStringed = methods.Select(i =>
// $"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\", new Type[] {{{string.Join(", ", i.Item2.Parameters.Select(p => $"typeof({p.Type.ToDisplayString()})"))}}})")
// .ToList();
var methodsStringed = methods.Select(i => var methodsStringed = methods.Select(i =>
$"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\", new Type[] {{{string.Join(", ", i.Item2.Parameters.Select(p => $"typeof({p.Type.ToDisplayString()})"))}}})") $"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\")")
.ToList(); .ToList();
var coCodegenRepoCode = @$"// <auto-generated/> var coCodegenRepoCode = @$"// <auto-generated/>
@@ -148,7 +148,7 @@ namespace mROA.Implementation.Backend
{ {
Id = command.Id Id = command.Id
}; };
_cancellationRepo.FreeCancelation(command.Id); _cancellationRepo?.FreeCancelation(command.Id);
var multiClientOwnershipRepository = var multiClientOwnershipRepository =
TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository;
+1 -1
View File
@@ -12,7 +12,7 @@ namespace mROA.Implementation
public static class TransmissionConfig public static class TransmissionConfig
{ {
#if TRACE #if TRACE
public static int TotalTransmittedBytes { get; set; } = 0; public static int TotalTransmittedBytes { get; set; }
#endif #endif
private static IContextRepository? _realContextRepository; private static IContextRepository? _realContextRepository;
private static IContextRepository? _remoteEndpointContextRepository; private static IContextRepository? _remoteEndpointContextRepository;