Skip to content

Commit

Permalink
Clean up some warnings (#6088)
Browse files Browse the repository at this point in the history
* Clean up some warnings

* Remove nullable enable

Co-authored-by: ShadowCommander <[email protected]>

Co-authored-by: ShadowCommander <[email protected]>
  • Loading branch information
wrexbe and ShadowCommander authored Jan 10, 2022
1 parent 03c56bf commit 5ceb237
Show file tree
Hide file tree
Showing 37 changed files with 126 additions and 119 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Arcade/UI/BlockGameBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected override void ReceiveMessage(BoundUserInterfaceMessage message)
_menu?.SetUsability(userMessage.IsPlayer);
break;
case BlockGameMessages.BlockGameSetScreenMessage statusMessage:
if (statusMessage.isStarted) _menu?.SetStarted();
if (statusMessage.IsStarted) _menu?.SetStarted();
_menu?.SetScreen(statusMessage.Screen);
if (statusMessage is BlockGameMessages.BlockGameGameOverScreenMessage gameOverScreenMessage)
_menu?.SetGameoverInfo(gameOverScreenMessage.FinalScore, gameOverScreenMessage.LocalPlacement, gameOverScreenMessage.GlobalPlacement);
Expand Down
12 changes: 6 additions & 6 deletions Content.Client/Computer/ComputerBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ namespace Content.Client.Computer
/// ComputerBoundUserInterface shunts all sorts of responsibilities that are in the BoundUserInterface for architectural reasons into the Window.
/// NOTE: Despite the name, ComputerBoundUserInterface does not and will not care about things like power.
/// </summary>
public class ComputerBoundUserInterface<W, S> : ComputerBoundUserInterfaceBase where W : BaseWindow, IComputerWindow<S>, new() where S : BoundUserInterfaceState
public class ComputerBoundUserInterface<TWindow, TState> : ComputerBoundUserInterfaceBase where TWindow : BaseWindow, IComputerWindow<TState>, new() where TState : BoundUserInterfaceState
{
[Dependency] private readonly IDynamicTypeFactory _dynamicTypeFactory = default!;
private W? _window;
private TWindow? _window;

protected override void Open()
{
base.Open();

_window = (W) _dynamicTypeFactory.CreateInstance(typeof(W));
_window = (TWindow) _dynamicTypeFactory.CreateInstance(typeof(TWindow));
_window.SetupComputerWindow(this);
_window.OnClose += Close;
_window.OpenCentered();
Expand All @@ -36,7 +36,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
return;
}

_window.UpdateState((S) state);
_window.UpdateState((TState) state);
}

protected override void Dispose(bool disposing)
Expand Down Expand Up @@ -64,10 +64,10 @@ public ComputerBoundUserInterfaceBase(ClientUserInterfaceComponent owner, object
}
}

public interface IComputerWindow<S>
public interface IComputerWindow<TState>
{
void SetupComputerWindow(ComputerBoundUserInterfaceBase cb) {}
void UpdateState(S state) {}
void UpdateState(TState state) {}
}
}

2 changes: 0 additions & 2 deletions Content.Client/Decals/DecalOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using Robust.Client.Utility;
using Robust.Shared.Enums;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Robust.Shared.Maths;

namespace Content.Client.Decals
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Inventory/StrippableBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void Open()
{
base.Open();

_strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", Name: IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName))}");
_strippingMenu = new StrippingMenu($"{Loc.GetString("strippable-bound-user-interface-stripping-menu-title",("ownerName", IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName))}");

_strippingMenu.OnClose += Close;
_strippingMenu.OpenCentered();
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Lathe/Components/LatheDatabaseComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public override void HandleComponentState(ComponentState? curState, ComponentSta

Clear();

foreach (var ID in state.Recipes)
foreach (var id in state.Recipes)
{
if (!_prototypeManager.TryIndex(ID, out LatheRecipePrototype? recipe)) continue;
if (!_prototypeManager.TryIndex(id, out LatheRecipePrototype? recipe)) continue;
AddRecipe(recipe);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public override void HandleComponentState(ComponentState? curState, ComponentSta

Clear();

foreach (var ID in state.Recipes)
foreach (var id in state.Recipes)
{
if(!_prototypeManager.TryIndex(ID, out LatheRecipePrototype? recipe)) continue;
if(!_prototypeManager.TryIndex(id, out LatheRecipePrototype? recipe)) continue;
AddRecipe(recipe);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Populate(MedicalScannerBoundUserInterfaceState state)
}
else
{
text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", Name: entities.GetComponent<MetaDataComponent>(state.Entity.Value).EntityName))}\n");
text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entities.GetComponent<MetaDataComponent>(state.Entity.Value).EntityName))}\n");

var totalDamage = state.DamagePerType.Values.Sum();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.VendingMachines.UI;
using Content.Client.VendingMachines.UI;
using Content.Shared.VendingMachines;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
Expand Down Expand Up @@ -38,9 +38,9 @@ protected override void Open()
_menu.OpenCentered();
}

public void Eject(string ID)
public void Eject(string id)
{
SendMessage(new VendingMachineEjectMessage(ID));
SendMessage(new VendingMachineEjectMessage(id));
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public async Task Test()
EntityUid uniform = default;
EntityUid idCard = default;
EntityUid pocketItem = default;
InventoryComponent inventory = null;

InventorySystem invSystem = default!;

Expand Down
21 changes: 11 additions & 10 deletions Content.Server.Database/NpgsqlTypeMapping.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq.Expressions;
using System.Linq.Expressions;
using System.Net;
using System.Reflection;
using Microsoft.EntityFrameworkCore.Storage;
Expand Down Expand Up @@ -42,26 +42,27 @@ protected NpgsqlInetWithMaskTypeMapping(RelationalTypeMappingParameters paramete
}

protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters parameters)
=> new NpgsqlInetWithMaskTypeMapping(parameters);
{
return new NpgsqlInetWithMaskTypeMapping(parameters);
}

protected override string GenerateNonNullSqlLiteral(object value)
{
var cidr = ((IPAddress Address, int Subnet)) value;
return $"INET '{cidr.Address}/{cidr.Subnet}'";
var (address, subnet) = ((IPAddress, int)) value;
return $"INET '{address}/{subnet}'";
}

public override Expression GenerateCodeLiteral(object value)
{
var cidr = ((IPAddress Address, int Subnet)) value;
var (address, subnet) = ((IPAddress, int)) value;
return Expression.New(
Constructor,
Expression.Call(ParseMethod, Expression.Constant(cidr.Address.ToString())),
Expression.Constant(cidr.Subnet));
Expression.Call(ParseMethod, Expression.Constant(address.ToString())),
Expression.Constant(subnet));
}

static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] {typeof(string)})!;

static readonly ConstructorInfo Constructor =
private static readonly MethodInfo ParseMethod = typeof(IPAddress).GetMethod("Parse", new[] {typeof(string)})!;
private static readonly ConstructorInfo Constructor =
typeof((IPAddress, int)).GetConstructor(new[] {typeof(IPAddress), typeof(int)})!;
}
}
19 changes: 14 additions & 5 deletions Content.Server.Database/SnakeCaseNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public SnakeCaseExtension() {
}

public void ApplyServices(IServiceCollection services)
=> services.AddSnakeCase();
{
services.AddSnakeCase();
}

public void Validate(IDbContextOptions options) {}

Expand All @@ -33,7 +35,10 @@ public ExtensionInfo(IDbContextOptionsExtension extension) : base(extension) {}

public override string LogFragment => "Snake Case Extension";

public override int GetServiceProviderHashCode() => 0;
public override int GetServiceProviderHashCode()
{
return 0;
}

public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
{
Expand Down Expand Up @@ -154,7 +159,9 @@ public void ProcessEntityTypeBaseTypeChanged(
public virtual void ProcessPropertyAdded(
IConventionPropertyBuilder propertyBuilder,
IConventionContext<IConventionPropertyBuilder> context)
=> RewriteColumnName(propertyBuilder);
{
RewriteColumnName(propertyBuilder);
}

public void ProcessForeignKeyOwnershipChanged(IConventionForeignKeyBuilder relationshipBuilder, IConventionContext<bool?> context)
{
Expand Down Expand Up @@ -237,7 +244,9 @@ public void ProcessEntityTypeAnnotationChanged(
public void ProcessForeignKeyAdded(
IConventionForeignKeyBuilder relationshipBuilder,
IConventionContext<IConventionForeignKeyBuilder> context)
=> relationshipBuilder.HasConstraintName(RewriteName(relationshipBuilder.Metadata.GetDefaultName()));
{
relationshipBuilder.HasConstraintName(RewriteName(relationshipBuilder.Metadata.GetDefaultName()));
}

public void ProcessKeyAdded(IConventionKeyBuilder keyBuilder, IConventionContext<IConventionKeyBuilder> context)
{
Expand Down Expand Up @@ -289,7 +298,7 @@ public void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConven
}
}

private void RewriteColumnName(IConventionPropertyBuilder propertyBuilder)
private static void RewriteColumnName(IConventionPropertyBuilder propertyBuilder)
{
var property = propertyBuilder.Metadata;
var entityType = property.DeclaringEntityType;
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/AI/Pathfinding/PathfindingChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public IEnumerable<PathfindingChunk> GetNeighbors()
}
}

public bool InBounds(Vector2i Vector2i)
public bool InBounds(Vector2i vector)
{
if (Vector2i.X < _indices.X || Vector2i.Y < _indices.Y) return false;
if (Vector2i.X >= _indices.X + ChunkSize || Vector2i.Y >= _indices.Y + ChunkSize) return false;
if (vector.X < _indices.X || vector.Y < _indices.Y) return false;
if (vector.X >= _indices.X + ChunkSize || vector.Y >= _indices.Y + ChunkSize) return false;
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Actions/Actions/DisarmAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void DoTargetEntityAction(TargetEntityActionEventArgs args)
SoundSystem.Play(Filter.Pvs(args.Performer), PunchMissSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f));

args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients",
("performerName", Name: entMan.GetComponent<MetaDataComponent>(args.Performer).EntityName),
("targetName", Name: entMan.GetComponent<MetaDataComponent>(args.Target).EntityName)));
("performerName", entMan.GetComponent<MetaDataComponent>(args.Performer).EntityName),
("targetName", entMan.GetComponent<MetaDataComponent>(args.Target).EntityName)));
args.Performer.PopupMessageCursor(Loc.GetString("disarm-action-popup-message-cursor",
("targetName", Name: entMan.GetComponent<MetaDataComponent>(args.Target).EntityName)));
("targetName", entMan.GetComponent<MetaDataComponent>(args.Target).EntityName)));
system.SendLunge(angle, args.Performer);
return;
}
Expand Down
18 changes: 9 additions & 9 deletions Content.Server/Administration/BwoinkSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#nullable enable
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand All @@ -22,6 +21,7 @@
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Utility;
using System.Text.Json.Serialization;

namespace Content.Server.Administration
{
Expand Down Expand Up @@ -94,8 +94,8 @@ private async void ProcessQueue(NetUserId channelId, Queue<string> messages)

var payload = new WebhookPayload()
{
username = oldMessage.username,
content = oldMessage.content
Username = oldMessage.username,
Content = oldMessage.content
};

if (oldMessage.id == string.Empty)
Expand Down Expand Up @@ -242,14 +242,14 @@ private string GenerateAHelpMessage(string username, string message, bool admin,

private struct WebhookPayload
{
// ReSharper disable once InconsistentNaming
public string username { get; set; } = "";
[JsonPropertyName("username")]
public string Username { get; set; } = "";

// ReSharper disable once InconsistentNaming
public string content { get; set; } = "";
[JsonPropertyName("content")]
public string Content { get; set; } = "";

// ReSharper disable once InconsistentNaming
public Dictionary<string, string[]> allowed_mentions { get; set; } =
[JsonPropertyName("allowed_mentions")]
public Dictionary<string, string[]> AllowedMentions { get; set; } =
new()
{
{ "parse", Array.Empty<string>() }
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Atmos.EntitySystems;
Expand Down Expand Up @@ -155,8 +155,8 @@ public override void Update(float frameTime)
{
for (var x = 0; x < LocalViewRange; x++)
{
var Vector2i = new Vector2i(baseTile.X + x, baseTile.Y + y);
debugOverlayContent[index++] = ConvertTileToData(_atmosphereSystem.GetTileAtmosphereOrCreateSpace(grid, gam, Vector2i));
var vector = new Vector2i(baseTile.X + x, baseTile.Y + y);
debugOverlayContent[index++] = ConvertTileToData(_atmosphereSystem.GetTileAtmosphereOrCreateSpace(grid, gam, vector));
}
}

Expand Down
10 changes: 5 additions & 5 deletions Content.Server/Botany/Components/PlantHolderComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
}

user.PopupMessageCursor(Loc.GetString("plant-holder-component-already-seeded-message",
("name", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
("name", _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
return false;
}

Expand All @@ -694,9 +694,9 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
if (WeedLevel > 0)
{
user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-weeds-message",
("name", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
("name", _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-weeds-others-message",
("otherName", Name: _entMan.GetComponent<MetaDataComponent>(user).EntityName)));
("otherName", _entMan.GetComponent<MetaDataComponent>(user).EntityName)));
WeedLevel = 0;
UpdateSprite();
}
Expand All @@ -713,9 +713,9 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
if (Seed != null)
{
user.PopupMessageCursor(Loc.GetString("plant-holder-component-remove-plant-message",
("name", Name: _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
("name", _entMan.GetComponent<MetaDataComponent>(Owner).EntityName)));
user.PopupMessageOtherClients(Loc.GetString("plant-holder-component-remove-plant-others-message",
("name", Name: _entMan.GetComponent<MetaDataComponent>(user).EntityName)));
("name", _entMan.GetComponent<MetaDataComponent>(user).EntityName)));
RemovePlant();
}
else
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Botany/Components/SeedExtractorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)

if (_entMan.TryGetComponent(eventArgs.Using, out ProduceComponent? produce) && produce.Seed != null)
{
eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", Name: _entMan.GetComponent<MetaDataComponent>(eventArgs.Using).EntityName)));
eventArgs.User.PopupMessageCursor(Loc.GetString("seed-extractor-component-interact-message",("name", _entMan.GetComponent<MetaDataComponent>(eventArgs.Using).EntityName)));

_entMan.QueueDeleteEntity(eventArgs.Using);

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void EntitySay(EntityUid source, string message, bool hideChat=false)
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
msg.Channel = ChatChannel.Local;
msg.Message = message;
msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", Name: _entManager.GetComponent<MetaDataComponent>(source).EntityName));
msg.MessageWrap = Loc.GetString("chat-manager-entity-say-wrap-message",("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
msg.SenderEntity = source;
msg.HideChat = hideChat;
_netManager.ServerSendToMany(msg, clients);
Expand Down Expand Up @@ -233,7 +233,7 @@ public void EntityMe(EntityUid source, string action)
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
msg.Channel = ChatChannel.Emotes;
msg.Message = action;
msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName",Name: _entManager.GetComponent<MetaDataComponent>(source).EntityName));
msg.MessageWrap = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName", _entManager.GetComponent<MetaDataComponent>(source).EntityName));
msg.SenderEntity = source;
_netManager.ServerSendToMany(msg, clients);
}
Expand Down
Loading

0 comments on commit 5ceb237

Please sign in to comment.