Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit 49d61ca

Browse files
committed
Apply StyleCop.Analyzers and fix issues
Some issues are suppressed to fix later.
1 parent e8c31a9 commit 49d61ca

39 files changed

+292
-107
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ sql
107107
TestResults
108108
*.Cache
109109
ClientBin
110-
stylecop.*
111110
~$*
112111
*.dbmdl
113112
Generated_Code #added for RIA/Silverlight projects

src/GitLink/Exceptions/GitLinkException.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="GitLinkException.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using System;

src/GitLink/Extensions/BinaryReaderExtensions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="BinaryReaderExtensions.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using System;

src/GitLink/Extensions/PdbExtensions.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="PdbExtensions.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using System;
@@ -39,7 +38,7 @@ public static IReadOnlyDictionary<string, byte[]> GetFilesAndChecksums(this PdbF
3938
{
4039
Argument.IsNotNull(() => pdbFile);
4140

42-
//const int LastInterestingByte = 47;
41+
// const int LastInterestingByte = 47;
4342
const string FileIndicator = "/src/files/";
4443

4544
var values = pdbFile.Info.NameToPdbName.Values;

src/GitLink/Extensions/RepositoryExtensions.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace GitLink
1+
// <copyright file="RepositoryExtensions.cs" company="CatenaLogic">
2+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
3+
// </copyright>
4+
5+
namespace GitLink
26
{
37
using System;
48
using System.Collections.Generic;

src/GitLink/Extensions/StringExtensions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="StringExtensions.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using Catel;

src/GitLink/GitLink.csproj

+12-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
<WarningLevel>4</WarningLevel>
2424
<Prefer32Bit>false</Prefer32Bit>
2525
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
26-
<DocumentationFile>
27-
</DocumentationFile>
26+
<DocumentationFile>..\..\bin\Debug\GitLink\GitLink.XML</DocumentationFile>
27+
<CodeAnalysisRuleSet>GitLink.ruleset</CodeAnalysisRuleSet>
28+
<NoWarn>CS1591</NoWarn>
2829
</PropertyGroup>
2930
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3031
<DebugType>pdbonly</DebugType>
@@ -35,8 +36,9 @@
3536
<WarningLevel>4</WarningLevel>
3637
<Prefer32Bit>false</Prefer32Bit>
3738
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
38-
<DocumentationFile>
39-
</DocumentationFile>
39+
<DocumentationFile>..\..\bin\Release\GitLink\GitLink.XML</DocumentationFile>
40+
<CodeAnalysisRuleSet>GitLink.ruleset</CodeAnalysisRuleSet>
41+
<NoWarn>CS1591</NoWarn>
4042
</PropertyGroup>
4143
<PropertyGroup>
4244
<StartupObject>GitLink.Program</StartupObject>
@@ -88,19 +90,23 @@
8890
<Compile Include="Providers\VisualStudioTeamServicesProvider.cs" />
8991
</ItemGroup>
9092
<ItemGroup>
93+
<None Include="GitLink.ruleset" />
9194
<None Include="pdbstr.exe">
9295
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
9396
</None>
9497
<None Include="winsdk.redist.txt">
9598
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
9699
</None>
97-
<Content Include="Logo.ico" />
100+
<None Include="project.json" />
98101
</ItemGroup>
99102
<ItemGroup>
100-
<None Include="project.json" />
103+
<Content Include="Logo.ico" />
101104
</ItemGroup>
102105
<ItemGroup>
103106
<Folder Include="Icons\" />
104107
</ItemGroup>
108+
<ItemGroup>
109+
<AdditionalFiles Include="stylecop.json" />
110+
</ItemGroup>
105111
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
106112
</Project>

src/GitLink/GitLink.ruleset

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. It is recommended to include this rule set in any custom rule set you create for your projects." ToolsVersion="10.0">
3+
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
4+
<Name Resource="MinimumRecommendedRules_Name" />
5+
<Description Resource="MinimumRecommendedRules_Description" />
6+
</Localization>
7+
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
8+
<Rule Id="CA1001" Action="Warning" />
9+
<Rule Id="CA1009" Action="Warning" />
10+
<Rule Id="CA1016" Action="Warning" />
11+
<Rule Id="CA1033" Action="Warning" />
12+
<Rule Id="CA1049" Action="Warning" />
13+
<Rule Id="CA1060" Action="Warning" />
14+
<Rule Id="CA1061" Action="Warning" />
15+
<Rule Id="CA1063" Action="Warning" />
16+
<Rule Id="CA1065" Action="Warning" />
17+
<Rule Id="CA1301" Action="Warning" />
18+
<Rule Id="CA1400" Action="Warning" />
19+
<Rule Id="CA1401" Action="Warning" />
20+
<Rule Id="CA1403" Action="Warning" />
21+
<Rule Id="CA1404" Action="Warning" />
22+
<Rule Id="CA1405" Action="Warning" />
23+
<Rule Id="CA1410" Action="Warning" />
24+
<Rule Id="CA1415" Action="Warning" />
25+
<Rule Id="CA1821" Action="Warning" />
26+
<Rule Id="CA1900" Action="Warning" />
27+
<Rule Id="CA1901" Action="Warning" />
28+
<Rule Id="CA2002" Action="Warning" />
29+
<Rule Id="CA2100" Action="Warning" />
30+
<Rule Id="CA2101" Action="Warning" />
31+
<Rule Id="CA2108" Action="Warning" />
32+
<Rule Id="CA2111" Action="Warning" />
33+
<Rule Id="CA2112" Action="Warning" />
34+
<Rule Id="CA2114" Action="Warning" />
35+
<Rule Id="CA2116" Action="Warning" />
36+
<Rule Id="CA2117" Action="Warning" />
37+
<Rule Id="CA2122" Action="Warning" />
38+
<Rule Id="CA2123" Action="Warning" />
39+
<Rule Id="CA2124" Action="Warning" />
40+
<Rule Id="CA2126" Action="Warning" />
41+
<Rule Id="CA2131" Action="Warning" />
42+
<Rule Id="CA2132" Action="Warning" />
43+
<Rule Id="CA2133" Action="Warning" />
44+
<Rule Id="CA2134" Action="Warning" />
45+
<Rule Id="CA2137" Action="Warning" />
46+
<Rule Id="CA2138" Action="Warning" />
47+
<Rule Id="CA2140" Action="Warning" />
48+
<Rule Id="CA2141" Action="Warning" />
49+
<Rule Id="CA2146" Action="Warning" />
50+
<Rule Id="CA2147" Action="Warning" />
51+
<Rule Id="CA2149" Action="Warning" />
52+
<Rule Id="CA2200" Action="Warning" />
53+
<Rule Id="CA2202" Action="Warning" />
54+
<Rule Id="CA2207" Action="Warning" />
55+
<Rule Id="CA2212" Action="Warning" />
56+
<Rule Id="CA2213" Action="Warning" />
57+
<Rule Id="CA2214" Action="Warning" />
58+
<Rule Id="CA2216" Action="Warning" />
59+
<Rule Id="CA2220" Action="Warning" />
60+
<Rule Id="CA2229" Action="Warning" />
61+
<Rule Id="CA2231" Action="Warning" />
62+
<Rule Id="CA2232" Action="Warning" />
63+
<Rule Id="CA2235" Action="Warning" />
64+
<Rule Id="CA2236" Action="Warning" />
65+
<Rule Id="CA2237" Action="Warning" />
66+
<Rule Id="CA2238" Action="Warning" />
67+
<Rule Id="CA2240" Action="Warning" />
68+
<Rule Id="CA2241" Action="Warning" />
69+
<Rule Id="CA2242" Action="Warning" />
70+
</Rules>
71+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
72+
<Rule Id="SA1101" Action="Hidden" />
73+
<Rule Id="SA1507" Action="Hidden" />
74+
<Rule Id="SA1202" Action="Hidden" />
75+
<Rule Id="SA1201" Action="Hidden" />
76+
<Rule Id="SA1124" Action="Hidden" />
77+
<Rule Id="SA1309" Action="Hidden" />
78+
<Rule Id="SA1600" Action="Hidden" />
79+
<Rule Id="SA1121" Action="Hidden" />
80+
<Rule Id="SA1214" Action="Hidden" />
81+
<Rule Id="SA1203" Action="Hidden" />
82+
</Rules>
83+
</RuleSet>

src/GitLink/Helpers/PdbStrHelper.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="PdbStrHelper.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using System.Diagnostics;

src/GitLink/LinkMethod.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright file="Linker.cs" company="Andrew Arnott">
3-
// Copyright (c) 2016 Andrew Arnott. All rights reserved.
2+
// <copyright file="LinkMethod.cs" company="CatenaLogic">
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

src/GitLink/LinkOptions.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace GitLink
1+
// <copyright file="LinkOptions.cs" company="CatenaLogic">
2+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
3+
// </copyright>
4+
5+
namespace GitLink
26
{
37
using System;
48
using System.Collections.Generic;

src/GitLink/Linker.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
2-
// <copyright file="Linker.cs" company="Andrew Arnott">
3-
// Copyright (c) 2016 Andrew Arnott. All rights reserved.
2+
// <copyright file="Linker.cs" company="CatenaLogic">
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink
98
{
109
using System;

src/GitLink/Logging/OutputLogListener.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="OutputLogListener.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink.Logging
98
{
109
using System;

src/GitLink/Pdb/Crypto.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// --------------------------------------------------------------------------------------------------------------------
22
// <copyright file="Crypto.cs" company="CatenaLogic">
3-
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
3+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
44
// </copyright>
55
// --------------------------------------------------------------------------------------------------------------------
66

7-
87
namespace GitLink.Pdb
98
{
109
using System;

src/GitLink/Pdb/PdbFile.cs

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace GitLink.Pdb
1+
// <copyright file="PdbFile.cs" company="CatenaLogic">
2+
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
3+
// </copyright>
4+
5+
namespace GitLink.Pdb
26
{
37
using System;
48
using System.Collections.Generic;
@@ -31,7 +35,7 @@ public PdbFile(string path)
3135
Argument.IsNotNullOrWhitespace(() => path);
3236

3337
Path = path;
34-
38+
3539
_fs = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
3640
_br = new BinaryReader(_fs, Encoding.UTF8, true);
3741
_bw = new BinaryWriter(_fs, Encoding.UTF8, true);
@@ -88,6 +92,7 @@ private void CheckPdbHeader()
8892
private void ReadPdbHeader()
8993
{
9094
// TODO: Create PdbHeader struct
95+
//// code here
9196

9297
_pageByteCount = _br.ReadInt32(); // 0x20
9398
PagesFree = _br.ReadInt32(); // 0x24 TODO not sure meaning
@@ -102,14 +107,20 @@ private void CheckPdb()
102107
var length = _fs.Length;
103108
if (length % _pageByteCount != 0)
104109
{
105-
throw Log.ErrorAndCreateException<GitLinkException>("pdb length {0} bytes per page <> 0, {1}, {2}", length, _pageByteCount,
110+
throw Log.ErrorAndCreateException<GitLinkException>(
111+
"pdb length {0} bytes per page <> 0, {1}, {2}",
112+
length,
113+
_pageByteCount,
106114
PageCount);
107115
}
108116

109117
if (length / _pageByteCount != PageCount)
110118
{
111-
throw Log.ErrorAndCreateException<GitLinkException>("pdb length does not match page count, length: {0}, bytes per page: {1}, page count: {2}",
112-
length, _pageByteCount, PageCount);
119+
throw Log.ErrorAndCreateException<GitLinkException>(
120+
"pdb length does not match page count, length: {0}, bytes per page: {1}, page count: {2}",
121+
length,
122+
_pageByteCount,
123+
PageCount);
113124
}
114125
}
115126

@@ -215,7 +226,7 @@ private byte[] ReadStreamBytes(PdbStream stream)
215226
}
216227

217228
var j = pages.Length - 1;
218-
ReadPage(bytes, pages[j], j * _pageByteCount, (stream.ByteCount - j * _pageByteCount));
229+
ReadPage(bytes, pages[j], j * _pageByteCount, stream.ByteCount - (j * _pageByteCount));
219230
}
220231

221232
return bytes;
@@ -240,7 +251,8 @@ private PdbInfo InternalInfo()
240251
var root = GetRoot();
241252
if (root.Streams.Count <= 1)
242253
{
243-
throw Log.ErrorAndCreateException<GitLinkException>("Expected at least 2 streams inside the pdb root, but only found '{0}', cannot read pdb info",
254+
throw Log.ErrorAndCreateException<GitLinkException>(
255+
"Expected at least 2 streams inside the pdb root, but only found '{0}', cannot read pdb info",
244256
root.Streams.Count);
245257
}
246258

@@ -295,7 +307,7 @@ private PdbInfo InternalInfo()
295307
}
296308

297309
var tailByteCount = GetRoot().Streams[1].ByteCount - br.BaseStream.Position;
298-
info.Tail = br.ReadBytes((int) tailByteCount);
310+
info.Tail = br.ReadBytes((int)tailByteCount);
299311

300312
foreach (var tuple in positions)
301313
{

0 commit comments

Comments
 (0)