Skip to content

Commit 3d94d28

Browse files
committed
SuppressMessage placed near source of issues.
1 parent 88c478b commit 3d94d28

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

doc/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2013-01-22 Giacomo Stelluti Scala <[email protected]>
2+
3+
* FxCop SuppressMessage attributes placed in right place (near source of issue).
4+
15
2013-01-22 Giacomo Stelluti Scala <[email protected]>
26

37
* Refactored BaseOptionAttribute to avoid virtual member call in ctor in OptionAttribute (FxCop CA2214).

src/libcmdline/Attributes/OptionListAttribute.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ namespace CommandLine
3939
/// Must be applied to a field compatible with an <see cref="System.Collections.Generic.IList&lt;T&gt;"/> interface
4040
/// of <see cref="System.String"/> instances.
4141
/// </summary>
42-
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "The char Separator property matches shortName char constructor argument because the ShortName property is defined in BaseOptionAttribute as nullable char.")]
4342
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
4443
public sealed class OptionListAttribute : BaseOptionAttribute
4544
{
@@ -87,6 +86,8 @@ public OptionListAttribute(char shortName, string longName, char separator)
8786
/// <summary>
8887
/// Gets or sets the values separator character.
8988
/// </summary>
90-
public char Separator { get; set; }
89+
public char Separator { get;
90+
[SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "The char Separator property matches shortName char constructor argument because the ShortName property is defined in BaseOptionAttribute as nullable char.")]
91+
set; }
9192
}
9293
}

src/libcmdline/CommandLineParser.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ namespace CommandLine
4040
/// Provides methods to parse command line arguments.
4141
/// Default implementation for <see cref="CommandLine.ICommandLineParser"/>.
4242
/// </summary>
43-
44-
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "singleton", Justification = "The constructor that accepts a boolean is designed to support default singleton, the parameter is ignored.")]
4543
public partial class CommandLineParser : ICommandLineParser, IDisposable
4644
{
4745
/// <summary>
@@ -52,7 +50,7 @@ public CommandLineParser()
5250
_settings = new CommandLineParserSettings();
5351
}
5452

55-
// special constructor for singleton instance, parameter ignored
53+
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "singleton", Justification = "The constructor that accepts a boolean is designed to support default singleton, the parameter is ignored.")]
5654
private CommandLineParser(bool singleton)
5755
{
5856
_settings = new CommandLineParserSettings(false, false, Console.Error);

src/libcmdline/Internal/OptionInfo.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
#endregion
3838

3939
namespace CommandLine.Internal
40-
{
41-
42-
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "FormatException (thrown by ConvertFromString) is thrown as Exception.InnerException, so we've to catch directly System.Exception.")]
40+
{
4341
[DebuggerDisplay("ShortName = {ShortName}, LongName = {LongName}")]
4442
sealed class OptionInfo
4543
{
@@ -125,6 +123,7 @@ private bool SetValueScalar(string value, object options)
125123
return true;
126124
}
127125

126+
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "FormatException (thrown by ConvertFromString) is thrown as Exception.InnerException, so we've to catch directly System.Exception.")]
128127
private bool SetNullableValue(string value, object options)
129128
{
130129
var nc = new NullableConverter(_property.PropertyType);

0 commit comments

Comments
 (0)