Skip to content

Commit

Permalink
Refactor serialization copying to use source generators (#19412)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSmugleaf authored Aug 23, 2023
1 parent 08b4399 commit a88e747
Show file tree
Hide file tree
Showing 1,737 changed files with 2,532 additions and 2,521 deletions.
4 changes: 2 additions & 2 deletions Content.Benchmarks/EntityManagerGetAllComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Content.Benchmarks
{
[Virtual]
public class EntityManagerGetAllComponents
public partial class EntityManagerGetAllComponents
{
private IEntityManager _entityManager;

Expand Down Expand Up @@ -87,7 +87,7 @@ public int Noop()
return count;
}

private sealed class DummyComponent : Component
private sealed partial class DummyComponent : Component
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Content.Client.Administration.Components;

[RegisterComponent, NetworkedComponent]
public sealed class HeadstandComponent : SharedHeadstandComponent
public sealed partial class HeadstandComponent : SharedHeadstandComponent
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
namespace Content.Client.Administration.Components;

[NetworkedComponent, RegisterComponent]
public sealed class KillSignComponent : SharedKillSignComponent
public sealed partial class KillSignComponent : SharedKillSignComponent
{ }
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Components/FireVisualsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Content.Client.Atmos.Components;
/// accumulated.
/// </summary>
[RegisterComponent]
public sealed class FireVisualsComponent : Component
public sealed partial class FireVisualsComponent : Component
{
[DataField("fireStackAlternateState")]
public int FireStackAlternateState = 3;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Atmos/Components/MapAtmosphereComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Content.Client.Atmos.Components;

[RegisterComponent]
public sealed class MapAtmosphereComponent : SharedMapAtmosphereComponent
public sealed partial class MapAtmosphereComponent : SharedMapAtmosphereComponent
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
namespace Content.Client.Atmos.Components;

[RegisterComponent]
public sealed class PipeColorVisualsComponent : Component
public sealed partial class PipeColorVisualsComponent : Component
{
}
10 changes: 5 additions & 5 deletions Content.Client/Atmos/Monitor/AtmosAlarmableVisualsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
namespace Content.Client.Atmos.Monitor;

[RegisterComponent]
public sealed class AtmosAlarmableVisualsComponent : Component
public sealed partial class AtmosAlarmableVisualsComponent : Component
{
[DataField("layerMap")]
public string LayerMap { get; } = string.Empty;
public string LayerMap { get; private set; } = string.Empty;

[DataField("alarmStates")]
public readonly Dictionary<AtmosAlarmType, string> AlarmStates = new();
public Dictionary<AtmosAlarmType, string> AlarmStates = new();

[DataField("hideOnDepowered")]
public readonly List<string>? HideOnDepowered;
public List<string>? HideOnDepowered;

// eh...
[DataField("setOnDepowered")]
public readonly Dictionary<string, string>? SetOnDepowered;
public Dictionary<string, string>? SetOnDepowered;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Content.Client.Atmos.Visualizers;
/// the ready / full pair controls the color of the light.
/// </summary>
[RegisterComponent]
public sealed class PortableScrubberVisualsComponent : Component
public sealed partial class PortableScrubberVisualsComponent : Component
{
[DataField("idleState", required: true)]
public string IdleState = default!;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Audio/AmbientSoundTreeComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Content.Client.Audio;
/// Samples nearby <see cref="AmbientSoundComponent"/> and plays audio.
/// </summary>
[RegisterComponent]
public sealed class AmbientSoundTreeComponent : Component, IComponentTreeComponent<AmbientSoundComponent>
public sealed partial class AmbientSoundTreeComponent : Component, IComponentTreeComponent<AmbientSoundComponent>
{
public DynamicTree<ComponentTreeEntry<AmbientSoundComponent>> Tree { get; set; } = default!;
}
2 changes: 1 addition & 1 deletion Content.Client/Beam/Components/BeamComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Content.Client.Beam.Components;
[RegisterComponent]
public sealed class BeamComponent : SharedBeamComponent
public sealed partial class BeamComponent : SharedBeamComponent
{

}
2 changes: 1 addition & 1 deletion Content.Client/Bed/Components/StasisBedVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Content.Client.Bed;

[RegisterComponent]
public sealed class StasisBedVisualsComponent : Component
public sealed partial class StasisBedVisualsComponent : Component
{}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Content.Client.Botany.Components;

[RegisterComponent]
public sealed class PlantHolderVisualsComponent : Component
public sealed partial class PlantHolderVisualsComponent : Component
{
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Content.Client.Botany.Components;

[RegisterComponent]
public sealed class PotencyVisualsComponent : Component
public sealed partial class PotencyVisualsComponent : Component
{
[DataField("minimumScale")]
public float MinimumScale = 1f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed class CrewManifestUi : UIFragment
public sealed partial class CrewManifestUi : UIFragment
{
private CrewManifestUiFragment? _fragment;

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/CartridgeLoader/Cartridges/NetProbeUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed class NetProbeUi : UIFragment
public sealed partial class NetProbeUi : UIFragment
{
private NetProbeUiFragment? _fragment;

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed class NewsReadUi : UIFragment
public sealed partial class NewsReadUi : UIFragment
{
private NewsReadUiFragment? _fragment;

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/CartridgeLoader/Cartridges/NotekeeperUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed class NotekeeperUi : UIFragment
public sealed partial class NotekeeperUi : UIFragment
{
private NotekeeperUiFragment? _fragment;

Expand Down
10 changes: 5 additions & 5 deletions Content.Client/Changelog/ChangelogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Content.Client.Changelog
{
public sealed class ChangelogManager
public sealed partial class ChangelogManager
{
[Dependency] private readonly IResourceManager _resource = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
Expand Down Expand Up @@ -86,20 +86,20 @@ public Task<List<ChangelogEntry>> LoadChangelog()
}

[DataDefinition]
public sealed class ChangelogEntry : ISerializationHooks
public sealed partial class ChangelogEntry : ISerializationHooks
{
[DataField("id")]
public int Id { get; private set; }

[DataField("author")]
public string Author { get; } = "";
public string Author { get; private set; } = "";

[DataField("time")] private string _time = default!;

public DateTime Time { get; private set; }

[DataField("changes")]
public List<ChangelogChange> Changes { get; } = default!;
public List<ChangelogChange> Changes { get; private set; } = default!;

void ISerializationHooks.AfterDeserialization()
{
Expand All @@ -108,7 +108,7 @@ void ISerializationHooks.AfterDeserialization()
}

[DataDefinition]
public sealed class ChangelogChange : ISerializationHooks
public sealed partial class ChangelogChange : ISerializationHooks
{
[DataField("type")]
public ChangelogLineType Type { get; private set; }
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Chemistry/Components/HyposprayComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Content.Client.Chemistry.Components
{
[RegisterComponent]
public sealed class HyposprayComponent : SharedHyposprayComponent
public sealed partial class HyposprayComponent : SharedHyposprayComponent
{
[ViewVariables]
public FixedPoint2 CurrentVolume;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Chemistry/Components/InjectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Content.Client.Chemistry.Components
/// Client behavior for injectors & syringes. Used for item status on injectors
/// </summary>
[RegisterComponent]
public sealed class InjectorComponent : SharedInjectorComponent
public sealed partial class InjectorComponent : SharedInjectorComponent
{
[ViewVariables]
public FixedPoint2 CurrentVolume;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Content.Client.Chemistry.Visualizers;
/// </summary>
[RegisterComponent]
[Access(typeof(FoamVisualizerSystem))]
public sealed class FoamVisualsComponent : Component
public sealed partial class FoamVisualsComponent : Component
{
/// <summary>
/// The id of the animation used when the foam dissolves.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ namespace Content.Client.Chemistry.Visualizers;
/// </summary>
[RegisterComponent]
[Access(typeof(SmokeVisualizerSystem))]
public sealed class SmokeVisualsComponent : Component {}
public sealed partial class SmokeVisualsComponent : Component {}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Content.Client.Chemistry.Visualizers
{
[RegisterComponent]
public sealed class SolutionContainerVisualsComponent : Component
public sealed partial class SolutionContainerVisualsComponent : Component
{
[DataField("maxFillLevels")]
public int MaxFillLevels = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Content.Client.Chemistry.Visualizers;
/// </summary>
[RegisterComponent]
[Access(typeof(VaporVisualizerSystem))]
public sealed class VaporVisualsComponent : Component
public sealed partial class VaporVisualsComponent : Component
{
/// <summary>
/// The id of the animation played when the vapor spawns in.
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Content.Client.Clickable
{
[RegisterComponent]
public sealed class ClickableComponent : Component
public sealed partial class ClickableComponent : Component
{
[Dependency] private readonly IClickMapManager _clickMapManager = default!;

Expand Down Expand Up @@ -131,7 +131,7 @@ public bool CheckDirBound(SpriteComponent sprite, Angle relativeRotation, Vector
}

[DataDefinition]
public sealed class DirBoundData
public sealed partial class DirBoundData
{
[DataField("all")] public Box2 All;
[DataField("north")] public Box2 North;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Construction/ConstructionGhostComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Content.Client.Construction
{
[RegisterComponent]
public sealed class ConstructionGhostComponent : Component
public sealed partial class ConstructionGhostComponent : Component
{
[ViewVariables] public ConstructionPrototype? Prototype { get; set; }
[ViewVariables] public int GhostId { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Crayon/CrayonComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Content.Client.Crayon
{
[RegisterComponent]
public sealed class CrayonComponent : SharedCrayonComponent
public sealed partial class CrayonComponent : SharedCrayonComponent
{
[ViewVariables(VVAccess.ReadWrite)] public bool UIUpdateNeeded;
[ViewVariables] public int Charges { get; set; }
Expand Down
18 changes: 9 additions & 9 deletions Content.Client/Damage/DamageVisualsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Content.Client.Damage;

[RegisterComponent]
public sealed class DamageVisualsComponent : Component
public sealed partial class DamageVisualsComponent : Component
{
/// <summary>
/// Damage thresholds between damage state changes.
Expand Down Expand Up @@ -55,7 +55,7 @@ public sealed class DamageVisualsComponent : Component
/// (for example, Brute), and has a value
/// of a DamageVisualizerSprite (see below)
/// </summary>
[DataField("damageOverlayGroups")] public readonly Dictionary<string, DamageVisualizerSprite>? DamageOverlayGroups;
[DataField("damageOverlayGroups")] public Dictionary<string, DamageVisualizerSprite>? DamageOverlayGroups;

/// <summary>
/// Sets if you want sprites to overlay the
Expand All @@ -68,7 +68,7 @@ public sealed class DamageVisualsComponent : Component
/// - There are no target layers
/// - There is no damage group
/// </summary>
[DataField("overlay")] public readonly bool Overlay = true;
[DataField("overlay")] public bool Overlay = true;

/// <summary>
/// A single damage group to target.
Expand All @@ -84,7 +84,7 @@ public sealed class DamageVisualsComponent : Component
/// what kind of damage combination
/// you would want, on which threshold.
/// </remarks>
[DataField("damageGroup")] public readonly string? DamageGroup;
[DataField("damageGroup")] public string? DamageGroup;

/// <summary>
/// Set this if you want incoming damage to be
Expand All @@ -106,14 +106,14 @@ public sealed class DamageVisualsComponent : Component
/// This will only work if you have damageOverlay
/// defined - otherwise, it will not work.
/// </remarks>
[DataField("trackAllDamage")] public readonly bool TrackAllDamage;
[DataField("trackAllDamage")] public bool TrackAllDamage;
/// <summary>
/// This is the overlay sprite used, if _trackAllDamage is
/// enabled. Supports no complex per-group layering,
/// just an actually simple damage overlay. See
/// DamageVisualizerSprite for more information.
/// </summary>
[DataField("damageOverlay")] public readonly DamageVisualizerSprite? DamageOverlay;
[DataField("damageOverlay")] public DamageVisualizerSprite? DamageOverlay;

public readonly List<Enum> TargetLayerMapKeys = new();
public bool Disabled = false;
Expand All @@ -128,7 +128,7 @@ public sealed class DamageVisualsComponent : Component
// deals with the edge case of human damage visuals not
// being in color without making a Dict<Dict<Dict<Dict<Dict<Dict...
[DataDefinition]
public sealed class DamageVisualizerSprite
public sealed partial class DamageVisualizerSprite
{
/// <summary>
/// The RSI path for the damage visualizer
Expand All @@ -151,11 +151,11 @@ public sealed class DamageVisualizerSprite
/// - DamageOverlay_{threshold} if not targeting
/// a layer.
/// </remarks>
[DataField("sprite", required: true)] public readonly string Sprite = default!;
[DataField("sprite", required: true)] public string Sprite = default!;

/// <summary>
/// The color of this sprite overlay.
/// Supports only hexadecimal format.
/// </summary>
[DataField("color")] public readonly string? Color;
[DataField("color")] public string? Color;
}
2 changes: 1 addition & 1 deletion Content.Client/DamageState/DamageStateVisualsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Content.Client.DamageState;

[RegisterComponent]
public sealed class DamageStateVisualsComponent : Component
public sealed partial class DamageStateVisualsComponent : Component
{
public int? OriginalDrawDepth;

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Decals/DecalPlacementSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void SetActive(bool active)
}
}

public sealed class PlaceDecalActionEvent : WorldTargetActionEvent
public sealed partial class PlaceDecalActionEvent : WorldTargetActionEvent
{
[DataField("decalId", customTypeSerializer:typeof(PrototypeIdSerializer<DecalPrototype>), required:true)]
public string DecalId = string.Empty;
Expand Down
Loading

0 comments on commit a88e747

Please sign in to comment.