mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Compiler error for AutoNetworkedField fields in a component without a AutoGenerateComponentState attribute (#4670)
* yeah * remove autonetfield --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -315,6 +315,8 @@ public partial class {componentName}
|
||||
{
|
||||
var symbols = new List<(INamedTypeSymbol, AttributeData)>();
|
||||
var attributeSymbol = comp.GetTypeByMetadataName(ClassAttributeName);
|
||||
var fieldAttr = comp.GetTypeByMetadataName(MemberAttributeName);
|
||||
|
||||
foreach (var candidateClass in receiver.CandidateClasses)
|
||||
{
|
||||
var model = comp.GetSemanticModel(candidateClass.SyntaxTree);
|
||||
@@ -325,6 +327,31 @@ public partial class {componentName}
|
||||
|
||||
if (relevantAttribute == null)
|
||||
{
|
||||
if (typeSymbol == null)
|
||||
continue;
|
||||
|
||||
foreach (var mem in typeSymbol.GetMembers())
|
||||
{
|
||||
var attribute = mem.GetAttributes().FirstOrDefault(a =>
|
||||
a.AttributeClass != null &&
|
||||
a.AttributeClass.Equals(fieldAttr, SymbolEqualityComparer.Default));
|
||||
|
||||
if (attribute == null)
|
||||
continue;
|
||||
|
||||
var msg = "Field is marked with [AutoNetworkedField], but its class has no [AutoGenerateComponentState] attribute.";
|
||||
context.ReportDiagnostic(
|
||||
Diagnostic.Create(
|
||||
new DiagnosticDescriptor(
|
||||
"RXN0007",
|
||||
msg,
|
||||
msg,
|
||||
"Usage",
|
||||
DiagnosticSeverity.Error,
|
||||
true),
|
||||
candidateClass.Keyword.GetLocation()));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user