Skip to content

Commit

Permalink
Fix FxCop complaints.
Browse files Browse the repository at this point in the history
gibbed committed Mar 30, 2019
1 parent 51ddcc0 commit 407d35b
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
@@ -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());
1 change: 1 addition & 0 deletions SAM.API/SAM.API.csproj
Original file line number Diff line number Diff line change
@@ -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" />
9 changes: 5 additions & 4 deletions SAM.API/Steam.cs
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions SAM.API/Wrappers/SteamUtils005.cs
Original file line number Diff line number Diff line change
@@ -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);
}
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
@@ -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)
{
@@ -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)
@@ -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)
{
62 changes: 42 additions & 20 deletions SAM.Game/Manager.cs
Original file line number Diff line number Diff line change
@@ -156,26 +156,31 @@ private void DownloadNextIcon()
return;
}

if (this._IconDownloader.IsBusy)
if (this._IconDownloader.IsBusy == true)
{
return;
}

this._DownloadStatusLabel.Text = string.Format("Downloading {0} icons...", this._IconQueue.Count);
this._DownloadStatusLabel.Text = string.Format(
CultureInfo.CurrentCulture,
"Downloading {0} icons...",
this._IconQueue.Count);
this._DownloadStatusLabel.Visible = true;

var info = this._IconQueue[0];
this._IconQueue.RemoveAt(0);


this._IconDownloader.DownloadDataAsync(
new Uri(string.Format("http://media.steamcommunity.com/steamcommunity/public/images/apps/{0}/{1}",
this._GameId,
info.IsAchieved == true ? info.IconNormal : info.IconLocked)),
new Uri(string.Format(
CultureInfo.InvariantCulture,
"http://media.steamcommunity.com/steamcommunity/public/images/apps/{0}/{1}",
this._GameId,
info.IsAchieved == true ? info.IconNormal : info.IconLocked)),
info);
}

private string TranslateError(int id)
private static string TranslateError(int id)
{
switch (id)
{
@@ -188,7 +193,7 @@ private string TranslateError(int id)
return id.ToString(CultureInfo.InvariantCulture);
}

private string GetLocalizedString(KeyValue kv, string language, string defaultValue)
private static string GetLocalizedString(KeyValue kv, string language, string defaultValue)
{
var name = kv[language].AsString("");
if (string.IsNullOrEmpty(name) == false)
@@ -223,7 +228,10 @@ private bool LoadUserGameStatsSchema()
path = API.Steam.GetInstallPath();
path = Path.Combine(path, "appcache");
path = Path.Combine(path, "stats");
path = Path.Combine(path, string.Format("UserGameStatsSchema_{0}.bin", this._GameId));
path = Path.Combine(path, string.Format(
CultureInfo.InvariantCulture,
"UserGameStatsSchema_{0}.bin",
this._GameId));

if (File.Exists(path) == false)
{
@@ -268,7 +276,7 @@ private bool LoadUserGameStatsSchema()
var type = (APITypes.UserStatType)rawType;
switch (type)
{
case API.Types.UserStatType.Invalid:
case APITypes.UserStatType.Invalid:
{
break;
}
@@ -318,7 +326,7 @@ private bool LoadUserGameStatsSchema()
if (stat.Children != null)
{
foreach (var bits in stat.Children.Where(
b => b.Name.ToLowerInvariant() == "bits"))
b => string.Compare(b.Name, "bits", StringComparison.InvariantCultureIgnoreCase) == 0))
{
if (bits.Valid == false ||
bits.Children == null)
@@ -364,6 +372,7 @@ private void OnUserStatsReceived(APITypes.UserStatsReceived param)
if (param.Result != 1)
{
this._GameStatusLabel.Text = string.Format(
CultureInfo.CurrentCulture,
"Error while retrieving stats: {0}",
TranslateError(param.Result));
this.EnableInput();
@@ -395,6 +404,7 @@ private void OnUserStatsReceived(APITypes.UserStatsReceived param)
}

this._GameStatusLabel.Text = string.Format(
CultureInfo.CurrentCulture,
"Retrieved {0} achievements and {1} statistics.",
this._AchievementListView.Items.Count,
this._StatisticsDataGridView.Rows.Count);
@@ -428,7 +438,7 @@ private void GetAchievements()

foreach (var def in this._AchievementDefinitions)
{
if (def.Id == string.Empty)
if (string.IsNullOrEmpty(def.Id) == true)
{
continue;
}
@@ -460,7 +470,7 @@ private void GetAchievements()

info.Item = item;

if (item.Text.StartsWith("#") == true)
if (item.Text.StartsWith("#", StringComparison.InvariantCulture) == true)
{
item.Text = info.Id;
}
@@ -580,7 +590,10 @@ private int StoreAchievements()
{
MessageBox.Show(
this,
string.Format("An error occured while setting the state for {0}, aborting store.", info.Id),
string.Format(
CultureInfo.CurrentCulture,
"An error occurred while setting the state for {0}, aborting store.",
info.Id),
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
@@ -615,7 +628,10 @@ private int StoreStatistics()
{
MessageBox.Show(
this,
string.Format("An error occured while setting the value for {0}, aborting store.", stat.Id),
string.Format(
CultureInfo.CurrentCulture,
"An error occurred while setting the value for {0}, aborting store.",
stat.Id),
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
@@ -631,7 +647,10 @@ private int StoreStatistics()
{
MessageBox.Show(
this,
string.Format("An error occured while setting the value for {0}, aborting store.", stat.Id),
string.Format(
CultureInfo.CurrentCulture,
"An error occurred while setting the value for {0}, aborting store.",
stat.Id),
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
@@ -640,7 +659,7 @@ private int StoreStatistics()
}
else
{
throw new Exception();
throw new InvalidOperationException("unsupported stat type");
}
}

@@ -701,7 +720,7 @@ private bool Store()
{
MessageBox.Show(
this,
"An error occured while storing, aborting.",
"An error occurred while storing, aborting.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
@@ -735,7 +754,11 @@ private void OnStore(object sender, EventArgs e)

MessageBox.Show(
this,
string.Format("Stored {0} achievements and {1} statistics.", achievements, stats),
string.Format(
CultureInfo.CurrentCulture,
"Stored {0} achievements and {1} statistics.",
achievements,
stats),
"Information",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
@@ -746,18 +769,17 @@ private void OnStatDataError(object sender, DataGridViewDataErrorEventArgs e)
{
if (e.Context == DataGridViewDataErrorContexts.Commit)
{
var view = (DataGridView)sender;
if (e.Exception is Stats.StatIsProtectedException)
{
e.ThrowException = false;
e.Cancel = true;
var view = (DataGridView)sender;
view.Rows[e.RowIndex].ErrorText = "Stat is protected! -- you can't modify it";
}
else
{
e.ThrowException = false;
e.Cancel = true;
var view = (DataGridView)sender;
view.Rows[e.RowIndex].ErrorText = "Invalid value";
}
}
2 changes: 1 addition & 1 deletion SAM.Game/Program.cs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ public static void Main(string[] args)
if (long.TryParse(args[0], out appId) == false)
{
MessageBox.Show(
"Could not parse application ID from commandline argument.",
"Could not parse application ID from command line argument.",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
1 change: 1 addition & 0 deletions SAM.Game/SAM.Game.csproj
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Stats\AchievementInfo.cs" />
<Compile Include="DoubleBufferedListView.cs">
<SubType>Component</SubType>
6 changes: 5 additions & 1 deletion SAM.Game/Stats/AchievementDefinition.cs
Original file line number Diff line number Diff line change
@@ -34,7 +34,11 @@ internal class AchievementDefinition

public override string ToString()
{
return string.Format("{0}: {1}", this.Name ?? this.Id ?? base.ToString(), this.Permission);
return string.Format(
System.Globalization.CultureInfo.CurrentCulture,
"{0}: {1}",
this.Name ?? this.Id ?? base.ToString(),
this.Permission);
}
}
}
2 changes: 1 addition & 1 deletion SAM.Game/Stats/FloatStatInfo.cs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ public override object Value
get { return this.FloatValue; }
set
{
var f = float.Parse((string)value);
var f = float.Parse((string)value, System.Globalization.CultureInfo.CurrentCulture);

if ((this.Permission & 2) != 0 &&
this.FloatValue.Equals(f) == false)
2 changes: 1 addition & 1 deletion SAM.Game/Stats/IntStatInfo.cs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ public override object Value
get { return this.IntValue; }
set
{
var i = int.Parse((string)value);
var i = int.Parse((string)value, System.Globalization.CultureInfo.CurrentCulture);

if ((this.Permission & 2) != 0 &&
this.IntValue != i)
20 changes: 20 additions & 0 deletions SAM.Game/Stats/StatIsProtectedException.cs
Original file line number Diff line number Diff line change
@@ -21,10 +21,30 @@
*/

using System;
using System.Runtime.Serialization;

namespace SAM.Game.Stats
{
[Serializable]
internal class StatIsProtectedException : Exception
{
public StatIsProtectedException()
{
}

public StatIsProtectedException(string message)
: base(message)
{
}

public StatIsProtectedException(string message, Exception innerException)
: base(message, innerException)
{
}

protected StatIsProtectedException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}
13 changes: 8 additions & 5 deletions SAM.Picker/GamePicker.cs
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ private void DoDownloadList(object sender, DoWorkEventArgs e)
byte[] bytes;
using (var downloader = new WebClient())
{
bytes = downloader.DownloadData(new Uri(string.Format("http://gib.me/sam/games.xml")));
bytes = downloader.DownloadData(new Uri("http://gib.me/sam/games.xml"));
}
using (var stream = new MemoryStream(bytes, false))
{
@@ -105,7 +105,7 @@ private void DoDownloadList(object sender, DoWorkEventArgs e)
while (nodes.MoveNext())
{
string type = nodes.Current.GetAttribute("type", "");
if (type == string.Empty)
if (string.IsNullOrEmpty(type) == true)
{
type = "normal";
}
@@ -159,6 +159,7 @@ private void RefreshGames()

this._GameListView.VirtualListSize = this._FilteredGames.Count;
this._PickerStatusLabel.Text = string.Format(
CultureInfo.CurrentCulture,
"Displaying {0} games. Total {1} games.",
this._GameListView.Items.Count,
this._Games.Count);
@@ -187,17 +188,17 @@ private void OnGameListViewSearchForVirtualItem(object sender, SearchForVirtualI
return;
}

var text = e.Text.ToLowerInvariant();
var text = e.Text;
int startIndex = e.StartIndex;

Predicate<GameInfo> predicate;
/*if (e.IsPrefixSearch == true)*/
{
predicate = gi => gi.Name != null && gi.Name.ToLowerInvariant().StartsWith(e.Text);
predicate = gi => gi.Name != null && gi.Name.StartsWith(text, StringComparison.CurrentCultureIgnoreCase);
}
/*else
{
predicate = gi => gi.Name != null && gi.Name.ToLowerInvariant() == e.Text;
predicate = gi => gi.Name != null && string.Compare(gi.Name, text, StringComparison.CurrentCultureIgnoreCase) == 0;
}*/

int index;
@@ -227,6 +228,7 @@ private void DoDownloadLogo(object sender, DoWorkEventArgs e)
{
var info = (GameInfo)e.Argument;
var logoPath = string.Format(
CultureInfo.InvariantCulture,
"https://media.steamcommunity.com/steamcommunity/public/images/apps/{0}/{1}.jpg",
info.Id,
info.Logo);
@@ -283,6 +285,7 @@ private void DownloadNextLogo()
}

this._DownloadStatusLabel.Text = string.Format(
CultureInfo.CurrentCulture,
"Downloading {0} game icons...",
this._LogoQueue.Count);
this._DownloadStatusLabel.Visible = true;
12 changes: 12 additions & 0 deletions SAM.Picker/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "SAM.Picker.GamePicker.#DoDownloadLogo(System.Object,System.ComponentModel.DoWorkEventArgs)")]
[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.Control.set_Text(System.String)", Scope = "member", Target = "SAM.Picker.GamePicker.#InitializeComponent()")]
[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.Picker.Program.#Main()")]
[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.Picker.GamePicker.#OnActivateGame(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.Picker.GamePicker.#OnAddGame(System.Object,System.EventArgs)")]
[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.Picker.GamePicker.#DownloadNextLogo()")]
[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.Picker.GamePicker.#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.Picker.GamePicker.#RefreshGames()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "statusStrip", Scope = "member", Target = "SAM.Picker.GamePicker.#InitializeComponent()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "SAM.Picker.GamePicker.#.ctor(SAM.API.Client)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "SAM.Picker.GamePicker.#InitializeComponent()")]
1 change: 1 addition & 0 deletions SAM.Picker/SAM.Picker.csproj
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@
<Compile Include="GamePicker.Designer.cs">
<DependentUpon>GamePicker.cs</DependentUpon>
</Compile>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="LogoInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

0 comments on commit 407d35b

Please sign in to comment.