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

Commit

Permalink
Apply StyleCop.Analyzers and fix issues
Browse files Browse the repository at this point in the history
Some issues are suppressed to fix later.
  • Loading branch information
AArnott committed Oct 9, 2016
1 parent e8c31a9 commit 49d61ca
Show file tree
Hide file tree
Showing 39 changed files with 292 additions and 107 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ sql
TestResults
*.Cache
ClientBin
stylecop.*
~$*
*.dbmdl
Generated_Code #added for RIA/Silverlight projects
Expand Down
3 changes: 1 addition & 2 deletions src/GitLink/Exceptions/GitLinkException.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GitLinkException.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System;
Expand Down
3 changes: 1 addition & 2 deletions src/GitLink/Extensions/BinaryReaderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BinaryReaderExtensions.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System;
Expand Down
5 changes: 2 additions & 3 deletions src/GitLink/Extensions/PdbExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PdbExtensions.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System;
Expand Down Expand Up @@ -39,7 +38,7 @@ public static IReadOnlyDictionary<string, byte[]> GetFilesAndChecksums(this PdbF
{
Argument.IsNotNull(() => pdbFile);

//const int LastInterestingByte = 47;
// const int LastInterestingByte = 47;
const string FileIndicator = "/src/files/";

var values = pdbFile.Info.NameToPdbName.Values;
Expand Down
6 changes: 5 additions & 1 deletion src/GitLink/Extensions/RepositoryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace GitLink
// <copyright file="RepositoryExtensions.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>

namespace GitLink
{
using System;
using System.Collections.Generic;
Expand Down
3 changes: 1 addition & 2 deletions src/GitLink/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StringExtensions.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using Catel;
Expand Down
18 changes: 12 additions & 6 deletions src/GitLink/GitLink.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile>..\..\bin\Debug\GitLink\GitLink.XML</DocumentationFile>
<CodeAnalysisRuleSet>GitLink.ruleset</CodeAnalysisRuleSet>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -35,8 +36,9 @@
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>
</DocumentationFile>
<DocumentationFile>..\..\bin\Release\GitLink\GitLink.XML</DocumentationFile>
<CodeAnalysisRuleSet>GitLink.ruleset</CodeAnalysisRuleSet>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<StartupObject>GitLink.Program</StartupObject>
Expand Down Expand Up @@ -88,19 +90,23 @@
<Compile Include="Providers\VisualStudioTeamServicesProvider.cs" />
</ItemGroup>
<ItemGroup>
<None Include="GitLink.ruleset" />
<None Include="pdbstr.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="winsdk.redist.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Logo.ico" />
<None Include="project.json" />
</ItemGroup>
<ItemGroup>
<None Include="project.json" />
<Content Include="Logo.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Icons\" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="stylecop.json" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
83 changes: 83 additions & 0 deletions src/GitLink/GitLink.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<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">
<Localization ResourceAssembly="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.dll" ResourceBaseName="Microsoft.VisualStudio.CodeAnalysis.RuleSets.Strings.Localized">
<Name Resource="MinimumRecommendedRules_Name" />
<Description Resource="MinimumRecommendedRules_Description" />
</Localization>
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1101" Action="Hidden" />
<Rule Id="SA1507" Action="Hidden" />
<Rule Id="SA1202" Action="Hidden" />
<Rule Id="SA1201" Action="Hidden" />
<Rule Id="SA1124" Action="Hidden" />
<Rule Id="SA1309" Action="Hidden" />
<Rule Id="SA1600" Action="Hidden" />
<Rule Id="SA1121" Action="Hidden" />
<Rule Id="SA1214" Action="Hidden" />
<Rule Id="SA1203" Action="Hidden" />
</Rules>
</RuleSet>
3 changes: 1 addition & 2 deletions src/GitLink/Helpers/PdbStrHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PdbStrHelper.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System.Diagnostics;
Expand Down
4 changes: 2 additions & 2 deletions src/GitLink/LinkMethod.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Linker.cs" company="Andrew Arnott">
// Copyright (c) 2016 Andrew Arnott. All rights reserved.
// <copyright file="LinkMethod.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
6 changes: 5 additions & 1 deletion src/GitLink/LinkOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace GitLink
// <copyright file="LinkOptions.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>

namespace GitLink
{
using System;
using System.Collections.Generic;
Expand Down
5 changes: 2 additions & 3 deletions src/GitLink/Linker.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Linker.cs" company="Andrew Arnott">
// Copyright (c) 2016 Andrew Arnott. All rights reserved.
// <copyright file="Linker.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink
{
using System;
Expand Down
3 changes: 1 addition & 2 deletions src/GitLink/Logging/OutputLogListener.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OutputLogListener.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink.Logging
{
using System;
Expand Down
3 changes: 1 addition & 2 deletions src/GitLink/Pdb/Crypto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Crypto.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2014 CatenaLogic. All rights reserved.
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------


namespace GitLink.Pdb
{
using System;
Expand Down
28 changes: 20 additions & 8 deletions src/GitLink/Pdb/PdbFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace GitLink.Pdb
// <copyright file="PdbFile.cs" company="CatenaLogic">
// Copyright (c) 2014 - 2016 CatenaLogic. All rights reserved.
// </copyright>

namespace GitLink.Pdb
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -31,7 +35,7 @@ public PdbFile(string path)
Argument.IsNotNullOrWhitespace(() => path);

Path = path;

_fs = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
_br = new BinaryReader(_fs, Encoding.UTF8, true);
_bw = new BinaryWriter(_fs, Encoding.UTF8, true);
Expand Down Expand Up @@ -88,6 +92,7 @@ private void CheckPdbHeader()
private void ReadPdbHeader()
{
// TODO: Create PdbHeader struct
//// code here

_pageByteCount = _br.ReadInt32(); // 0x20
PagesFree = _br.ReadInt32(); // 0x24 TODO not sure meaning
Expand All @@ -102,14 +107,20 @@ private void CheckPdb()
var length = _fs.Length;
if (length % _pageByteCount != 0)
{
throw Log.ErrorAndCreateException<GitLinkException>("pdb length {0} bytes per page <> 0, {1}, {2}", length, _pageByteCount,
throw Log.ErrorAndCreateException<GitLinkException>(
"pdb length {0} bytes per page <> 0, {1}, {2}",
length,
_pageByteCount,
PageCount);
}

if (length / _pageByteCount != PageCount)
{
throw Log.ErrorAndCreateException<GitLinkException>("pdb length does not match page count, length: {0}, bytes per page: {1}, page count: {2}",
length, _pageByteCount, PageCount);
throw Log.ErrorAndCreateException<GitLinkException>(
"pdb length does not match page count, length: {0}, bytes per page: {1}, page count: {2}",
length,
_pageByteCount,
PageCount);
}
}

Expand Down Expand Up @@ -215,7 +226,7 @@ private byte[] ReadStreamBytes(PdbStream stream)
}

var j = pages.Length - 1;
ReadPage(bytes, pages[j], j * _pageByteCount, (stream.ByteCount - j * _pageByteCount));
ReadPage(bytes, pages[j], j * _pageByteCount, stream.ByteCount - (j * _pageByteCount));
}

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

Expand Down Expand Up @@ -295,7 +307,7 @@ private PdbInfo InternalInfo()
}

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

foreach (var tuple in positions)
{
Expand Down
Loading

0 comments on commit 49d61ca

Please sign in to comment.