Browse Source

changed StyleCop rules to not use this. prefiex, start field names with an underscore, and not to care about ordering

Signed-off-by: Marcus Cuda <marcus@cuda.net>
pull/36/head
Marcus Cuda 17 years ago
parent
commit
dbf8bbcaba
  1. 48
      src/Managed/Complex.cs
  2. 77
      src/Settings.StyleCop

48
src/Managed/Complex.cs

@ -26,14 +26,14 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using MathNet.Numerics.Properties;
namespace MathNet.Numerics namespace MathNet.Numerics
{ {
using System;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using Properties;
/// <summary> /// <summary>
/// Complex numbers class. /// Complex numbers class.
/// </summary> /// </summary>
@ -104,12 +104,12 @@ namespace MathNet.Numerics
/// <summary> /// <summary>
/// The real component of the complex number. /// The real component of the complex number.
/// </summary> /// </summary>
private readonly double real; private readonly double _real;
/// <summary> /// <summary>
/// The imaginary component of the complex number. /// The imaginary component of the complex number.
/// </summary> /// </summary>
private readonly double imag; private readonly double _imag;
#endregion fields #endregion fields
@ -123,8 +123,8 @@ namespace MathNet.Numerics
/// <param name="imaginary">The value for the imaginary component.</param> /// <param name="imaginary">The value for the imaginary component.</param>
public Complex(double real, double imaginary) public Complex(double real, double imaginary)
{ {
this.real = real; _real = real;
this.imag = imaginary; _imag = imaginary;
} }
#endregion #endregion
@ -193,7 +193,7 @@ namespace MathNet.Numerics
/// <value>The real component of the complex number.</value> /// <value>The real component of the complex number.</value>
public double Real public double Real
{ {
get { return this.real; } get { return _real; }
} }
/// <summary> /// <summary>
@ -202,7 +202,7 @@ namespace MathNet.Numerics
/// <value>The real imaginary component of the complex number.</value> /// <value>The real imaginary component of the complex number.</value>
public double Imaginary public double Imaginary
{ {
get { return this.imag; } get { return _imag; }
} }
/// <summary> /// <summary>
@ -255,7 +255,7 @@ namespace MathNet.Numerics
/// </remarks> /// </remarks>
public bool IsInfinity public bool IsInfinity
{ {
get { return double.IsInfinity(this.real) || double.IsInfinity(this.imag); } get { return double.IsInfinity(_real) || double.IsInfinity(_imag); }
} }
/// <summary> /// <summary>
@ -328,7 +328,7 @@ namespace MathNet.Numerics
/// <returns>The string representation of this complex number.</returns> /// <returns>The string representation of this complex number.</returns>
public override string ToString() public override string ToString()
{ {
return this.ToString(null, null); return ToString(null, null);
} }
/// <summary>A string representation of this complex number.</summary> /// <summary>A string representation of this complex number.</summary>
@ -339,7 +339,7 @@ namespace MathNet.Numerics
/// <param name="format">A format specification.</param> /// <param name="format">A format specification.</param>
public string ToString(string format) public string ToString(string format)
{ {
return this.ToString(format, null); return ToString(format, null);
} }
/// <summary>A string representation of this complex number.</summary> /// <summary>A string representation of this complex number.</summary>
@ -350,7 +350,7 @@ namespace MathNet.Numerics
/// <param name="formatProvider">An IFormatProvider that supplies culture-specific formatting information.</param> /// <param name="formatProvider">An IFormatProvider that supplies culture-specific formatting information.</param>
public string ToString(IFormatProvider formatProvider) public string ToString(IFormatProvider formatProvider)
{ {
return this.ToString(null, formatProvider); return ToString(null, formatProvider);
} }
/// <summary>A string representation of this complex number.</summary> /// <summary>A string representation of this complex number.</summary>
@ -364,20 +364,20 @@ namespace MathNet.Numerics
/// <param name="formatProvider">An IFormatProvider that supplies culture-specific formatting information.</param> /// <param name="formatProvider">An IFormatProvider that supplies culture-specific formatting information.</param>
public string ToString(string format, IFormatProvider formatProvider) public string ToString(string format, IFormatProvider formatProvider)
{ {
if (this.IsNaN) if (IsNaN)
{ {
return "NaN"; return "NaN";
} }
if (this.IsInfinity) if (IsInfinity)
{ {
return "Infinity"; return "Infinity";
} }
var ret = new StringBuilder(); var ret = new StringBuilder();
ret.Append(this.real.ToString(format, formatProvider)); ret.Append(_real.ToString(format, formatProvider));
if (this.imag < 0) if (_imag < 0)
{ {
ret.Append(" "); ret.Append(" ");
} }
@ -386,7 +386,7 @@ namespace MathNet.Numerics
ret.Append(" + "); ret.Append(" + ");
} }
ret.Append(this.imag.ToString(format, formatProvider)).Append("i"); ret.Append(_imag.ToString(format, formatProvider)).Append("i");
return ret.ToString(); return ret.ToString();
} }
@ -406,7 +406,7 @@ namespace MathNet.Numerics
/// <param name="other">The complex number to compare to with.</param> /// <param name="other">The complex number to compare to with.</param>
public bool Equals(Complex other) public bool Equals(Complex other)
{ {
return this.Real == other.Real && this.Imaginary == other.Imaginary; return Real == other.Real && Imaginary == other.Imaginary;
} }
/// <summary>The hash code for the complex number.</summary> /// <summary>The hash code for the complex number.</summary>
@ -417,7 +417,7 @@ namespace MathNet.Numerics
/// </remarks> /// </remarks>
public override int GetHashCode() public override int GetHashCode()
{ {
return this.real.GetHashCode() ^ (-this.imag.GetHashCode()); return _real.GetHashCode() ^ (-_imag.GetHashCode());
} }
/// <summary> /// <summary>
@ -431,7 +431,7 @@ namespace MathNet.Numerics
/// <param name="obj">The complex number to compare to with.</param> /// <param name="obj">The complex number to compare to with.</param>
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
return (obj is Complex) && this.Equals((Complex) obj); return (obj is Complex) && Equals((Complex)obj);
} }
#endregion #endregion

77
src/Settings.StyleCop

@ -1 +1,76 @@
<StyleCopSettings Version="4.3" /> <StyleCopSettings Version="4.3">
<Parsers>
<Parser ParserId="Microsoft.StyleCop.CSharp.CsParser">
<ParserSettings>
<BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty>
</ParserSettings>
</Parser>
</Parsers>
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustAppearInTheCorrectOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeOrderedByAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticElementsMustAppearBeforeInstanceElements">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DeclarationKeywordsMustFollowOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ProtectedMustComeBeforeInternal">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertyAccessorsMustFollowOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EventAccessorsMustFollowOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="PrefixLocalCallsWithThis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
<Rules>
<Rule Name="FieldNamesMustNotBeginWithUnderscore">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
Loading…
Cancel
Save