-
-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix some (lots of) issues reported by analyzers. (#1125)
Fix some (lots of) issues reported by analyzers.
- Loading branch information
Showing
251 changed files
with
7,541 additions
and
4,090 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project> | ||
<Import Project="$(MSBuildThisFileFullPath).user" Condition="Exists('$(MSBuildThisFileFullPath).user')" /> | ||
|
||
<!-- | ||
Assembly Info properties that apply to all projects/assemblies. | ||
--> | ||
<PropertyGroup> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)src\Renci.SshNet.snk</AssemblyOriginatorKeyFile> | ||
<GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
<LangVersion>latest</LangVersion> | ||
<!-- | ||
<WarningLevel>9999</WarningLevel> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
--> | ||
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Code analysis properties. | ||
--> | ||
<PropertyGroup> | ||
<EnableNETAnalyzers>false</EnableNETAnalyzers> | ||
<AnalysisLevel>preview-All</AnalysisLevel> | ||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | ||
</PropertyGroup> | ||
|
||
<!-- | ||
Add the stylecop config to each project. | ||
--> | ||
<ItemGroup> | ||
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Use fixed version of analyzers. | ||
--> | ||
<ItemGroup> | ||
<!-- | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0-preview1.23165.1" PrivateAssets="all" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all" /> | ||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.52" PrivateAssets="all" /> | ||
--> | ||
<!-- | ||
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.55.0.65544" PrivateAssets="all" /> | ||
--> | ||
</ItemGroup> | ||
</Project> |
39 changes: 25 additions & 14 deletions
39
src/Renci.SshNet.Tests/Classes/Common/ObjectIdentifierTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Renci.SshNet.Common; | ||
using Renci.SshNet.Tests.Common; | ||
|
||
namespace Renci.SshNet.Tests.Classes.Common | ||
{ | ||
/// <summary> | ||
///This is a test class for ObjectIdentifierTest and is intended | ||
///to contain all ObjectIdentifierTest Unit Tests | ||
///</summary> | ||
{ | ||
[TestClass] | ||
[Ignore] // placeholder for actual test | ||
public class ObjectIdentifierTest : TestBase | ||
{ | ||
/// <summary> | ||
///A test for ObjectIdentifier Constructor | ||
///</summary> | ||
[TestMethod] | ||
public void ObjectIdentifierConstructorTest() | ||
public void Constructor_IdentifiersIsNull() | ||
{ | ||
ulong[] identifiers = null; // TODO: Initialize to an appropriate value | ||
ObjectIdentifier target = new ObjectIdentifier(identifiers); | ||
Assert.Inconclusive("TODO: Implement code to verify target"); | ||
const ulong[] identifiers = null; | ||
|
||
var actualException = Assert.ThrowsException<ArgumentNullException>(() => new ObjectIdentifier(identifiers)); | ||
|
||
Assert.AreEqual(typeof(ArgumentNullException), actualException.GetType()); | ||
Assert.IsNull(actualException.InnerException); | ||
Assert.AreEqual(nameof(identifiers), actualException.ParamName); | ||
} | ||
|
||
[TestMethod] | ||
public void Constructor_LengthOfIdentifiersIsLessThanTwo() | ||
{ | ||
var identifiers = new[] { 5UL }; | ||
|
||
var actualException = Assert.ThrowsException<ArgumentException>(() => new ObjectIdentifier(identifiers)); | ||
|
||
Assert.AreEqual(typeof(ArgumentException), actualException.GetType()); | ||
Assert.IsNull(actualException.InnerException); | ||
ArgumentExceptionAssert.MessageEquals("Must contain at least two elements.", actualException); | ||
Assert.AreEqual(nameof(identifiers), actualException.ParamName); | ||
} | ||
} | ||
} |
12 changes: 7 additions & 5 deletions
12
...ses/Connection/ProtocolVersionExchangeTest_ConnectionClosedByServer_NoDataSentByServer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[*.cs] | ||
|
||
### StyleCop Analyzers rules ### | ||
|
||
# SA1202: Elements must be ordered by access | ||
# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md | ||
dotnet_diagnostic.SA1202.severity = none | ||
|
||
#### .NET Compiler Platform analysers rules #### | ||
|
||
# CA1031: Do not catch general exception types | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1031 | ||
dotnet_diagnostic.CA1031.severity = none | ||
|
||
# CA2213: Disposable fields should be disposed | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2213 | ||
dotnet_diagnostic.CA2213.severity = none | ||
|
||
# IDE0004: Types that own disposable fields should be disposable | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0004 | ||
dotnet_diagnostic.IDE0004.severity = none | ||
|
||
# IDE0048: Add parentheses for clarity | ||
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0047 | ||
dotnet_diagnostic.IDE0048.severity = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.