баг решен

This commit is contained in:
2025-02-15 09:06:29 +03:00
parent 40249c3901
commit 4f0304cb43
5 changed files with 41 additions and 24 deletions
+18 -16
View File
@@ -56,17 +56,17 @@ namespace {Namespace}
// 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
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();
string attributeName = attributeSymbol.ContainingType.ToDisplayString();
// Check the full name of the [Report] attribute.
if (attributeName == "mROA.Implementation.Attributes.SharedObjectInterfaceAttribute")
return (classDeclarationSyntax, true);
}
// Check the full name of the [Report] attribute.
if (attributeName == "mROA.Implementation.Attributes.SharedObjectInterfaceAttribute")
return (classDeclarationSyntax, true);
}
return (classDeclarationSyntax, false);
}
@@ -141,8 +141,7 @@ namespace {Namespace}
sb.AppendLine(
$"\t\tvar defaultCallRequestCodegen = new DefaultCallRequest {{ CommandId = {index}, ObjectId = id }};");
}
sb.AppendLine("\t\tSystem.Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(defaultCallRequestCodegen));");
//Post created request
sb.AppendLine("\t\tserialisationModule.PostCallRequest(defaultCallRequestCodegen);");
@@ -154,7 +153,6 @@ namespace {Namespace}
}
else 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);
@@ -169,6 +167,11 @@ namespace {Namespace}
$"\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}");
@@ -198,16 +201,16 @@ partial class {className} (int id, ISerialisationModule.IFrontendSerialisationMo
// Add the source code to the compilation.
context.AddSource($"{className}.g.cs", SourceText.From(code, Encoding.UTF8));
frontendContextRepo.Add($"{{ typeof({classSymbol.ToDisplayString()}), typeof({namespaceName}.{className}) }}");
frontendContextRepo.Add(
$"{{ typeof({classSymbol.ToDisplayString()}), typeof({namespaceName}.{className}) }}");
}
if (methods.Count != 0)
{
var methodsStringed = methods.Select(i =>
$"typeof({i.Item1}).GetMethod(\"{i.Item2.Name}\", [{string.Join(", ", i.Item2.Parameters.Select(p => $"typeof({p.Type.ToDisplayString()})"))}])")
.ToList();
var coCodegenRepoCode = @$"// <auto-generated/>
using System.Collections.Generic;
using System.Reflection;
@@ -249,7 +252,6 @@ public class CoCodegenMethodRepository : IMethodRepository
if (frontendContextRepo.Count != 0)
{
var fronendRepoCode = @$"// <auto-generated/>
using System.Collections.Frozen;
using mROA.Implementation;