mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Source gen reorganizations + component unpause generator. (#4896)
* Source gen reorganizations + component unpause generator. This commit (and subsequent commits) aims to clean up our Roslyn plugin (source gens + analyzers) stack to more sanely re-use common code I also built a new source-gen that automatically generates unpausing implementations for components, incrementing attributed TimeSpan field when unpaused. * Fix warnings in all Roslyn projects
This commit is contained in:
committed by
GitHub
parent
ef0bc1a2e4
commit
ae6cebbfbb
@@ -32,7 +32,7 @@ namespace Robust.Shared.CompNetworkGenerator
|
||||
private const string GlobalHashSetName = "global::System.Collections.Generic.HashSet<T>";
|
||||
private const string GlobalListName = "global::System.Collections.Generic.List<T>";
|
||||
|
||||
private static string GenerateSource(in GeneratorExecutionContext context, INamedTypeSymbol classSymbol, CSharpCompilation comp, bool raiseAfterAutoHandle)
|
||||
private static string? GenerateSource(in GeneratorExecutionContext context, INamedTypeSymbol classSymbol, CSharpCompilation comp, bool raiseAfterAutoHandle)
|
||||
{
|
||||
var nameSpace = classSymbol.ContainingNamespace.ToDisplayString();
|
||||
var componentName = classSymbol.Name;
|
||||
@@ -280,10 +280,10 @@ public partial class {componentName}
|
||||
{
|
||||
var attr = type.Attribute;
|
||||
var raiseEv = false;
|
||||
if (attr.ConstructorArguments.Length == 1 && attr.ConstructorArguments[0].Value != null)
|
||||
if (attr.ConstructorArguments is [{Value: bool raise}])
|
||||
{
|
||||
// Get the afterautohandle bool, which is first constructor arg
|
||||
raiseEv = (bool) attr.ConstructorArguments[0].Value;
|
||||
raiseEv = raise;
|
||||
}
|
||||
|
||||
var source = GenerateSource(context, type.Type, comp, raiseEv);
|
||||
@@ -325,11 +325,11 @@ public partial class {componentName}
|
||||
attr.AttributeClass != null &&
|
||||
attr.AttributeClass.Equals(attributeSymbol, SymbolEqualityComparer.Default));
|
||||
|
||||
if (typeSymbol == null)
|
||||
continue;
|
||||
|
||||
if (relevantAttribute == null)
|
||||
{
|
||||
if (typeSymbol == null)
|
||||
continue;
|
||||
|
||||
foreach (var mem in typeSymbol.GetMembers())
|
||||
{
|
||||
var attribute = mem.GetAttributes().FirstOrDefault(a =>
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>9</LangVersion>
|
||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||
</PropertyGroup>
|
||||
<Import Project="../Robust.Roslyn.Shared/Robust.Roslyn.Shared.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user