Skip to content

Commit

Permalink
Fix FxCop complaints.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbed committed Mar 30, 2019
1 parent 51ddcc0 commit 407d35b
Show file tree
Hide file tree
Showing 17 changed files with 458 additions and 43 deletions.
295 changes: 295 additions & 0 deletions SAM.API/GlobalSuppressions.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions SAM.API/NativeWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public abstract class NativeWrapper<TNativeFunctions> : INativeWrapper
public override string ToString()
{
return string.Format(
System.Globalization.CultureInfo.CurrentCulture,
"Steam Interface<{0}> #{1:X8}",
typeof(TNativeFunctions),
this.ObjectAddress.ToInt32());
Expand Down
1 change: 1 addition & 0 deletions SAM.API/SAM.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<ItemGroup>
<Compile Include="Callbacks\AppDataChanged.cs" />
<Compile Include="Callbacks\UserStatsReceived.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="ICallback.cs" />
<Compile Include="NativeStrings.cs" />
<Compile Include="Types\CallbackMessage.cs" />
Expand Down
9 changes: 5 additions & 4 deletions SAM.API/Steam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ public static class Steam
{
private struct Native
{
[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern IntPtr GetProcAddress(IntPtr module, string name);

[DllImport("kernel32.dll", SetLastError = true)]
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr LoadLibraryEx(string path, IntPtr file, uint flags);

[DllImport("kernel32.dll", SetLastError = true)]
internal static extern IntPtr SetDllDirectory(string path);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetDllDirectory(string path);

internal const uint LoadWithAlteredSearchPath = 8;
}
Expand Down
4 changes: 4 additions & 0 deletions SAM.API/Wrappers/SteamUtils005.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public bool GetImageSize(int index, out int width, out int height)

public bool GetImageRGBA(int index, byte[] data)
{
if (data == null)
{
throw new ArgumentNullException("data");
}
var call = this.GetFunction<NativeGetImageRGBA>(this.Functions.GetImageRGBA);
return call(this.ObjectAddress, index, data, data.Length);
}
Expand Down
47 changes: 47 additions & 0 deletions SAM.Game/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Game.KeyValue.#LoadAsBinary(System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Game.KeyValue.#ReadAsBinary(System.IO.Stream)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Game.Manager.#LoadUserGameStatsSchema()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Game.Manager.#OnIconDownload(System.Object,System.Net.DownloadDataCompletedEventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Game.Manager.#OnUserStatsReceived(SAM.API.Types.UserStatsReceived)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1064:ExceptionsShouldBePublic", Scope = "type", Target = "SAM.Game.Stats.StatIsProtectedException")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA2210:AssembliesShouldHaveValidStrongNames")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ColumnHeader.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#InitializeComponent()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.Control.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#InitializeComponent()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.Form.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#.ctor(System.Int64,SAM.API.Client)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#OnResetAllStats(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#OnUserStatsReceived(SAM.API.Types.UserStatsReceived)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Program.#Main(System.String[])")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#OnCheckAchievement(System.Object,System.Windows.Forms.ItemCheckEventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#OnResetAllStats(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#OnStore(System.Object,System.EventArgs)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#RefreshStats()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#Store()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#StoreAchievements()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window,System.String,System.String,System.Windows.Forms.MessageBoxButtons,System.Windows.Forms.MessageBoxIcon)", Scope = "member", Target = "SAM.Game.Manager.#StoreStatistics()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ToolStripItem.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#DownloadNextIcon()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ToolStripItem.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#InitializeComponent()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ToolStripItem.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#OnUserStatsReceived(SAM.API.Types.UserStatsReceived)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ToolStripItem.set_Text(System.String)", Scope = "member", Target = "SAM.Game.Manager.#RefreshStats()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Windows.Forms.ToolStripItem.set_ToolTipText(System.String)", Scope = "member", Target = "SAM.Game.Manager.#InitializeComponent()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison", MessageId = "System.String.StartsWith(System.String,System.StringComparison)", Scope = "member", Target = "SAM.Game.Manager.#GetAchievements()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "wstring", Scope = "member", Target = "SAM.Game.KeyValue.#ReadAsBinary(System.IO.Stream)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Scope = "member", Target = "SAM.Game.Manager.#GetStatistics()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily", Scope = "member", Target = "SAM.Game.Manager.#StoreStatistics()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.AchievementInfo.#ImageIndex")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.StatInfo.#DisplayName")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.StatInfo.#Extra")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.StatInfo.#IsIncrementOnly")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.StatIsProtectedException.#.ctor(System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.Stats.StatIsProtectedException.#.ctor(System.String,System.Exception)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "SAM.Game.StreamHelpers.#ReadStringAscii(System.IO.Stream)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.AchievementDefinition.#IsHidden")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.FloatStatDefinition.#DefaultValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.FloatStatDefinition.#MaxChange")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.FloatStatDefinition.#MaxValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.FloatStatDefinition.#MinValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.IntegerStatDefinition.#DefaultValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.IntegerStatDefinition.#MaxChange")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.IntegerStatDefinition.#MaxValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "SAM.Game.Stats.IntegerStatDefinition.#MinValue")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "SAM.Game.Manager.#.ctor(System.Int64,SAM.API.Client)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "SAM.Game.Manager.#InitializeComponent()")]
23 changes: 13 additions & 10 deletions SAM.Game/KeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public KeyValue this[string key]
}

var child = this.Children.SingleOrDefault(
c => c.Name.ToLowerInvariant() == key.ToLowerInvariant());
c => string.Compare(c.Name, key, StringComparison.InvariantCultureIgnoreCase) == 0);

if (child == null)
{
Expand Down Expand Up @@ -202,7 +202,11 @@ public override string ToString()
return this.Name;
}

return string.Format("{0} = {1}", this.Name, this.Value);
return string.Format(
System.Globalization.CultureInfo.CurrentCulture,
"{0} = {1}",
this.Name,
this.Value);
}

public static KeyValue LoadAsBinary(string path)
Expand All @@ -214,16 +218,15 @@ public static KeyValue LoadAsBinary(string path)

try
{
var input = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
var kv = new KeyValue();

if (kv.ReadAsBinary(input) == false)
using (var input = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
return null;
var kv = new KeyValue();
if (kv.ReadAsBinary(input) == false)
{
return null;
}
return kv;
}

input.Close();
return kv;
}
catch (Exception)
{
Expand Down
Loading

0 comments on commit 407d35b

Please sign in to comment.