Skip to content

Commit 03e90ee

Browse files
committed
convert to VS2010 project. clean up almost all inspections/warnings reported by ReSharper 5.0. clean up a number of FxCop and Gendarme warnings. Next up: convert the old-style NUnit asserts to the (not so) new assertion syntax, unless someone beats me to it.
1 parent 7943413 commit 03e90ee

38 files changed

+385
-209
lines changed

AbstractBuffer.cs

+22-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@ public sealed class AbstractBuffer
1414

1515
public AbstractBuffer(AbstractValue[] values)
1616
{
17+
if (null == values)
18+
{
19+
throw new ArgumentNullException("values");
20+
}
21+
1722
storage = values;
1823
Length = storage.Length;
1924
}
2025

2126
public AbstractBuffer(AbstractBuffer other)
2227
{
28+
if (null == other)
29+
{
30+
throw new ArgumentNullException("other");
31+
}
32+
2333
BaseIndex = other.BaseIndex;
2434
Length = other.Length;
2535
storage = new AbstractValue[other.storage.Length];
@@ -37,7 +47,7 @@ public AbstractValue this[Int32 index]
3747
// We check this.storage.Length as well so that we aren't calling Extend() when we dont need to.
3848
if (IsIndexPastBounds(index))
3949
{
40-
Extend(BaseIndex + (UInt32) index);
50+
Extend(BaseIndex + (UInt32)index);
4151
return storage[BaseIndex + index];
4252
}
4353

@@ -46,14 +56,19 @@ public AbstractValue this[Int32 index]
4656

4757
set
4858
{
59+
if (value == null)
60+
{
61+
throw new ArgumentNullException("value");
62+
}
63+
4964
if ((BaseIndex + index) >= Length)
5065
{
5166
value.IsOutOfBounds = true;
5267
}
5368

5469
if (IsIndexPastBounds(index))
5570
{
56-
Extend(BaseIndex + (UInt32) index);
71+
Extend(BaseIndex + (UInt32)index);
5772
storage[BaseIndex + index] = value;
5873
}
5974
else
@@ -65,6 +80,11 @@ public AbstractValue this[Int32 index]
6580

6681
public AbstractBuffer DoOperation(OperatorEffect operatorEffect, AbstractValue rhs)
6782
{
83+
if (null == rhs)
84+
{
85+
throw new ArgumentNullException("rhs");
86+
}
87+
6888
var lhs = this;
6989

7090
// TODO: should have a guard for if rhs isn't a pointer

AbstractBufferTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void Copy()
2727
}
2828

2929
[Test]
30-
[ExpectedException(typeof (ArgumentOutOfRangeException))]
30+
[ExpectedException(typeof(ArgumentOutOfRangeException))]
3131
public void InvalidPointerAnd()
3232
{
3333
var one = new AbstractValue(0x1);
@@ -112,7 +112,7 @@ public void PointerAssignment()
112112
{
113113
var values = AbstractValue.GetNewBuffer(4);
114114
var buffer = new AbstractBuffer(values);
115-
var assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, null);
115+
var assignedBuffer = buffer.DoOperation(OperatorEffect.Assignment, AbstractValue.Zero);
116116
Assert.AreNotSame(buffer, assignedBuffer);
117117
}
118118

@@ -200,14 +200,14 @@ public void PointerSub()
200200
}
201201

202202
[Test]
203-
[ExpectedException(typeof (ArgumentOutOfRangeException))]
203+
[ExpectedException(typeof(ArgumentOutOfRangeException))]
204204
public void PointerSubUnderflow()
205205
{
206206
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Sub, new AbstractValue(1));
207207
}
208208

209209
[Test]
210-
[ExpectedException(typeof (ArgumentException))]
210+
[ExpectedException(typeof(ArgumentException))]
211211
public void PointerUnknownOperation()
212212
{
213213
new AbstractBuffer(new AbstractValue[] {}).DoOperation(OperatorEffect.Unknown, null);

AbstractValue.cs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public sealed class AbstractValue
1313
{
1414
public const UInt32 MAX_BUFFER_SIZE = 25600000;
1515
public const UInt32 UNKNOWN = 0xb4dc0d3d;
16+
private static readonly AbstractValue zero = new AbstractValue(0);
1617
private readonly AbstractBuffer pointsTo;
1718
private readonly UInt32 storage;
1819
private Boolean tainted;
@@ -95,6 +96,11 @@ public Boolean IsPointer
9596
get { return pointsTo != null; }
9697
}
9798

99+
public static AbstractValue Zero
100+
{
101+
get { return zero; }
102+
}
103+
98104
public static AbstractValue[] GetNewBuffer(UInt32 size)
99105
{
100106
if (size > MAX_BUFFER_SIZE)

AbstractValueTest.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void AddTaintIf()
4040
}
4141

4242
[Test]
43-
[ExpectedException(typeof (InvalidOperationException))]
43+
[ExpectedException(typeof(InvalidOperationException))]
4444
public void AddTaintOnPointer()
4545
{
4646
buffer = new AbstractBuffer(AbstractValue.GetNewBuffer(1));
@@ -68,7 +68,7 @@ public void AssignmentAtEnd()
6868
}
6969

7070
[Test]
71-
[ExpectedException(typeof (ArgumentException))]
71+
[ExpectedException(typeof(ArgumentException))]
7272
public void EmptyBuffer()
7373
{
7474
pointer = new AbstractValue(new AbstractBuffer(new AbstractValue[] {}));
@@ -88,6 +88,18 @@ public void Initialized()
8888
Assert.AreEqual(0xabcdef, uninit.Value);
8989
}
9090

91+
[Test]
92+
public void IsOutOfBoundsPropertySurviviesCopy()
93+
{
94+
var src = new AbstractValue(0x31337)
95+
{
96+
IsOutOfBounds = true
97+
};
98+
var dest = new AbstractValue(src);
99+
100+
Assert.IsTrue(dest.IsOutOfBounds);
101+
}
102+
91103
[Test]
92104
public void NoPointer()
93105
{
@@ -108,10 +120,10 @@ public void NotInitialized()
108120
}
109121

110122
[Test]
111-
[ExpectedException(typeof (ArgumentNullException))]
123+
[ExpectedException(typeof(ArgumentNullException))]
112124
public void NullCopyCtor()
113125
{
114-
pointer = new AbstractValue((AbstractValue) null);
126+
pointer = new AbstractValue((AbstractValue)null);
115127
}
116128

117129
[Test]
@@ -167,19 +179,7 @@ public void PointerPointerPointer()
167179
}
168180

169181
[Test]
170-
public void IsOutOfBoundsPropertySurviviesCopy()
171-
{
172-
var src = new AbstractValue(0x31337)
173-
{
174-
IsOutOfBounds = true
175-
};
176-
var dest = new AbstractValue(src);
177-
178-
Assert.IsTrue(dest.IsOutOfBounds);
179-
}
180-
181-
[Test]
182-
[ExpectedException(typeof (ArgumentOutOfRangeException))]
182+
[ExpectedException(typeof(ArgumentOutOfRangeException))]
183183
public void RequestedBufferTooLarge()
184184
{
185185
AbstractValue.GetNewBuffer(AbstractValue.MAX_BUFFER_SIZE + 1);
@@ -194,7 +194,7 @@ public void TruncateValue()
194194
}
195195

196196
[Test]
197-
[ExpectedException(typeof (ArgumentException))]
197+
[ExpectedException(typeof(ArgumentException))]
198198
public void ZeroSizeBuffer()
199199
{
200200
pointer = new AbstractValue(new AbstractValue[] {});

AnalysisEngine.csproj

+62-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
23
<PropertyGroup>
34
<ProjectGuid>{8DC8856B-6FF9-4E39-BF0B-1C1B55115273}</ProjectGuid>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -16,7 +17,24 @@
1617
</FileUpgradeFlags>
1718
<UpgradeBackupLocation>
1819
</UpgradeBackupLocation>
19-
<OldToolsVersion>2.0</OldToolsVersion>
20+
<OldToolsVersion>3.5</OldToolsVersion>
21+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
22+
<PublishUrl>publish\</PublishUrl>
23+
<Install>true</Install>
24+
<InstallFrom>Disk</InstallFrom>
25+
<UpdateEnabled>false</UpdateEnabled>
26+
<UpdateMode>Foreground</UpdateMode>
27+
<UpdateInterval>7</UpdateInterval>
28+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
29+
<UpdatePeriodically>false</UpdatePeriodically>
30+
<UpdateRequired>false</UpdateRequired>
31+
<MapFileExtensions>true</MapFileExtensions>
32+
<ApplicationRevision>0</ApplicationRevision>
33+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
34+
<IsWebBootstrapper>false</IsWebBootstrapper>
35+
<UseApplicationTrust>false</UseApplicationTrust>
36+
<BootstrapperEnabled>true</BootstrapperEnabled>
37+
<TargetFrameworkProfile />
2038
</PropertyGroup>
2139
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
2240
<OutputPath>bin\Debug\</OutputPath>
@@ -40,6 +58,16 @@
4058
<PlatformTarget>AnyCPU</PlatformTarget>
4159
<FileAlignment>4096</FileAlignment>
4260
</PropertyGroup>
61+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
62+
<CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
63+
<CodeAnalysisRules />
64+
<Optimize>true</Optimize>
65+
</PropertyGroup>
66+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
67+
<CodeAnalysisRuleSet>Migrated rules for AnalysisEngine.ruleset</CodeAnalysisRuleSet>
68+
<CodeAnalysisRules />
69+
<Optimize>true</Optimize>
70+
</PropertyGroup>
4371
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
4472
<ItemGroup>
4573
<Reference Include="nunit.framework">
@@ -61,13 +89,16 @@
6189
<Compile Include="Analyzer.cs" />
6290
<Compile Include="AnalyzerTest.cs" />
6391
<Compile Include="BitMathTest.cs" />
92+
<Compile Include="Block.cs" />
6493
<Compile Include="Contract.cs" />
6594
<Compile Include="CoverageExcludeAttribute.cs" />
95+
<Compile Include="DifferenceEngineTest.cs" />
6696
<Compile Include="DumpFileParserTest.cs" />
6797
<Compile Include="ElfFileParser.cs" />
6898
<Compile Include="ElfFileParserTest.cs" />
6999
<Compile Include="GLibcStartMainContract.cs" />
70100
<Compile Include="GLibcStartMainContractTest.cs" />
101+
<Compile Include="GlobalSuppressions.cs" />
71102
<Compile Include="InvalidOpcodeException.cs" />
72103
<Compile Include="MachineStateTest.cs" />
73104
<Compile Include="MallocContract.cs" />
@@ -80,6 +111,11 @@
80111
<Compile Include="MachineState.cs" />
81112
<Compile Include="ModRM.cs" />
82113
<Compile Include="Opcode.cs" />
114+
<Compile Include="Properties\Settings.Designer.cs">
115+
<AutoGen>True</AutoGen>
116+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
117+
<DependentUpon>Settings.settings</DependentUpon>
118+
</Compile>
83119
<Compile Include="X86Emulator.cs" />
84120
<Compile Include="X86EmulatorTest.cs" />
85121
<Compile Include="X86OpcodeTest.cs" />
@@ -91,4 +127,28 @@
91127
<Compile Include="SIBTests.cs" />
92128
<Compile Include="X86Opcode.cs" />
93129
</ItemGroup>
130+
<ItemGroup>
131+
<None Include="Migrated rules for AnalysisEngine.ruleset" />
132+
<None Include="Properties\Settings.settings">
133+
<Generator>SettingsSingleFileGenerator</Generator>
134+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
135+
</None>
136+
</ItemGroup>
137+
<ItemGroup>
138+
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
139+
<Visible>False</Visible>
140+
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
141+
<Install>false</Install>
142+
</BootstrapperPackage>
143+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
144+
<Visible>False</Visible>
145+
<ProductName>.NET Framework 3.5 SP1</ProductName>
146+
<Install>true</Install>
147+
</BootstrapperPackage>
148+
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
149+
<Visible>False</Visible>
150+
<ProductName>Windows Installer 3.1</ProductName>
151+
<Install>true</Install>
152+
</BootstrapperPackage>
153+
</ItemGroup>
94154
</Project>

Analyzer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected ReportCollection ReportItems
103103

104104
public void Run()
105105
{
106-
var machineState = new MachineState(GetRegistersForLinuxStart())
106+
var machineState = new MachineState(createRegistersForLinuxStart())
107107
{
108108
InstructionPointer = parser.EntryPointAddress
109109
};
@@ -136,7 +136,7 @@ protected virtual MachineState RunCode(MachineState _machineState, Byte[] code)
136136
return X86Emulator.Run(reportItems, _machineState, code);
137137
}
138138

139-
private static RegisterCollection GetRegistersForLinuxStart()
139+
private static RegisterCollection createRegistersForLinuxStart()
140140
{
141141
var linuxMainDefaultValues = new RegisterCollection();
142142

AnalyzerTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void Dispose()
2929

3030
private IParsable CreateMockParser(UInt32 expectedReportItemCount)
3131
{
32-
var control = new DynamicMock(typeof (IParsable));
32+
var control = new DynamicMock(typeof(IParsable));
3333
control.ExpectAndReturn("GetBytes", code, null);
3434

3535
var reportItemList = new List<ReportItem>();
@@ -61,7 +61,7 @@ protected override MachineState RunCode(MachineState machineState, Byte[] instru
6161
ReportItems.Add(new ReportItem(i, false));
6262
}
6363

64-
machineState.InstructionPointer += (UInt32) instructionBytes.Length;
64+
machineState.InstructionPointer += (UInt32)instructionBytes.Length;
6565

6666
return machineState;
6767
}
@@ -77,7 +77,7 @@ public void NoReportItems()
7777
}
7878

7979
[Test]
80-
[ExpectedException(typeof (ArgumentNullException))]
80+
[ExpectedException(typeof(ArgumentNullException))]
8181
public void NullStream()
8282
{
8383
analyzer = new Analyzer(null);

AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
// You can specify all values by your own or you can build default build and revision
1818

1919
[assembly: AssemblyVersion("0.1.*")]
20-
[assembly: CLSCompliant(true)]
20+
[assembly: CLSCompliant(false)]

BitMath.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static UInt32 BytesToDword(Byte[] data, Byte index)
2525

2626
for (var i = 0; i < DWORD_SIZE; ++i)
2727
{
28-
result |= (UInt32) data[i + index] << (8 * i);
28+
result |= (UInt32)data[i + index] << (8*i);
2929
}
3030

3131
return result;

BitMathTest.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public void AllZeroes()
2020
}
2121

2222
[Test]
23-
[ExpectedException(typeof (ArgumentException))]
23+
[ExpectedException(typeof(ArgumentException))]
2424
public void EmptyBytes()
2525
{
2626
BitMath.BytesToDword(new Byte[] {}, 0);
2727
}
2828

2929
[Test]
30-
[ExpectedException(typeof (ArgumentException))]
30+
[ExpectedException(typeof(ArgumentException))]
3131
public void NotEnoughBytesToDwordAtNonZeroIndex()
3232
{
3333
BitMath.BytesToDword(new Byte[] {0, 1, 2, 3}, 1);
3434
}
3535

3636
[Test]
37-
[ExpectedException(typeof (ArgumentException))]
37+
[ExpectedException(typeof(ArgumentException))]
3838
public void NotEnoughBytesToDwordAtZeroIndex()
3939
{
4040
BitMath.BytesToDword(new Byte[] {0}, 0);

0 commit comments

Comments
 (0)