-
-
Notifications
You must be signed in to change notification settings - Fork 950
Fix some (lots of) issues reported by analyzers. #1125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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> |
Empty file.
39 changes: 25 additions & 14 deletions
39
src/Renci.SshNet.Tests/Classes/Common/ObjectIdentifierTest.cs
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
drieseng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### .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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.