Stylecop (#428)
* add auto generate header * run gen * introduce first style analyizer * fix tab
This commit is contained in:
6
Directory.Build.props
Normal file
6
Directory.Build.props
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)\kubernetes-client.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
11
Directory.Build.targets
Normal file
11
Directory.Build.targets
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
|
||||||
|
<PrivateAssets>All</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
using k8s.Models;
|
using k8s.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
using k8s.Models;
|
using k8s.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
namespace k8s.Models
|
namespace k8s.Models
|
||||||
{
|
{
|
||||||
{{#.}}
|
{{#.}}
|
||||||
|
|||||||
8
kubernetes-client.ruleset
Normal file
8
kubernetes-client.ruleset
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RuleSet Name="kubernetes-client" ToolsVersion="10.0">
|
||||||
|
|
||||||
|
<!-- https://github.com/DotNetAnalyzers/StyleCopAnalyzers/tree/master/documentation -->
|
||||||
|
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
|
||||||
|
<Rule Id="SA1027" Action="Error" />
|
||||||
|
</Rules>
|
||||||
|
</RuleSet>
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
using k8s.Models;
|
using k8s.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
using k8s.Models;
|
using k8s.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
// <auto-generated>
|
||||||
|
// Code generated by gen/KubernetesWatchGenerator
|
||||||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||||||
|
// regenerated.
|
||||||
|
// </auto-generated>
|
||||||
namespace k8s.Models
|
namespace k8s.Models
|
||||||
{
|
{
|
||||||
[KubernetesEntity(Group="admissionregistration.k8s.io", Kind="MutatingWebhookConfiguration", ApiVersion="v1", PluralName="mutatingwebhookconfigurations")]
|
[KubernetesEntity(Group="admissionregistration.k8s.io", Kind="MutatingWebhookConfiguration", ApiVersion="v1", PluralName="mutatingwebhookconfigurations")]
|
||||||
|
|||||||
5
stylecop.json
Normal file
5
stylecop.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||||
|
"settings": {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,13 +6,13 @@ using Xunit.Abstractions;
|
|||||||
namespace k8s.Tests.Logging
|
namespace k8s.Tests.Logging
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An implementation of <see cref="ILogger"/> that writes to the output of the current Xunit test.
|
/// An implementation of <see cref="ILogger"/> that writes to the output of the current Xunit test.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
sealed class TestOutputLogger
|
sealed class TestOutputLogger
|
||||||
: ILogger
|
: ILogger
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="TestOutputLogger"/>.
|
/// Create a new <see cref="TestOutputLogger"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testOutput">
|
/// <param name="testOutput">
|
||||||
/// The output for the current test.
|
/// The output for the current test.
|
||||||
@@ -21,7 +21,7 @@ namespace k8s.Tests.Logging
|
|||||||
/// The logger's category name.
|
/// The logger's category name.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="minLogLevel">
|
/// <param name="minLogLevel">
|
||||||
/// The logger's minimum log level.
|
/// The logger's minimum log level.
|
||||||
/// </param>
|
/// </param>
|
||||||
public TestOutputLogger(ITestOutputHelper testOutput, string loggerCategory, LogLevel minLogLevel)
|
public TestOutputLogger(ITestOutputHelper testOutput, string loggerCategory, LogLevel minLogLevel)
|
||||||
{
|
{
|
||||||
@@ -47,27 +47,27 @@ namespace k8s.Tests.Logging
|
|||||||
public string LoggerCategory { get; }
|
public string LoggerCategory { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The logger's minimum log level.
|
/// The logger's minimum log level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LogLevel MinLogLevel { get; }
|
public LogLevel MinLogLevel { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Emit a log entry.
|
/// Emit a log entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="level">
|
/// <param name="level">
|
||||||
/// The log entry's level.
|
/// The log entry's level.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="eventId">
|
/// <param name="eventId">
|
||||||
/// The log entry's associated event Id.
|
/// The log entry's associated event Id.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="state">
|
/// <param name="state">
|
||||||
/// The log entry to be written. Can be also an object.
|
/// The log entry to be written. Can be also an object.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="exception">
|
/// <param name="exception">
|
||||||
/// The exception (if any) related to the log entry.
|
/// The exception (if any) related to the log entry.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="formatter">
|
/// <param name="formatter">
|
||||||
/// A function that creates a <c>string</c> log message from the <paramref name="state"/> and <paramref name="exception"/>.
|
/// A function that creates a <c>string</c> log message from the <paramref name="state"/> and <paramref name="exception"/>.
|
||||||
/// </param>
|
/// </param>
|
||||||
public void Log<TState>(LogLevel level, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
public void Log<TState>(LogLevel level, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||||
{
|
{
|
||||||
@@ -89,24 +89,24 @@ namespace k8s.Tests.Logging
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if the given <paramref name="logLevel"/> is enabled.
|
/// Check if the given <paramref name="logLevel"/> is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logLevel">
|
/// <param name="logLevel">
|
||||||
/// The level to be checked.
|
/// The level to be checked.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <c>true</c> if enabled; otherwise, <c>false</c>.
|
/// <c>true</c> if enabled; otherwise, <c>false</c>.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public bool IsEnabled(LogLevel logLevel) => logLevel >= MinLogLevel;
|
public bool IsEnabled(LogLevel logLevel) => logLevel >= MinLogLevel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begin a logical operation scope.
|
/// Begin a logical operation scope.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="state">
|
/// <param name="state">
|
||||||
/// An identifier for the scope.
|
/// An identifier for the scope.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An <see cref="IDisposable"/> that ends the logical operation scope when disposed.
|
/// An <see cref="IDisposable"/> that ends the logical operation scope when disposed.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IDisposable BeginScope<TState>(TState state) => Disposable.Empty;
|
public IDisposable BeginScope<TState>(TState state) => Disposable.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ namespace k8s.Tests.Logging
|
|||||||
: ILoggerProvider
|
: ILoggerProvider
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new <see cref="TestOutputLoggerProvider"/>.
|
/// Create a new <see cref="TestOutputLoggerProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testOutput">
|
/// <param name="testOutput">
|
||||||
/// The output for the current test.
|
/// The output for the current test.
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <param name="minLogLevel">
|
/// <param name="minLogLevel">
|
||||||
/// The logger's minimum log level.
|
/// The logger's minimum log level.
|
||||||
/// </param>
|
/// </param>
|
||||||
public TestOutputLoggerProvider(ITestOutputHelper testOutput, LogLevel minLogLevel)
|
public TestOutputLoggerProvider(ITestOutputHelper testOutput, LogLevel minLogLevel)
|
||||||
{
|
{
|
||||||
@@ -41,7 +41,7 @@ namespace k8s.Tests.Logging
|
|||||||
ITestOutputHelper TestOutput { get; }
|
ITestOutputHelper TestOutput { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The logger's minimum log level.
|
/// The logger's minimum log level.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LogLevel MinLogLevel { get; }
|
public LogLevel MinLogLevel { get; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user