diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index af7742b5e4..49ca013140 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -74,8 +74,6 @@ public static class Helper static readonly Lazy _githubAppCredentials = new Lazy(() => { - // 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 @@ public static class Helper 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 _customUrl = new Lazy(() => diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 513f252fe3..a99961f414 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -19,16 +19,12 @@ false - - $(DefineConstants);GITHUBJWT_HELPER_AVAILABLE - - - + @@ -36,18 +32,15 @@ - - - - + + + + + - - - - - + diff --git a/Octokit.Tests/Fixtures/EmbeddedResource.cs b/Octokit.Tests/Fixtures/EmbeddedResource.cs index 445f00e19a..375312e508 100644 --- a/Octokit.Tests/Fixtures/EmbeddedResource.cs +++ b/Octokit.Tests/Fixtures/EmbeddedResource.cs @@ -20,13 +20,7 @@ public EmbeddedResource(Assembly assembly, string resourceName) 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)) { diff --git a/Octokit.Tests/Fixtures/Fixtures.cs b/Octokit.Tests/Fixtures/Fixtures.cs index edc9aef620..13bedb3d79 100644 --- a/Octokit.Tests/Fixtures/Fixtures.cs +++ b/Octokit.Tests/Fixtures/Fixtures.cs @@ -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 @@ public static class Fixtures 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 } } diff --git a/Octokit.Tests/Http/RateLimitTests.cs b/Octokit.Tests/Http/RateLimitTests.cs index d16082a3a8..2e298aaa54 100644 --- a/Octokit.Tests/Http/RateLimitTests.cs +++ b/Octokit.Tests/Http/RateLimitTests.cs @@ -79,6 +79,7 @@ public void CanPopulateObjectFromSerializedData() }; var rateLimit = new RateLimit(headers); + var deserialized = BinaryFormatterExtensions.SerializeAndDeserializeObject(rateLimit); Assert.Equal(100, deserialized.Limit); diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 3eb7e6c47a..92ec09d1dc 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -32,10 +32,6 @@ - - $(DefineConstants);NO_SERIALIZABLE;HAS_TYPEINFO - - diff --git a/Octokit.Tests/SelfTests.cs b/Octokit.Tests/SelfTests.cs index 98701b9394..c419425785 100644 --- a/Octokit.Tests/SelfTests.cs +++ b/Octokit.Tests/SelfTests.cs @@ -1,6 +1,4 @@ -#if HAS_TYPEINFO -using System.Reflection; -#endif +using System.Reflection; using Xunit; /// @@ -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); } } diff --git a/Octokit/Exceptions/AbuseException.cs b/Octokit/Exceptions/AbuseException.cs index 5e94754b95..3a8d13406f 100644 --- a/Octokit/Exceptions/AbuseException.cs +++ b/Octokit/Exceptions/AbuseException.cs @@ -4,10 +4,8 @@ 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. /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Request Forbidden - Abuse Detection"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of AbuseException /// @@ -86,6 +81,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("RetryAfterSeconds", RetryAfterSeconds); } -#endif } } diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 91f255975d..99d2fa1b6b 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -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 /// /// Represents errors that occur from the GitHub API. /// -#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 @@ static ApiError GetApiErrorFromExceptionMessage(string responseContent) return new ApiError(responseContent); } -#if !NO_SERIALIZABLE /// /// Constructs an instance of ApiException. /// @@ -170,7 +165,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("HttpStatusCode", StatusCode); info.AddValue("ApiError", ApiError); } -#endif /// /// Get the inner error message from the API response diff --git a/Octokit/Exceptions/ApiValidationException.cs b/Octokit/Exceptions/ApiValidationException.cs index 3b76a8ed52..e349830ffa 100644 --- a/Octokit/Exceptions/ApiValidationException.cs +++ b/Octokit/Exceptions/ApiValidationException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a HTTP 422 - Unprocessable Entity response returned from the API. /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Validation Failed"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of ApiValidationException /// @@ -76,6 +71,5 @@ protected ApiValidationException(SerializationInfo info, StreamingContext contex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/AuthorizationException.cs b/Octokit/Exceptions/AuthorizationException.cs index f47bb0deb7..4ab2e4e09f 100644 --- a/Octokit/Exceptions/AuthorizationException.cs +++ b/Octokit/Exceptions/AuthorizationException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a HTTP 401 - Unauthorized response returned from the API. /// -#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 @@ public AuthorizationException(HttpStatusCode httpStatusCode, Exception innerExce { } -#if !NO_SERIALIZABLE /// /// Constructs an instance of AuthorizationException. /// @@ -67,6 +62,5 @@ protected AuthorizationException(SerializationInfo info, StreamingContext contex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/ForbiddenException.cs b/Octokit/Exceptions/ForbiddenException.cs index 9f15d11786..1988286735 100644 --- a/Octokit/Exceptions/ForbiddenException.cs +++ b/Octokit/Exceptions/ForbiddenException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a HTTP 403 - Forbidden response returned from the API. /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Request Forbidden"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of ForbiddenException /// @@ -59,6 +54,5 @@ protected ForbiddenException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs index 6e0d8db546..7c8f354e51 100644 --- a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs +++ b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs @@ -1,17 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a HTTP 403 - Forbidden response returned from the API. /// -#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 @@ public override string Message } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of InvalidGitignoreTemplateException /// @@ -53,6 +48,5 @@ public override string Message protected InvalidGitIgnoreTemplateException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } \ No newline at end of file diff --git a/Octokit/Exceptions/LegalRestrictionException.cs b/Octokit/Exceptions/LegalRestrictionException.cs index d7ac60c22e..6868949eac 100644 --- a/Octokit/Exceptions/LegalRestrictionException.cs +++ b/Octokit/Exceptions/LegalRestrictionException.cs @@ -2,9 +2,7 @@ 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. /// -#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 @@ public LegalRestrictionException(IResponse response, Exception innerException) "LegalRestrictionException created with wrong status code"); } -#if !NO_SERIALIZABLE /// /// Constructs an instance of LegalRestrictionException /// @@ -70,6 +65,5 @@ protected LegalRestrictionException(SerializationInfo info, StreamingContext con : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/LoginAttemptsExceededException.cs b/Octokit/Exceptions/LoginAttemptsExceededException.cs index 56269c98fc..fe6fab01a6 100644 --- a/Octokit/Exceptions/LoginAttemptsExceededException.cs +++ b/Octokit/Exceptions/LoginAttemptsExceededException.cs @@ -1,17 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a "Login Attempts Exceeded" response returned from the API. /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Maximum number of login attempts exceeded"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of LoginAttemptsExceededException /// @@ -56,6 +51,5 @@ protected LoginAttemptsExceededException(SerializationInfo info, StreamingContex : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/NotFoundException.cs b/Octokit/Exceptions/NotFoundException.cs index 4f64b26b86..d4943867a7 100644 --- a/Octokit/Exceptions/NotFoundException.cs +++ b/Octokit/Exceptions/NotFoundException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif namespace Octokit { /// /// Represents a HTTP 404 - Not Found response returned from the API. /// -#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 @@ public NotFoundException(IResponse response, Exception innerException) "NotFoundException created with wrong status code"); } -#if !NO_SERIALIZABLE /// /// Constructs an instance of NotFoundException /// @@ -63,6 +58,5 @@ protected NotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/PullRequestMismatchException.cs b/Octokit/Exceptions/PullRequestMismatchException.cs index 83df68cc66..310fc264af 100644 --- a/Octokit/Exceptions/PullRequestMismatchException.cs +++ b/Octokit/Exceptions/PullRequestMismatchException.cs @@ -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 /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Head branch was modified. Review and try the merge again."; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of . /// @@ -61,6 +56,5 @@ protected PullRequestMismatchException(SerializationInfo info, StreamingContext : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/PullRequestNotMergeableException.cs b/Octokit/Exceptions/PullRequestNotMergeableException.cs index 89ce79e158..4e92e16dfb 100644 --- a/Octokit/Exceptions/PullRequestNotMergeableException.cs +++ b/Octokit/Exceptions/PullRequestNotMergeableException.cs @@ -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 /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Pull Request is not mergeable"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of . /// @@ -61,6 +56,5 @@ protected PullRequestNotMergeableException(SerializationInfo info, StreamingCont : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/RateLimitExceededException.cs b/Octokit/Exceptions/RateLimitExceededException.cs index 537d9c82d1..61a17ca10a 100644 --- a/Octokit/Exceptions/RateLimitExceededException.cs +++ b/Octokit/Exceptions/RateLimitExceededException.cs @@ -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 /// /// See http://developer.github.com/v3/#rate-limiting for more details. /// -#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 @@ public TimeSpan GetRetryAfterTimeSpan() return ts > TimeSpan.Zero ? ts : TimeSpan.Zero; } -#if !NO_SERIALIZABLE /// /// Constructs an instance of RateLimitExceededException /// @@ -131,6 +126,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("RateLimit", _rateLimit); info.AddValue(nameof(ApiInfo.ServerTimeDifference), _severTimeDiff); } -#endif } } diff --git a/Octokit/Exceptions/RepositoryExistsException.cs b/Octokit/Exceptions/RepositoryExistsException.cs index d3d773ef40..e606b1e3e9 100644 --- a/Octokit/Exceptions/RepositoryExistsException.cs +++ b/Octokit/Exceptions/RepositoryExistsException.cs @@ -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 /// /// Exception thrown when creating a repository, but it already exists on the server. /// -#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 @@ public override string Message /// public bool OwnerIsOrganization { get; private set; } -#if !NO_SERIALIZABLE /// /// Constructs an instance of RepositoryExistsException. /// @@ -130,6 +125,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("OwnerIsOrganization", OwnerIsOrganization); info.AddValue("ExistingRepositoryWebUrl", ExistingRepositoryWebUrl); } -#endif } } diff --git a/Octokit/Exceptions/RepositoryFormatException.cs b/Octokit/Exceptions/RepositoryFormatException.cs index c0ab53b515..60428fc3bf 100644 --- a/Octokit/Exceptions/RepositoryFormatException.cs +++ b/Octokit/Exceptions/RepositoryFormatException.cs @@ -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 @@ public override string Message } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of LoginAttemptsExceededException /// @@ -60,6 +55,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("Message", Message); } -#endif } } diff --git a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs index 48d264a751..dc0795b742 100644 --- a/Octokit/Exceptions/SecondaryRateLimitExceededException.cs +++ b/Octokit/Exceptions/SecondaryRateLimitExceededException.cs @@ -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 /// /// See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details. /// -#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 @@ public override string Message get { return ApiErrorMessageSafe ?? "Secondary API Rate Limit exceeded"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of . /// @@ -62,6 +57,5 @@ protected SecondaryRateLimitExceededException(SerializationInfo info, StreamingC : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/TwoFactorAuthorizationException.cs b/Octokit/Exceptions/TwoFactorAuthorizationException.cs index b1ab087f10..1e107497b3 100644 --- a/Octokit/Exceptions/TwoFactorAuthorizationException.cs +++ b/Octokit/Exceptions/TwoFactorAuthorizationException.cs @@ -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 /// /// Represents a failed 2FA challenge from the API /// [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 @@ protected TwoFactorAuthorizationException(IResponse response, TwoFactorType twoF /// public TwoFactorType TwoFactorType { get; private set; } -#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorRequiredException. /// @@ -89,8 +84,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("TwoFactorType", TwoFactorType); } -#endif - } /// diff --git a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs index 3e1b799f54..a317e176eb 100644 --- a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs +++ b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs @@ -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 /// /// Represents a failed 2FA challenge from the API /// [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 @@ static TwoFactorType ParseTwoFactorType(ApiException exception) return exception == null ? TwoFactorType.None : Connection.ParseTwoFactorType(exception.HttpResponse); } -#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorChallengeFailedException. /// @@ -73,6 +68,5 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont base.GetObjectData(info, context); info.AddValue("AuthorizationCode", AuthorizationCode); } -#endif } } diff --git a/Octokit/Exceptions/TwoFactorRequiredException.cs b/Octokit/Exceptions/TwoFactorRequiredException.cs index 22f4276d19..5cdf5dab6d 100644 --- a/Octokit/Exceptions/TwoFactorRequiredException.cs +++ b/Octokit/Exceptions/TwoFactorRequiredException.cs @@ -2,18 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; -#if !NO_SERIALIZABLE using System.Runtime.Serialization; -#endif 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 TwoFactorRequiredException : TwoFactorAuthorizationException @@ -50,7 +46,6 @@ public override string Message get { return ApiErrorMessageSafe ?? "Two-factor authentication code is required"; } } -#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorRequiredException. /// @@ -66,6 +61,5 @@ protected TwoFactorRequiredException(SerializationInfo info, StreamingContext co : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs b/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs index 9435b21e8f..ec8478581d 100644 --- a/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs +++ b/Octokit/Exceptions/UserIsLastOwnerOfOrganizationException.cs @@ -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 /// -#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 @@ public UserIsLastOwnerOfOrganizationException(IResponse response, ApiException i // 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 /// /// Constructs an instance of . /// @@ -58,6 +53,5 @@ protected UserIsLastOwnerOfOrganizationException(SerializationInfo info, Streami : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs b/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs index 05976c6260..257e96fc9d 100644 --- a/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs +++ b/Octokit/Exceptions/UserIsNotMemberOfOrganizationException.cs @@ -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 /// -#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 @@ public UserIsNotMemberOfOrganizationException(IResponse response, ApiException i // 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 /// /// Constructs an instance of ForbiddenException /// @@ -58,6 +53,5 @@ protected UserIsNotMemberOfOrganizationException(SerializationInfo info, Streami : base(info, context) { } -#endif } } diff --git a/Octokit/Exceptions/UserIsOrganizationMemberException.cs b/Octokit/Exceptions/UserIsOrganizationMemberException.cs index 06120d9044..072a763ce2 100644 --- a/Octokit/Exceptions/UserIsOrganizationMemberException.cs +++ b/Octokit/Exceptions/UserIsOrganizationMemberException.cs @@ -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 /// -#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 @@ public UserIsOrganizationMemberException(IResponse response, ApiException innerE // 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 /// /// Constructs an instance of . /// @@ -58,6 +53,5 @@ protected UserIsOrganizationMemberException(SerializationInfo info, StreamingCon : base(info, context) { } -#endif } } diff --git a/Octokit/Helpers/ReflectionExtensions.cs b/Octokit/Helpers/ReflectionExtensions.cs index 49265172a8..cc8f5a4d75 100644 --- a/Octokit/Helpers/ReflectionExtensions.cs +++ b/Octokit/Helpers/ReflectionExtensions.cs @@ -39,12 +39,6 @@ public static bool IsNullable(this Type type) return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } -#if !HAS_TYPEINFO - public static Type GetTypeInfo(this Type type) - { - return type; - } -#else public static IEnumerable GetMember(this Type type, string name) { return type.GetTypeInfo().DeclaredMembers.Where(m => m.Name == name); @@ -59,19 +53,14 @@ public static bool IsAssignableFrom(this Type type, Type otherType) { return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo()); } -#endif public static IEnumerable 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) diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 17cfce19fb..bcace9f7ee 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -8,9 +8,6 @@ using System.Threading; using System.Threading.Tasks; using Octokit.Internal; -#if !HAS_ENVIRONMENT -using System.Runtime.InteropServices; -#endif namespace Octokit { @@ -790,17 +787,11 @@ static string GetPlatformInformation() 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 { diff --git a/Octokit/Http/HttpClientAdapter.cs b/Octokit/Http/HttpClientAdapter.cs index efe823dda5..eca20a7480 100644 --- a/Octokit/Http/HttpClientAdapter.cs +++ b/Octokit/Http/HttpClientAdapter.cs @@ -29,31 +29,6 @@ public HttpClientAdapter(Func getHandler) { 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() }); } diff --git a/Octokit/Http/RateLimit.cs b/Octokit/Http/RateLimit.cs index 016ef4944a..0695726bd5 100644 --- a/Octokit/Http/RateLimit.cs +++ b/Octokit/Http/RateLimit.cs @@ -4,22 +4,15 @@ 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 @@ static long GetHeaderValueAsInt32Safe(IDictionary responseHeader : result; } -#if !NO_SERIALIZABLE protected RateLimit(SerializationInfo info, StreamingContext context) { Ensure.ArgumentNotNull(info, nameof(info)); @@ -115,7 +107,6 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte info.AddValue("Remaining", Remaining); info.AddValue("ResetAsUtcEpochSeconds", ResetAsUtcEpochSeconds); } -#endif internal string DebuggerDisplay { diff --git a/Octokit/Models/Response/ApiError.cs b/Octokit/Models/Response/ApiError.cs index be5650c9f6..2317cdacab 100644 --- a/Octokit/Models/Response/ApiError.cs +++ b/Octokit/Models/Response/ApiError.cs @@ -8,9 +8,7 @@ namespace Octokit /// /// Error payload from the API response /// -#if !NO_SERIALIZABLE [Serializable] -#endif [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ApiError { diff --git a/Octokit/Models/Response/ApiErrorDetail.cs b/Octokit/Models/Response/ApiErrorDetail.cs index 9e9d9f76bc..391561e02e 100644 --- a/Octokit/Models/Response/ApiErrorDetail.cs +++ b/Octokit/Models/Response/ApiErrorDetail.cs @@ -4,9 +4,7 @@ namespace Octokit { -#if !NO_SERIALIZABLE [Serializable] -#endif [DebuggerDisplay("{DebuggerDisplay,nq}")] public class ApiErrorDetail { diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 0148ebc3eb..33b13e2f7c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -20,7 +20,7 @@ - $(DefineConstants);HAS_TYPEINFO;SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO + $(DefineConstants);SIMPLE_JSON_INTERNAL;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_READONLY_COLLECTIONS;SIMPLE_JSON_TYPEINFO 1591;1701;1702;1705 diff --git a/Octokit/SimpleJson.cs b/Octokit/SimpleJson.cs index 5d5161c202..eab7a32a6f 100644 --- a/Octokit/SimpleJson.cs +++ b/Octokit/SimpleJson.cs @@ -59,9 +59,7 @@ 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 @@ public static object DeserializeObject(string json) if (TryDeserializeObject(json, out obj)) return obj; -#if !NO_SERIALIZABLE throw new SerializationException("Invalid JSON string"); -#else - throw new Exception("Invalid JSON string"); -#endif } ///