-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: Introduce formatting and analyzers (#36)
* Use dotnet format to lint locally and in CI * Results of running dotnet format * Add code analysis workflow * <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> and <EnableNETAnalyzers>true</EnableNETAnalyzers> * Give full commit hash instead of v1 for code-analysis action * Install .NET before running code analysis * Rip out unmaintained analysis Action * Do not error on CS0618; error on all other warnings
- Loading branch information
1 parent
820a5e8
commit 24f96a2
Showing
12 changed files
with
123 additions
and
103 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using Xunit; | ||
using GitHub.Octokit.Client; | ||
using Xunit; | ||
|
||
public class ClientFactoryTests | ||
{ | ||
|
||
[Fact] | ||
public void Creates_Client_With_Default_Timeout() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
Assert.Equal(TimeSpan.FromSeconds(100), clientFactory.Timeout); | ||
} | ||
[Fact] | ||
public void Creates_Client_With_Default_Timeout() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
Assert.Equal(TimeSpan.FromSeconds(100), clientFactory.Timeout); | ||
} | ||
|
||
[Fact] | ||
public void Creates_Client_Persists_Set_Timeout() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
clientFactory.Timeout = TimeSpan.FromSeconds(5); | ||
Assert.Equal(TimeSpan.FromSeconds(5), clientFactory.Timeout); | ||
} | ||
[Fact] | ||
public void Creates_Client_Persists_Set_Timeout() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
clientFactory.Timeout = TimeSpan.FromSeconds(5); | ||
Assert.Equal(TimeSpan.FromSeconds(5), clientFactory.Timeout); | ||
} | ||
|
||
} | ||
} |
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,32 +1,32 @@ | ||
using Xunit; | ||
using GitHub.Octokit.Client; | ||
using GitHub.Octokit.Authentication; | ||
using GitHub.Octokit.Client; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
public class RequestAdapterTests | ||
{ | ||
|
||
[Fact] | ||
public void Creates_RequestAdaptor_With_Defaults() | ||
{ | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN")); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
[Fact] | ||
public void Creates_RequestAdaptor_With_Defaults() | ||
{ | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN")); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
|
||
[Fact] | ||
public void Creates_RequestAdaptor_With_GenericHttpClient() | ||
{ | ||
var httpClient = Substitute.For<HttpClient>(); | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN"), httpClient); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
[Fact] | ||
public void Creates_RequestAdaptor_With_GenericHttpClient() | ||
{ | ||
var httpClient = Substitute.For<HttpClient>(); | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN"), httpClient); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
|
||
[Fact] | ||
public void Creates_RequestAdaptor_With_ClientFactory() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN"), clientFactory); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
[Fact] | ||
public void Creates_RequestAdaptor_With_ClientFactory() | ||
{ | ||
var clientFactory = ClientFactory.Create(); | ||
var requestAdapter = RequestAdapter.Create(new TokenAuthenticationProvider("Octokit.Gen", "JRRTOLKIEN"), clientFactory); | ||
Assert.NotNull(requestAdapter); | ||
} | ||
|
||
} | ||
} |
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,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
# GitHub Actions performs formatting in .github/workflows/build.yml. | ||
# This script may be used to update files before pushing to a PR check. | ||
dotnet format |
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 |
---|---|---|
@@ -1,41 +1,47 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PackageId>GitHub.Octokit.SDK</PackageId> | ||
<Version>0.0.1-alpha</Version> | ||
<NuGetVersion>0.0.1-alpha</NuGetVersion> | ||
<Title>Octokit</Title> | ||
<Description> | ||
This is an auto-generated SDK for GitHub's REST API, built on Kiota. | ||
</Description> | ||
<Authors>GitHub</Authors> | ||
<PackageTags>GitHub API Octokit dotnet-core</PackageTags> | ||
<RepositoryUrl>https://github.com/octokit/dotnet-sdk</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/octokit/dotnet-sdk</PackageProjectUrl> | ||
<PackageIcon>octokit.png</PackageIcon> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageReadmeFile>NugetREADME.md</PackageReadmeFile> | ||
<Copyright>Copyright (c) GitHub 2023</Copyright> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<IsTrimmable>true</IsTrimmable> | ||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.7.2" /> | ||
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.3.3" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.1.2" /> | ||
<None Include="NugetREADME.md" Pack="true" PackagePath="\"/> | ||
<None Include="octokit.png" Pack="true" PackagePath="\"/> | ||
</ItemGroup> | ||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PackageId>GitHub.Octokit.SDK</PackageId> | ||
<Version>0.0.1-alpha</Version> | ||
<NuGetVersion>0.0.1-alpha</NuGetVersion> | ||
<Title>Octokit</Title> | ||
<Description> | ||
This is an auto-generated SDK for GitHub's REST API, built on Kiota. | ||
</Description> | ||
<Authors>GitHub</Authors> | ||
<PackageTags>GitHub API Octokit dotnet-core</PackageTags> | ||
<RepositoryUrl>https://github.com/octokit/dotnet-sdk</RepositoryUrl> | ||
<PackageProjectUrl>https://github.com/octokit/dotnet-sdk</PackageProjectUrl> | ||
<PackageIcon>octokit.png</PackageIcon> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
<PackageReadmeFile>NugetREADME.md</PackageReadmeFile> | ||
<Copyright>Copyright (c) GitHub 2023</Copyright> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<IsTrimmable>true</IsTrimmable> | ||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer> | ||
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> | ||
<EnableNETAnalyzers>true</EnableNETAnalyzers> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<!-- The below NoWarn is due to Kiota generating code marked as Obsolete. | ||
This is expected, but we still want to error on other warnings from analyzers. --> | ||
<NoWarn>$(NoWarn);CS0618</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.7.2" /> | ||
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.3.3" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.1.2" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.1.2" /> | ||
<None Include="NugetREADME.md" Pack="true" PackagePath="\"/> | ||
<None Include="octokit.png" Pack="true" PackagePath="\"/> | ||
</ItemGroup> | ||
</Project> |
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