Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforced order in aspects generator #4342

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private static IReadOnlyList<string> GetAspectSources(Compilation compilation, I

var results = new List<string>();

List<(string, INamedTypeSymbol)> classSymbols = new List<(string, INamedTypeSymbol)>();

foreach (ClassDeclarationSyntax classDec in classes)
{
// stop if we're asked to
Expand All @@ -123,11 +125,15 @@ private static IReadOnlyList<string> GetAspectSources(Compilation compilation, I
if (instance != null)
{
string className = GetFullName(classSymbol);
results.Add(instance.ToString() + " " + className);
classSymbols.Add((instance.ToString() + " " + className, classSymbol));
}
}
}

foreach (var member in classSymbol.GetMembers())
foreach (var classSymbol in classSymbols.OrderBy(c => c.Item1))
{
var methods = new List<string>();
foreach (var member in classSymbol.Item2.GetMembers().OrderBy(m => m.MetadataName))
{
var memberAttributes = member.GetAttributes();
foreach (var memberAttribute in memberAttributes)
Expand All @@ -136,10 +142,14 @@ private static IReadOnlyList<string> GetAspectSources(Compilation compilation, I
if (attribute != null)
{
string functionName = GetFullName(member);
results.Add(" " + attribute.ToString() + " " + functionName);
methods.Add(" " + attribute.ToString() + " " + functionName);
}
}
}

results.Add(classSymbol.Item1);
methods.Sort();
results.AddRange(methods);
}

return results;
Expand Down
Loading