mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +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;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Robust.Shared.GameObjects
|
||||
public abstract partial class SharedPointLightComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("color"), AutoNetworkedField]
|
||||
[DataField("color")]
|
||||
[Animatable]
|
||||
public Color Color { get; set; } = Color.White;
|
||||
|
||||
@@ -26,17 +26,17 @@ namespace Robust.Shared.GameObjects
|
||||
public Vector2 Offset = Vector2.Zero;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("energy"), AutoNetworkedField]
|
||||
[DataField("energy")]
|
||||
[Animatable]
|
||||
public float Energy { get; set; } = 1f;
|
||||
|
||||
[DataField("softness"), AutoNetworkedField, Animatable]
|
||||
[DataField("softness"), Animatable]
|
||||
public float Softness { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this pointlight should cast shadows
|
||||
/// </summary>
|
||||
[DataField("castShadows"), AutoNetworkedField]
|
||||
[DataField("castShadows")]
|
||||
public bool CastShadows = true;
|
||||
|
||||
[Access(typeof(SharedPointLightSystem))]
|
||||
|
||||
Reference in New Issue
Block a user