перевод на передачу с обозначением схемы
This commit is contained in:
@@ -77,14 +77,15 @@ namespace {Namespace}
|
||||
/// </summary>
|
||||
/// <param name="context">Source generation context used to add source files.</param>
|
||||
/// <param name="compilation">Compilation used to provide access to the Semantic Model.</param>
|
||||
/// <param name="classDeclarations">Nodes annotated with the [Report] attribute that trigger the generate action.</param>
|
||||
/// <param name="classes">Nodes annotated with the [Report] attribute that trigger the generate action.</param>
|
||||
private void GenerateCode(SourceProductionContext context, Compilation compilation,
|
||||
ImmutableArray<InterfaceDeclarationSyntax> classDeclarations)
|
||||
ImmutableArray<InterfaceDeclarationSyntax> classes)
|
||||
{
|
||||
var methods = new List<(string, IMethodSymbol)>();
|
||||
var frontendContextRepo = new List<string>();
|
||||
// Go through all filtered class declarations.
|
||||
foreach (var classDeclarationSyntax in classDeclarations)
|
||||
var declarations = classes.ToList().OrderBy(i => i.Identifier.Text).ToList();
|
||||
foreach (var classDeclarationSyntax in declarations)
|
||||
{
|
||||
// We need to get semantic model of the class to retrieve metadata.
|
||||
var semanticModel = compilation.GetSemanticModel(classDeclarationSyntax.SyntaxTree);
|
||||
@@ -102,7 +103,7 @@ namespace {Namespace}
|
||||
|
||||
// Go through all class members with a particular type (property) to generate method lines.
|
||||
var methodBody = classSymbol.GetMembers()
|
||||
.OfType<IMethodSymbol>();
|
||||
.OfType<IMethodSymbol>().OrderBy(i => i.Name);
|
||||
|
||||
var originalName = className;
|
||||
// Build up the source code
|
||||
@@ -204,7 +205,7 @@ partial class {className} (int id, ISerialisationModule.IFrontendSerialisationMo
|
||||
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;
|
||||
@@ -212,10 +213,10 @@ using mROA.Abstract;
|
||||
|
||||
namespace mROA.Codegen;
|
||||
|
||||
public class CoCodegenMethodRepository :IMethodRepository
|
||||
public class CoCodegenMethodRepository : IMethodRepository
|
||||
{{
|
||||
private readonly List<MethodInfo> _methods = [
|
||||
{string.Join(", \r\n\t\t", methodsStringed)}
|
||||
{string.Join(", // test comment\r\n\t\t", methodsStringed)}
|
||||
];
|
||||
public MethodInfo GetMethod(int id)
|
||||
{{
|
||||
@@ -310,6 +311,5 @@ public class FrontendContextRepository : IContextRepository
|
||||
";
|
||||
context.AddSource("FrontendContextRepository.g.cs", SourceText.From(fronendRepoCode, Encoding.UTF8));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user