diff --git a/Facepunch.Steamworks.Test/AppTest.cs b/Facepunch.Steamworks.Test/AppTest.cs index 51921b7..bf216aa 100644 --- a/Facepunch.Steamworks.Test/AppTest.cs +++ b/Facepunch.Steamworks.Test/AppTest.cs @@ -43,11 +43,6 @@ namespace Steamworks } - static void OnNewUrlLaunchParameters() - { - // Wow! - } - [TestMethod] public void GameLangauge() { diff --git a/Facepunch.Steamworks.Test/InventoryTest.cs b/Facepunch.Steamworks.Test/InventoryTest.cs index 4e8179a..dee610d 100644 --- a/Facepunch.Steamworks.Test/InventoryTest.cs +++ b/Facepunch.Steamworks.Test/InventoryTest.cs @@ -195,8 +195,8 @@ namespace Steamworks { await SteamInventory.WaitForDefinitions(); - byte[] data = null; - int itemCount = 0; + byte[] data; + int itemCount; // Serialize { diff --git a/Facepunch.Steamworks.Test/UgcEditor.cs b/Facepunch.Steamworks.Test/UgcEditor.cs index ab222b1..76ca8a1 100644 --- a/Facepunch.Steamworks.Test/UgcEditor.cs +++ b/Facepunch.Steamworks.Test/UgcEditor.cs @@ -130,7 +130,7 @@ namespace Steamworks [TestMethod] public async Task CreateAndThenEditFile() { - PublishedFileId fileid = default; + PublishedFileId fileid; // // Make a file diff --git a/Facepunch.Steamworks/SteamApps.cs b/Facepunch.Steamworks/SteamApps.cs index 3b7ff8f..c32b2be 100644 --- a/Facepunch.Steamworks/SteamApps.cs +++ b/Facepunch.Steamworks/SteamApps.cs @@ -168,9 +168,7 @@ namespace Steamworks appid = SteamClient.AppId; var depots = new DepotId_t[32]; - uint count = 0; - - count = Internal.GetInstalledDepots( appid.Value, depots, (uint) depots.Length ); + uint count = Internal.GetInstalledDepots( appid.Value, depots, (uint) depots.Length ); for ( int i = 0; i < count; i++ ) { @@ -220,7 +218,7 @@ namespace Steamworks ulong punBytesTotal = 0; if ( !Internal.GetDlcDownloadProgress( appid.Value, ref punBytesDownloaded, ref punBytesTotal ) ) - return default( DownloadProgress ); + return default; return new DownloadProgress { BytesDownloaded = punBytesDownloaded, BytesTotal = punBytesTotal, Active = true }; } @@ -263,7 +261,7 @@ namespace Steamworks { get { - var len = Internal.GetLaunchCommandLine( out var strVal ); + Internal.GetLaunchCommandLine( out var strVal ); return strVal; } } diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index 1937b4d..73e7149 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -74,7 +74,7 @@ namespace Steamworks openInterfaces.Add( t ); } - static List openInterfaces = new List(); + static readonly List openInterfaces = new List(); internal static void ShutdownInterfaces() { diff --git a/Facepunch.Steamworks/SteamInput.cs b/Facepunch.Steamworks/SteamInput.cs index c05ae70..d55e523 100644 --- a/Facepunch.Steamworks/SteamInput.cs +++ b/Facepunch.Steamworks/SteamInput.cs @@ -25,7 +25,7 @@ namespace Steamworks Internal.RunFrame(); } - static InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT]; + static readonly InputHandle_t[] queryArray = new InputHandle_t[STEAM_CONTROLLER_MAX_COUNT]; /// /// Return a list of connected controllers. diff --git a/Facepunch.Steamworks/SteamNetworkingSockets.cs b/Facepunch.Steamworks/SteamNetworkingSockets.cs index ae4f571..c9c3ad0 100644 --- a/Facepunch.Steamworks/SteamNetworkingSockets.cs +++ b/Facepunch.Steamworks/SteamNetworkingSockets.cs @@ -103,7 +103,7 @@ namespace Steamworks public static T CreateNormalSocket( NetAddress address ) where T : SocketInterface, new() { var t = new T(); - var options = new NetKeyValue[0]; + var options = Array.Empty(); t.Socket = Internal.CreateListenSocketIP( ref address, options.Length, options ); t.Initialize(); @@ -117,7 +117,7 @@ namespace Steamworks public static T ConnectNormal( NetAddress address ) where T : ConnectionInterface, new() { var t = new T(); - var options = new NetKeyValue[0]; + var options = Array.Empty(); t.Connection = Internal.ConnectByIPAddress( ref address, options.Length, options ); SetConnectionInterface( t.Connection.Id, t ); return t; @@ -129,7 +129,7 @@ namespace Steamworks public static T CreateRelaySocket( int virtualport = 0 ) where T : SocketInterface, new() { var t = new T(); - var options = new NetKeyValue[0]; + var options = Array.Empty(); t.Socket = Internal.CreateListenSocketP2P( virtualport, options.Length, options ); SetSocketInterface( t.Socket.Id, t ); return t; @@ -142,7 +142,7 @@ namespace Steamworks { var t = new T(); NetIdentity identity = serverId; - var options = new NetKeyValue[0]; + var options = Array.Empty(); t.Connection = Internal.ConnectP2P( ref identity, virtualport, options.Length, options ); SetConnectionInterface( t.Connection.Id, t ); return t; diff --git a/Facepunch.Steamworks/SteamNetworkingUtils.cs b/Facepunch.Steamworks/SteamNetworkingUtils.cs index ff6d06a..7e02b3a 100644 --- a/Facepunch.Steamworks/SteamNetworkingUtils.cs +++ b/Facepunch.Steamworks/SteamNetworkingUtils.cs @@ -109,7 +109,7 @@ namespace Steamworks /// public static async Task WaitForPingDataAsync( float maxAgeInSeconds = 60 * 5 ) { - if ( Internal.CheckPingDataUpToDate( 120.0f ) ) + if ( Internal.CheckPingDataUpToDate( maxAgeInSeconds ) ) return; SteamRelayNetworkStatus_t status = default; diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index 09367de..32ec298 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -131,7 +131,7 @@ namespace Steamworks openInterfaces.Add( t ); } - static List openInterfaces = new List(); + static readonly List openInterfaces = new List(); internal static void ShutdownInterfaces() { diff --git a/Facepunch.Steamworks/SteamUgc.cs b/Facepunch.Steamworks/SteamUgc.cs index e3a8654..4ddb20e 100644 --- a/Facepunch.Steamworks/SteamUgc.cs +++ b/Facepunch.Steamworks/SteamUgc.cs @@ -58,7 +58,7 @@ namespace Steamworks /// Allows you to send a message to cancel the download anywhere during the process /// How often to call the progress function /// true if downloaded and installed correctly - public static async Task DownloadAsync( PublishedFileId fileId, Action progress = null, CancellationToken ct = default, int milisecondsUpdateDelay = 60 ) + public static async Task DownloadAsync( PublishedFileId fileId, Action progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default ) { var item = new Steamworks.Ugc.Item( fileId ); diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index f35f6e2..55e7f78 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -318,11 +318,11 @@ namespace Steamworks AuthTicket ticket = null; var stopwatch = Stopwatch.StartNew(); - Action f = ( t ) => + void f( GetAuthSessionTicketResponse_t t ) { if ( t.AuthTicket != ticket.Handle ) return; result = t.Result; - }; + } OnGetAuthSessionTicketResponse += f; diff --git a/Facepunch.Steamworks/Structs/Achievement.cs b/Facepunch.Steamworks/Structs/Achievement.cs index 966df12..04ac438 100644 --- a/Facepunch.Steamworks/Structs/Achievement.cs +++ b/Facepunch.Steamworks/Structs/Achievement.cs @@ -75,12 +75,12 @@ namespace Steamworks.Data var ident = Identifier; bool gotCallback = false; - Action f = ( x, icon ) => + void f( string x, int icon ) { if ( x != ident ) return; i = icon; gotCallback = true; - }; + } try { diff --git a/Facepunch.Steamworks/Structs/Friend.cs b/Facepunch.Steamworks/Structs/Friend.cs index 5be8f94..0561b8d 100644 --- a/Facepunch.Steamworks/Structs/Friend.cs +++ b/Facepunch.Steamworks/Structs/Friend.cs @@ -51,7 +51,7 @@ namespace Steamworks /// Sometimes we don't know the user's name. This will wait until we have /// downloaded the information on this user. /// - public async Task RequestInfoAsync( int timeout = 5000 ) + public async Task RequestInfoAsync() { await SteamFriends.CacheUserInformationAsync( Id, true ); } @@ -99,7 +99,7 @@ namespace Steamworks { get { - FriendGameInfo_t gameInfo = default( FriendGameInfo_t ); + FriendGameInfo_t gameInfo = default; if ( !SteamFriends.Internal.GetFriendGamePlayed( Id, ref gameInfo ) ) return null; diff --git a/Facepunch.Steamworks/Structs/InventoryDef.cs b/Facepunch.Steamworks/Structs/InventoryDef.cs index 0f689aa..2afb6f7 100644 --- a/Facepunch.Steamworks/Structs/InventoryDef.cs +++ b/Facepunch.Steamworks/Structs/InventoryDef.cs @@ -135,7 +135,7 @@ namespace Steamworks string val = GetProperty( name ); if ( string.IsNullOrEmpty( val ) ) - return default( T ); + return default; try { @@ -143,7 +143,7 @@ namespace Steamworks } catch ( System.Exception ) { - return default( T ); + return default; } } diff --git a/Facepunch.Steamworks/Structs/Leaderboard.cs b/Facepunch.Steamworks/Structs/Leaderboard.cs index afc18a3..271d7b8 100644 --- a/Facepunch.Steamworks/Structs/Leaderboard.cs +++ b/Facepunch.Steamworks/Structs/Leaderboard.cs @@ -20,7 +20,7 @@ namespace Steamworks.Data public int EntryCount => SteamUserStats.Internal.GetLeaderboardEntryCount(Id); static int[] detailsBuffer = new int[64]; - static int[] noDetails = new int[0]; + static int[] noDetails = Array.Empty(); /// /// Submit your score and replace your old score even if it was better @@ -122,7 +122,7 @@ namespace Steamworks.Data return output; } - internal async Task WaitForUserNames( LeaderboardEntry[] entries) + internal static async Task WaitForUserNames( LeaderboardEntry[] entries) { bool gotAll = false; while ( !gotAll ) diff --git a/Facepunch.Steamworks/Structs/Lobby.cs b/Facepunch.Steamworks/Structs/Lobby.cs index db229ac..70ecdf3 100644 --- a/Facepunch.Steamworks/Structs/Lobby.cs +++ b/Facepunch.Steamworks/Structs/Lobby.cs @@ -123,7 +123,7 @@ namespace Steamworks.Data /// /// Sets per-user metadata (for the local user implicitly) /// - public void SetMemberData( Friend member, string key, string value ) + public void SetMemberData( string key, string value ) { SteamMatchmaking.Internal.SetLobbyMemberData( Id, key, value ); } diff --git a/Facepunch.Steamworks/Structs/PartyBeacon.cs b/Facepunch.Steamworks/Structs/PartyBeacon.cs index 2bb4145..b889042 100644 --- a/Facepunch.Steamworks/Structs/PartyBeacon.cs +++ b/Facepunch.Steamworks/Structs/PartyBeacon.cs @@ -18,7 +18,7 @@ namespace Steamworks { var owner = default( SteamId ); var location = default( SteamPartyBeaconLocation_t ); - Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal ); + Internal.GetBeaconDetails( Id, ref owner, ref location, out _ ); return owner; } } @@ -32,7 +32,7 @@ namespace Steamworks { var owner = default( SteamId ); var location = default( SteamPartyBeaconLocation_t ); - Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal ); + _ = Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal ); return strVal; } } diff --git a/Facepunch.Steamworks/Structs/Server.cs b/Facepunch.Steamworks/Structs/Server.cs index 765e052..89ea224 100644 --- a/Facepunch.Steamworks/Structs/Server.cs +++ b/Facepunch.Steamworks/Structs/Server.cs @@ -9,8 +9,6 @@ namespace Steamworks.Data { public struct ServerInfo : IEquatable { - static ISteamMatchmakingServers Internal => Steamworks.ServerList.Base.Internal; - public string Name { get; set; } public int Ping { get; set; } public string GameDir { get; set; } diff --git a/Facepunch.Steamworks/Structs/UgcItem.cs b/Facepunch.Steamworks/Structs/UgcItem.cs index a614789..bd93fa0 100644 --- a/Facepunch.Steamworks/Structs/UgcItem.cs +++ b/Facepunch.Steamworks/Structs/UgcItem.cs @@ -183,8 +183,7 @@ namespace Steamworks.Ugc ulong size = 0; uint ts = 0; - - if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out var strVal, ref ts ) ) + if ( !SteamUGC.Internal.GetItemInstallInfo( Id, ref size, out _, ref ts ) ) return 0; return (long) size; @@ -262,9 +261,9 @@ namespace Steamworks.Ugc /// If CancellationToken is default then there is 60 seconds timeout /// Progress will be set to 0-1 /// - public async Task DownloadAsync( Action progress = null, CancellationToken ct = default, int milisecondsUpdateDelay = 60 ) + public async Task DownloadAsync( Action progress = null, int milisecondsUpdateDelay = 60, CancellationToken ct = default ) { - return await SteamUGC.DownloadAsync( Id, progress, ct, milisecondsUpdateDelay ); + return await SteamUGC.DownloadAsync( Id, progress, milisecondsUpdateDelay, ct ); } /// diff --git a/Facepunch.Steamworks/Utility/SourceServerQuery.cs b/Facepunch.Steamworks/Utility/SourceServerQuery.cs index c635e75..8463ed5 100644 --- a/Facepunch.Steamworks/Utility/SourceServerQuery.cs +++ b/Facepunch.Steamworks/Utility/SourceServerQuery.cs @@ -13,7 +13,7 @@ namespace Steamworks { private static readonly byte[] A2S_SERVERQUERY_GETCHALLENGE = { 0x55, 0xFF, 0xFF, 0xFF, 0xFF }; // private static readonly byte A2S_PLAYER = 0x55; - private static readonly byte A2S_RULES = 0x56; + private const byte A2S_RULES = 0x56; private static readonly Dictionary>> PendingQueries = new Dictionary>>(); @@ -27,7 +27,7 @@ namespace Steamworks if (PendingQueries.TryGetValue(endpoint, out var pending)) return pending; - var task = GetRulesImpl(endpoint, server) + var task = GetRulesImpl( endpoint ) .ContinueWith(t => { lock (PendingQueries) @@ -44,7 +44,7 @@ namespace Steamworks } } - private static async Task> GetRulesImpl( IPEndPoint endpoint, ServerInfo server ) + private static async Task> GetRulesImpl( IPEndPoint endpoint ) { try { diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs index f409449..89d23e3 100644 --- a/Facepunch.Steamworks/Utility/SteamInterface.cs +++ b/Facepunch.Steamworks/Utility/SteamInterface.cs @@ -61,7 +61,7 @@ namespace Steamworks public class SteamSharedClass : SteamClass { - internal static SteamInterface Interface => InterfaceClient != null ? InterfaceClient : InterfaceServer; + internal static SteamInterface Interface => InterfaceClient ?? InterfaceServer; internal static SteamInterface InterfaceClient; internal static SteamInterface InterfaceServer; diff --git a/Facepunch.Steamworks/Utility/Utility.cs b/Facepunch.Steamworks/Utility/Utility.cs index 2bc8110..645f501 100644 --- a/Facepunch.Steamworks/Utility/Utility.cs +++ b/Facepunch.Steamworks/Utility/Utility.cs @@ -89,7 +89,7 @@ namespace Steamworks } } - static byte[] readBuffer = new byte[1024 * 8]; + static readonly byte[] readBuffer = new byte[1024 * 8]; public static string ReadNullTerminatedUTF8String( this BinaryReader br ) { diff --git a/Generator/CodeWriter/Interface.cs b/Generator/CodeWriter/Interface.cs index c35d22f..f85927a 100644 --- a/Generator/CodeWriter/Interface.cs +++ b/Generator/CodeWriter/Interface.cs @@ -100,7 +100,7 @@ namespace Generator { if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType ) { - if ( args[i + 1].Ref == string.Empty ) + if ( string.IsNullOrEmpty( args[i + 1].Ref ) ) { args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" ); } diff --git a/Generator/CodeWriter/Struct.cs b/Generator/CodeWriter/Struct.cs index 2e252a5..e1531b0 100644 --- a/Generator/CodeWriter/Struct.cs +++ b/Generator/CodeWriter/Struct.cs @@ -15,7 +15,7 @@ namespace Generator public string ManagedType; } - private Dictionary TypeDefs = new Dictionary(); + private readonly Dictionary TypeDefs = new Dictionary(); void Structs() { @@ -29,8 +29,6 @@ namespace Generator if ( name.Contains( "::" ) ) continue; - int defaultPack = c.IsPack4OnWindows ? 4 : 8; - var partial = ""; if ( c.Methods != null ) partial = " partial"; diff --git a/Generator/CodeWriter/StructFunctions.cs b/Generator/CodeWriter/StructFunctions.cs index f135a20..7613430 100644 --- a/Generator/CodeWriter/StructFunctions.cs +++ b/Generator/CodeWriter/StructFunctions.cs @@ -46,7 +46,7 @@ namespace Generator { if ( args[i + 1] is IntType || args[i + 1] is UIntType || args[i + 1] is UIntPtrType ) { - if ( args[i + 1].Ref == string.Empty ) + if ( string.IsNullOrEmpty( args[i + 1].Ref ) ) { args[i + 1] = new LiteralType( args[i + 1], "(1024 * 32)" ); }