mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
maint: Tidying up DefineConstants (#2538)
This commit is contained in:
@@ -74,8 +74,6 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
static readonly Lazy<Credentials> _githubAppCredentials = new Lazy<Credentials>(() =>
|
||||
{
|
||||
// GitHubJwt nuget package only available for netstandard2.0+
|
||||
#if GITHUBJWT_HELPER_AVAILABLE
|
||||
var generator = new GitHubJwt.GitHubJwtFactory(
|
||||
new GitHubJwt.FilePrivateKeySource(GitHubAppPemFile),
|
||||
new GitHubJwt.GitHubJwtFactoryOptions
|
||||
@@ -87,11 +85,6 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
var jwtToken = generator.CreateEncodedJwtToken();
|
||||
return new Credentials(jwtToken, AuthenticationType.Bearer);
|
||||
#else
|
||||
// return null, which will cause the [GitHubAppTest]'s to not be discovered
|
||||
return null;
|
||||
#endif
|
||||
|
||||
});
|
||||
|
||||
static readonly Lazy<Uri> _customUrl = new Lazy<Uri>(() =>
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
|
||||
<DefineConstants>$(DefineConstants);GITHUBJWT_HELPER_AVAILABLE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Octokit.Tests\Helpers\AssertEx.cs" />
|
||||
<EmbeddedResource Include="fixtures\hello-world.txt;fixtures\hello-world.zip" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
|
||||
@@ -36,6 +32,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitHubJwt" Version="0.0.5" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
@@ -46,10 +43,6 @@
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
|
||||
<PackageReference Include="GitHubJwt" Version="0.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -20,13 +20,7 @@ namespace Octokit.Tests
|
||||
|
||||
public string GetResourceAsString(Encoding encoding = null)
|
||||
{
|
||||
encoding = encoding ??
|
||||
#if HAS_DEFAULT_ENCODING
|
||||
Encoding.Default;
|
||||
#else
|
||||
// http://stackoverflow.com/questions/35929391/how-can-i-determine-the-default-encoding-in-a-portable-class-library
|
||||
Encoding.GetEncoding(0);
|
||||
#endif
|
||||
encoding = encoding ?? Encoding.GetEncoding(0);
|
||||
|
||||
using (var sr = new StreamReader(GetResourceStream(), encoding))
|
||||
{
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#if HAS_TYPEINFO
|
||||
using System.Reflection;
|
||||
#endif
|
||||
using System.Reflection;
|
||||
|
||||
namespace Octokit.Tests
|
||||
{
|
||||
public static class Fixtures
|
||||
{
|
||||
#if HAS_TYPEINFO
|
||||
public static EmbeddedResource AuthorizationsJson =
|
||||
new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.authorizations.json");
|
||||
|
||||
@@ -33,33 +30,5 @@ namespace Octokit.Tests
|
||||
|
||||
public static EmbeddedResource ReleaseAssetJson =
|
||||
new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.release_asset.json");
|
||||
#else
|
||||
public static EmbeddedResource AuthorizationsJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.authorizations.json");
|
||||
|
||||
public static EmbeddedResource AuthorizationJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.authorization.json");
|
||||
|
||||
public static EmbeddedResource UserJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.user.json");
|
||||
|
||||
public static EmbeddedResource UserFullJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.user_full.json");
|
||||
|
||||
public static EmbeddedResource RepositoryJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.repository.json");
|
||||
|
||||
public static EmbeddedResource RepositoriesJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.repositories.json");
|
||||
|
||||
public static EmbeddedResource ReleasesJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.releases.json");
|
||||
|
||||
public static EmbeddedResource ReleaseJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.release.json");
|
||||
|
||||
public static EmbeddedResource ReleaseAssetJson =
|
||||
new EmbeddedResource(typeof(Fixtures).Assembly, "Octokit.Tests.Fixtures.release_asset.json");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace Octokit.Tests.Http
|
||||
};
|
||||
|
||||
var rateLimit = new RateLimit(headers);
|
||||
|
||||
var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(rateLimit);
|
||||
|
||||
Assert.Equal(100, deserialized.Limit);
|
||||
|
||||
@@ -32,10 +32,6 @@
|
||||
<PackageReference Include="NSubstitute" Version="4.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
|
||||
<DefineConstants>$(DefineConstants);NO_SERIALIZABLE;HAS_TYPEINFO</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#if HAS_TYPEINFO
|
||||
using System.Reflection;
|
||||
#endif
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
/// <summary>
|
||||
@@ -11,11 +9,7 @@ public class SelfTests
|
||||
[Fact]
|
||||
public void NoTestsUseAsyncVoid()
|
||||
{
|
||||
#if HAS_TYPEINFO
|
||||
var errors = typeof(SelfTests).GetTypeInfo().Assembly.GetAsyncVoidMethodsList();
|
||||
#else
|
||||
var errors = typeof(SelfTests).Assembly.GetAsyncVoidMethodsList();
|
||||
#endif
|
||||
Assert.Equal("", errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,8 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -15,9 +13,7 @@ namespace Octokit
|
||||
/// Represents a subset of the HTTP 403 - Forbidden response returned from the API when the forbidden response is related to an abuse detection mechanism.
|
||||
/// Contains the amount of seconds after which it's safe to retry the request.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class AbuseException : ForbiddenException
|
||||
@@ -63,7 +59,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Request Forbidden - Abuse Detection"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of AbuseException
|
||||
/// </summary>
|
||||
@@ -86,6 +81,5 @@ namespace Octokit
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("RetryAfterSeconds", RetryAfterSeconds);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
using Octokit.Internal;
|
||||
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Represents errors that occur from the GitHub API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class ApiException : Exception
|
||||
@@ -143,7 +139,6 @@ namespace Octokit
|
||||
return new ApiError(responseContent);
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of ApiException.
|
||||
/// </summary>
|
||||
@@ -170,7 +165,6 @@ namespace Octokit
|
||||
info.AddValue("HttpStatusCode", StatusCode);
|
||||
info.AddValue("ApiError", ApiError);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Get the inner error message from the API response
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 422 - Unprocessable Entity response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class ApiValidationException : ApiException
|
||||
@@ -60,7 +56,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Validation Failed"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of ApiValidationException
|
||||
/// </summary>
|
||||
@@ -76,6 +71,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 401 - Unauthorized response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class AuthorizationException : ApiException
|
||||
@@ -51,7 +47,6 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of AuthorizationException.
|
||||
/// </summary>
|
||||
@@ -67,6 +62,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 403 - Forbidden response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class ForbiddenException : ApiException
|
||||
@@ -43,7 +39,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Request Forbidden"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of ForbiddenException
|
||||
/// </summary>
|
||||
@@ -59,6 +54,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 403 - Forbidden response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class InvalidGitIgnoreTemplateException : ApiValidationException
|
||||
@@ -38,7 +34,6 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of InvalidGitignoreTemplateException
|
||||
/// </summary>
|
||||
@@ -53,6 +48,5 @@ namespace Octokit
|
||||
protected InvalidGitIgnoreTemplateException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{ }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -13,9 +11,7 @@ namespace Octokit
|
||||
/// This will returned if GitHub has been asked to takedown the requested resource due to
|
||||
/// a DMCA takedown.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class LegalRestrictionException : ApiException
|
||||
@@ -54,7 +50,6 @@ namespace Octokit
|
||||
"LegalRestrictionException created with wrong status code");
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of LegalRestrictionException
|
||||
/// </summary>
|
||||
@@ -70,6 +65,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a "Login Attempts Exceeded" response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class LoginAttemptsExceededException : ForbiddenException
|
||||
@@ -40,7 +36,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Maximum number of login attempts exceeded"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of LoginAttemptsExceededException
|
||||
/// </summary>
|
||||
@@ -56,6 +51,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a HTTP 404 - Not Found response returned from the API.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class NotFoundException : ApiException
|
||||
@@ -47,7 +43,6 @@ namespace Octokit
|
||||
"NotFoundException created with wrong status code");
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of NotFoundException
|
||||
/// </summary>
|
||||
@@ -63,6 +58,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// Represents an error that occurs when the specified SHA
|
||||
/// doesn't match the current pull request's HEAD
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class PullRequestMismatchException : ApiException
|
||||
@@ -45,7 +41,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Head branch was modified. Review and try the merge again."; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="Octokit.PullRequestNotMergeableException"/>.
|
||||
/// </summary>
|
||||
@@ -61,6 +56,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// Represents an error that occurs when the pull request is in an
|
||||
/// unmergeable state
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class PullRequestNotMergeableException : ApiException
|
||||
@@ -45,7 +41,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Pull Request is not mergeable"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="Octokit.PullRequestNotMergeableException"/>.
|
||||
/// </summary>
|
||||
@@ -61,6 +56,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
|
||||
namespace Octokit
|
||||
@@ -18,9 +16,7 @@ namespace Octokit
|
||||
/// </para>
|
||||
/// <para>See http://developer.github.com/v3/#rate-limiting for more details.</para>
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class RateLimitExceededException : ForbiddenException
|
||||
@@ -102,7 +98,6 @@ namespace Octokit
|
||||
return ts > TimeSpan.Zero ? ts : TimeSpan.Zero;
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of RateLimitExceededException
|
||||
/// </summary>
|
||||
@@ -131,6 +126,5 @@ namespace Octokit
|
||||
info.AddValue("RateLimit", _rateLimit);
|
||||
info.AddValue(nameof(ApiInfo.ServerTimeDifference), _severTimeDiff);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
|
||||
namespace Octokit
|
||||
@@ -11,9 +9,7 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Exception thrown when creating a repository, but it already exists on the server.
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class RepositoryExistsException : ApiValidationException
|
||||
@@ -97,7 +93,6 @@ namespace Octokit
|
||||
/// </summary>
|
||||
public bool OwnerIsOrganization { get; private set; }
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of RepositoryExistsException.
|
||||
/// </summary>
|
||||
@@ -130,6 +125,5 @@ namespace Octokit
|
||||
info.AddValue("OwnerIsOrganization", OwnerIsOrganization);
|
||||
info.AddValue("ExistingRepositoryWebUrl", ExistingRepositoryWebUrl);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class RepositoryFormatException : Exception
|
||||
@@ -35,7 +31,6 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of LoginAttemptsExceededException
|
||||
/// </summary>
|
||||
@@ -60,6 +55,5 @@ namespace Octokit
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("Message", Message);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -16,9 +14,7 @@ namespace Octokit
|
||||
/// </para>
|
||||
/// <para>See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para>
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class SecondaryRateLimitExceededException : ForbiddenException
|
||||
@@ -46,7 +42,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Secondary API Rate Limit exceeded"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="Octokit.SecondaryRateLimitExceededException"/>.
|
||||
/// </summary>
|
||||
@@ -62,6 +57,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,15 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Represents a failed 2FA challenge from the API
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public abstract class TwoFactorAuthorizationException : AuthorizationException
|
||||
@@ -64,7 +60,6 @@ namespace Octokit
|
||||
/// </summary>
|
||||
public TwoFactorType TwoFactorType { get; private set; }
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of TwoFactorRequiredException.
|
||||
/// </summary>
|
||||
@@ -89,8 +84,6 @@ namespace Octokit
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("TwoFactorType", TwoFactorType);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Represents a failed 2FA challenge from the API
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class TwoFactorChallengeFailedException : TwoFactorAuthorizationException
|
||||
@@ -49,7 +45,6 @@ namespace Octokit
|
||||
return exception == null ? TwoFactorType.None : Connection.ParseTwoFactorType(exception.HttpResponse);
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of TwoFactorChallengeFailedException.
|
||||
/// </summary>
|
||||
@@ -73,6 +68,5 @@ namespace Octokit
|
||||
base.GetObjectData(info, context);
|
||||
info.AddValue("AuthorizationCode", AuthorizationCode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class TwoFactorRequiredException : TwoFactorAuthorizationException
|
||||
@@ -50,7 +46,6 @@ namespace Octokit
|
||||
get { return ApiErrorMessageSafe ?? "Two-factor authentication code is required"; }
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of TwoFactorRequiredException.
|
||||
/// </summary>
|
||||
@@ -66,6 +61,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// Represents an error that occurs when trying to convert the
|
||||
/// last owner of the organization to an outside collaborator
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class UserIsLastOwnerOfOrganizationException : ApiException
|
||||
@@ -42,7 +38,6 @@ namespace Octokit
|
||||
// https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-the-last-owner-of-the-organization
|
||||
public override string Message => ApiErrorMessageSafe ?? "User is the last owner of the organization.";
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="UserIsLastOwnerOfOrganizationException"/>.
|
||||
/// </summary>
|
||||
@@ -58,6 +53,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// Represents an error that occurs when trying to convert a user
|
||||
/// that is not a member of the organization to an outside collaborator
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class UserIsNotMemberOfOrganizationException : ApiException
|
||||
@@ -42,7 +38,6 @@ namespace Octokit
|
||||
// https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-not-a-member-of-the-organization
|
||||
public override string Message => ApiErrorMessageSafe ?? "User is not a member of the organization.";
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of ForbiddenException
|
||||
/// </summary>
|
||||
@@ -58,6 +53,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -12,9 +10,7 @@ namespace Octokit
|
||||
/// Represents an error that occurs when trying to remove an
|
||||
/// outside collaborator that is a member of the organization
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
|
||||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
|
||||
public class UserIsOrganizationMemberException : ApiException
|
||||
@@ -42,7 +38,6 @@ namespace Octokit
|
||||
// https://developer.github.com/v3/orgs/outside_collaborators/#response-if-user-is-a-member-of-the-organization
|
||||
public override string Message => ApiErrorMessageSafe ?? "User could not be removed as an outside collaborator.";
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
/// <summary>
|
||||
/// Constructs an instance of <see cref="UserIsOrganizationMemberException"/>.
|
||||
/// </summary>
|
||||
@@ -58,6 +53,5 @@ namespace Octokit
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,12 +39,6 @@ namespace Octokit
|
||||
return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>);
|
||||
}
|
||||
|
||||
#if !HAS_TYPEINFO
|
||||
public static Type GetTypeInfo(this Type type)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
#else
|
||||
public static IEnumerable<MemberInfo> GetMember(this Type type, string name)
|
||||
{
|
||||
return type.GetTypeInfo().DeclaredMembers.Where(m => m.Name == name);
|
||||
@@ -59,19 +53,14 @@ namespace Octokit
|
||||
{
|
||||
return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo());
|
||||
}
|
||||
#endif
|
||||
public static IEnumerable<PropertyInfo> GetAllProperties(this Type type)
|
||||
{
|
||||
#if HAS_TYPEINFO
|
||||
var typeInfo = type.GetTypeInfo();
|
||||
var properties = typeInfo.DeclaredProperties;
|
||||
|
||||
var baseType = typeInfo.BaseType;
|
||||
|
||||
return baseType == null ? properties : properties.Concat(baseType.GetAllProperties());
|
||||
#else
|
||||
return type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static bool IsEnumeration(this Type type)
|
||||
|
||||
@@ -8,9 +8,6 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit.Internal;
|
||||
#if !HAS_ENVIRONMENT
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
@@ -790,16 +787,10 @@ namespace Octokit
|
||||
try
|
||||
{
|
||||
_platformInformation = string.Format(CultureInfo.InvariantCulture,
|
||||
#if !HAS_ENVIRONMENT
|
||||
"{0}; {1}",
|
||||
RuntimeInformation.OSDescription.Trim(),
|
||||
RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant().Trim()
|
||||
#else
|
||||
"{0} {1}; {2}",
|
||||
Environment.OSVersion.Platform,
|
||||
Environment.OSVersion.Version.ToString(3),
|
||||
Environment.Is64BitOperatingSystem ? "amd64" : "x86"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -29,31 +29,6 @@ namespace Octokit.Internal
|
||||
{
|
||||
Ensure.ArgumentNotNull(getHandler, nameof(getHandler));
|
||||
|
||||
#if HAS_SERVICEPOINTMANAGER
|
||||
// GitHub API requires TLS1.2 as of February 2018
|
||||
//
|
||||
// .NET Framework before 4.6 did not enable TLS1.2 by default
|
||||
//
|
||||
// Even though this is an AppDomain wide setting, the decision was made for Octokit to
|
||||
// ensure that TLS1.2 is enabled so that existing applications using Octokit did not need to
|
||||
// make changes outside Octokit to continue to work with GitHub API
|
||||
//
|
||||
// *Update*
|
||||
// .NET Framework 4.7 introduced a new value (SecurityProtocolType.SystemDefault = 0)
|
||||
// which defers enabled protocols to operating system defaults
|
||||
// If this is the current value we shouldn't do anything, as that would cause TLS1.2 to be the ONLY enabled protocol!
|
||||
//
|
||||
// See https://docs.microsoft.com/en-us/dotnet/api/system.net.securityprotocoltype?view=netframework-4.7
|
||||
// See https://github.com/octokit/octokit.net/issues/1914
|
||||
|
||||
// Only apply when current setting is not SystemDefault (0) added in .NET 4.7
|
||||
if ((int)ServicePointManager.SecurityProtocol != 0)
|
||||
{
|
||||
// Add Tls1.2 to the existing enabled protocols
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
|
||||
}
|
||||
#endif
|
||||
|
||||
_http = new HttpClient(new RedirectHandler { InnerHandler = getHandler() });
|
||||
}
|
||||
|
||||
|
||||
@@ -4,22 +4,15 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Security;
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class RateLimit
|
||||
#if !NO_SERIALIZABLE
|
||||
: ISerializable
|
||||
#endif
|
||||
public class RateLimit : ISerializable
|
||||
{
|
||||
public RateLimit() { }
|
||||
|
||||
@@ -96,7 +89,6 @@ namespace Octokit
|
||||
: result;
|
||||
}
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
protected RateLimit(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
Ensure.ArgumentNotNull(info, nameof(info));
|
||||
@@ -115,7 +107,6 @@ namespace Octokit
|
||||
info.AddValue("Remaining", Remaining);
|
||||
info.AddValue("ResetAsUtcEpochSeconds", ResetAsUtcEpochSeconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace Octokit
|
||||
/// <summary>
|
||||
/// Error payload from the API response
|
||||
/// </summary>
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class ApiError
|
||||
{
|
||||
|
||||
@@ -4,9 +4,7 @@ using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
#if !NO_SERIALIZABLE
|
||||
[Serializable]
|
||||
#endif
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class ApiErrorDetail
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants>$(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO</DefineConstants>
|
||||
<NoWarn>1591;1701;1702;1705</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -59,9 +59,7 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
#if !NO_SERIALIZABLE
|
||||
using System.Runtime.Serialization;
|
||||
#endif
|
||||
using System.Text;
|
||||
using Octokit.Reflection;
|
||||
#if !SIMPLE_JSON_NO_LINQ_EXPRESSION
|
||||
@@ -549,11 +547,7 @@ namespace Octokit
|
||||
if (TryDeserializeObject(json, out obj))
|
||||
return obj;
|
||||
|
||||
#if !NO_SERIALIZABLE
|
||||
throw new SerializationException("Invalid JSON string");
|
||||
#else
|
||||
throw new Exception("Invalid JSON string");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user