Skip to content

Commit

Permalink
Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Nov 17, 2023
1 parent 1a49156 commit 79b687f
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 135 deletions.
6 changes: 3 additions & 3 deletions SteamKit2/SteamKit2/Steam/Handlers/SteamFriends/Callbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ internal FriendMsgCallback( CMsgClientFriendMsgIncoming msg )
if ( msg.message != null )
{
this.Message = Encoding.UTF8.GetString( msg.message );
this.Message = this.Message.TrimEnd( ['\0'] ); // trim any extra null chars from the end
this.Message = this.Message.TrimEnd( '\0' ); // trim any extra null chars from the end
}
}
}
Expand Down Expand Up @@ -481,7 +481,7 @@ internal FriendMsgEchoCallback( CMsgClientFriendMsgIncoming msg )
if ( msg.message != null )
{
this.Message = Encoding.UTF8.GetString( msg.message );
this.Message = this.Message.TrimEnd( ['\0'] ); // trim any extra null chars from the end
this.Message = this.Message.TrimEnd( '\0' ); // trim any extra null chars from the end
}
}
}
Expand Down Expand Up @@ -728,7 +728,7 @@ internal ChatMsgCallback( MsgClientChatMsg msg, byte[] payload )
this.ChatMsgType = msg.ChatMsgType;

this.Message = Encoding.UTF8.GetString( payload );
this.Message = this.Message.TrimEnd( ['\0'] ); // trim any extra null chars from the end
this.Message = this.Message.TrimEnd( '\0' ); // trim any extra null chars from the end
}
}

Expand Down
2 changes: 1 addition & 1 deletion SteamKit2/SteamKit2/Types/DepotManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public bool DecryptFilenames(byte[] encryptionKey)
return false;
}

file.FileName = Encoding.UTF8.GetString( filename ).TrimEnd( ['\0'] ).Replace(altDirChar, Path.DirectorySeparatorChar);
file.FileName = Encoding.UTF8.GetString( filename ).TrimEnd( '\0' ).Replace(altDirChar, Path.DirectorySeparatorChar);
}

// Sort file entries alphabetically because that's what Steam does
Expand Down
42 changes: 21 additions & 21 deletions SteamKit2/SteamKit2/Types/GameID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,24 @@ public GameID()
/// Initializes a new instance of the <see cref="GameID"/> class.
/// </summary>
/// <param name="id">The 64bit integer to assign this GameID from.</param>
public GameID( UInt64 id )
public GameID( ulong id )
{
gameid = new BitVector64( id );
}
/// <summary>
/// Initializes a new instance of the <see cref="GameID"/> class.
/// </summary>
/// <param name="nAppID">The 32bit app id to assign this GameID from.</param>
public GameID( Int32 nAppID )
: this( ( UInt64 )nAppID )
public GameID( int nAppID )
: this( ( ulong )nAppID )
{
}
/// <summary>
/// Initializes a new instance of the <see cref="GameID"/> class.
/// </summary>
/// <param name="nAppID">The base app id of the mod.</param>
/// <param name="modPath">The game folder name of the mod.</param>
public GameID( UInt32 nAppID, string modPath )
public GameID( uint nAppID, string modPath )
: this(0)
{
AppID = nAppID;
Expand Down Expand Up @@ -115,7 +115,7 @@ public ulong ToUInt64()
}

/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.GameID"/> to <see cref="System.String"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.GameID"/> to <see cref="string"/>.
/// </summary>
/// <param name="gid">The GameID to convert..</param>
/// <returns>
Expand All @@ -129,27 +129,27 @@ public static implicit operator string( GameID? gid )
}

/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.GameID"/> to <see cref="System.UInt64"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.GameID"/> to <see cref="ulong"/>.
/// </summary>
/// <param name="gid">The GameId to convert.</param>
/// <returns>
/// The result of the conversion.
/// </returns>
public static implicit operator UInt64( GameID? gid )
public static implicit operator ulong( GameID? gid )
{
ArgumentNullException.ThrowIfNull( gid );

return gid.gameid.Data;
}

/// <summary>
/// Performs an implicit conversion from <see cref="System.UInt64"/> to <see cref="SteamKit2.GameID"/>.
/// Performs an implicit conversion from <see cref="ulong"/> to <see cref="SteamKit2.GameID"/>.
/// </summary>
/// <param name="id">The 64bit integer representing a GameID to convert.</param>
/// <returns>
/// The result of the conversion.
/// </returns>
public static implicit operator GameID( UInt64 id )
public static implicit operator GameID( ulong id )
{
return new GameID( id );
}
Expand All @@ -161,15 +161,15 @@ public static implicit operator GameID( UInt64 id )
/// <value>
/// The app IDid
/// </value>
public UInt32 AppID
public uint AppID
{
get
{
return ( UInt32 )gameid[ 0, 0xFFFFFF ];
return ( uint )gameid[ 0, 0xFFFFFF ];
}
set
{
gameid[ 0, 0xFFFFFF ] = ( UInt64 )value;
gameid[ 0, 0xFFFFFF ] = ( ulong )value;
}
}
/// <summary>
Expand All @@ -186,7 +186,7 @@ public GameType AppType
}
set
{
gameid[ 24, 0xFF ] = ( UInt64 )value;
gameid[ 24, 0xFF ] = ( ulong )value;
}
}
/// <summary>
Expand All @@ -195,15 +195,15 @@ public GameType AppType
/// <value>
/// The mod ID.
/// </value>
public UInt32 ModID
public uint ModID
{
get
{
return ( UInt32 )gameid[ 32, 0xFFFFFFFF ];
return ( uint )gameid[ 32, 0xFFFFFFFF ];
}
set
{
gameid[ 32, 0xFFFFFFFF ] = ( UInt64 )value;
gameid[ 32, 0xFFFFFFFF ] = ( ulong )value;
gameid[ 63, 0xFF ] = 1;
}
}
Expand Down Expand Up @@ -252,11 +252,11 @@ public bool IsSteamApp


/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// Determines whether the specified <see cref="object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals( object? obj )
{
Expand Down Expand Up @@ -333,10 +333,10 @@ public override int GetHashCode()
}

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
Expand Down
18 changes: 9 additions & 9 deletions SteamKit2/SteamKit2/Types/GlobalID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public GlobalID( ulong gid )


/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.GlobalID"/> to <see cref="System.UInt64"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.GlobalID"/> to <see cref="ulong"/>.
/// </summary>
/// <param name="gid">The gid.</param>
/// <returns>
Expand All @@ -51,7 +51,7 @@ public static implicit operator ulong( GlobalID gid )
}

/// <summary>
/// Performs an implicit conversion from <see cref="System.UInt64"/> to <see cref="SteamKit2.GlobalID"/>.
/// Performs an implicit conversion from <see cref="ulong"/> to <see cref="SteamKit2.GlobalID"/>.
/// </summary>
/// <param name="gid">The gid.</param>
/// <returns>
Expand Down Expand Up @@ -134,11 +134,11 @@ public ulong Value


/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// Determines whether the specified <see cref="object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals( object? obj )
{
Expand Down Expand Up @@ -220,10 +220,10 @@ public override int GetHashCode()
}

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
Expand Down Expand Up @@ -255,7 +255,7 @@ public UGCHandle( ulong ugcId )


/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.UGCHandle"/> to <see cref="System.UInt64"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.UGCHandle"/> to <see cref="ulong"/>.
/// </summary>
/// <param name="handle">The UGC handle.</param>
/// <returns>
Expand All @@ -269,7 +269,7 @@ public static implicit operator ulong( UGCHandle handle )
}

/// <summary>
/// Performs an implicit conversion from <see cref="System.UInt64"/> to <see cref="SteamKit2.UGCHandle"/>.
/// Performs an implicit conversion from <see cref="ulong"/> to <see cref="SteamKit2.UGCHandle"/>.
/// </summary>
/// <param name="ugcId">The UGC ID.</param>
/// <returns>
Expand Down
4 changes: 2 additions & 2 deletions SteamKit2/SteamKit2/Types/JobID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public JobID( ulong jobId )


/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.JobID"/> to <see cref="System.UInt64"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.JobID"/> to <see cref="ulong"/>.
/// </summary>
/// <param name="jobId">The Job ID.</param>
/// <returns>
Expand All @@ -55,7 +55,7 @@ public static implicit operator ulong ( JobID jobId )
}

/// <summary>
/// Performs an implicit conversion from <see cref="System.UInt64"/> to <see cref="SteamKit2.JobID"/>.
/// Performs an implicit conversion from <see cref="ulong"/> to <see cref="SteamKit2.JobID"/>.
/// </summary>
/// <param name="jobId">The Job ID.</param>
/// <returns>
Expand Down
8 changes: 4 additions & 4 deletions SteamKit2/SteamKit2/Types/KeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void EatWhiteSpace()
{
while ( !EndOfStream )
{
if ( !Char.IsWhiteSpace( ( char )Peek() ) )
if ( !char.IsWhiteSpace( ( char )Peek() ) )
{
break;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ private bool EatCPPComment()
if ( next == ']' && bConditionalStart )
wasConditional = true;

if ( Char.IsWhiteSpace( next ) )
if ( char.IsWhiteSpace( next ) )
break;

if ( count < 1023 )
Expand Down Expand Up @@ -478,10 +478,10 @@ public KeyValue this[ string key ]
}

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
Expand Down
14 changes: 7 additions & 7 deletions SteamKit2/SteamKit2/Types/PubFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public override int GetHashCode()
}

/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
/// Determines whether the specified <see cref="object"/> is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
/// <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals( object? obj )
{
Expand All @@ -69,10 +69,10 @@ public override bool Equals( object? obj )
}

/// <summary>
/// Returns a <see cref="System.String"/> that represents this instance.
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String"/> that represents this instance.
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
Expand Down Expand Up @@ -118,7 +118,7 @@ public PublishedFileID( ulong fileId = ulong.MaxValue )
}

/// <summary>
/// Performs an implicit conversion from <see cref="SteamKit2.PublishedFileID"/> to <see cref="System.UInt64"/>.
/// Performs an implicit conversion from <see cref="SteamKit2.PublishedFileID"/> to <see cref="ulong"/>.
/// </summary>
/// <param name="file">The published file.</param>
/// <returns>
Expand All @@ -131,7 +131,7 @@ public static implicit operator ulong( PublishedFileID? file )
return file.Value;
}
/// <summary>
/// Performs an implicit conversion from <see cref="System.UInt64"/> to <see cref="SteamKit2.PublishedFileID"/>.
/// Performs an implicit conversion from <see cref="ulong"/> to <see cref="SteamKit2.PublishedFileID"/>.
/// </summary>
/// <param name="fileId">The file id.</param>
/// <returns>
Expand Down
12 changes: 6 additions & 6 deletions SteamKit2/SteamKit2/Util/StreamHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@ static void EnsureInitialized()
data ??= new byte[ 8 ];
}

public static Int16 ReadInt16(this Stream stream)
public static short ReadInt16(this Stream stream)
{
EnsureInitialized();

stream.Read( data, 0, 2 );
return BitConverter.ToInt16( data, 0 );
}

public static UInt16 ReadUInt16(this Stream stream)
public static ushort ReadUInt16(this Stream stream)
{
EnsureInitialized();

stream.Read( data, 0, 2 );
return BitConverter.ToUInt16( data, 0);
}

public static Int32 ReadInt32(this Stream stream)
public static int ReadInt32(this Stream stream)
{
EnsureInitialized();

stream.Read( data, 0, 4 );
return BitConverter.ToInt32( data, 0 );
}

public static Int64 ReadInt64(this Stream stream)
public static long ReadInt64(this Stream stream)
{
EnsureInitialized();

stream.Read( data, 0, 8 );
return BitConverter.ToInt64( data, 0 );
}

public static UInt32 ReadUInt32(this Stream stream)
public static uint ReadUInt32(this Stream stream)
{
EnsureInitialized();

stream.Read(data, 0, 4);
return BitConverter.ToUInt32( data, 0);
}

public static UInt64 ReadUInt64(this Stream stream)
public static ulong ReadUInt64(this Stream stream)
{
EnsureInitialized();

Expand Down
Loading

0 comments on commit 79b687f

Please sign in to comment.