From 13d5dab51645e603f6e71f776912acfe00115923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Derriey?= Date: Sat, 21 Jan 2017 15:42:02 +1100 Subject: [PATCH] Port to .NET Core (#1503) Port to .NET Core --- .gitignore | 11 +- .travis.yml | 10 +- Octokit.Core.sln | 38 +- Octokit.Next.Tests/CalculatorTests.cs | 24 - Octokit.Next.Tests/Properties/AssemblyInfo.cs | 19 - Octokit.Next.Tests/project.json | 16 - Octokit.Next/Calculator.cs | 10 - Octokit.Next/Properties/AssemblyInfo.cs | 19 - Octokit.Next/project.json | 11 - .../ObservableEnterpriseLdapClient.cs | 1 - .../ObservableEnterpriseLicenseClient.cs | 1 - .../ObservableEnterpriseOrganizationClient.cs | 1 - .../ObservableUserAdministrationClient.cs | 1 - Octokit.Reactive/Octokit.Reactive-Mono.csproj | 209 ------- .../Octokit.Reactive-MonoAndroid.csproj | 225 -------- .../Octokit.Reactive-Monotouch.csproj | 221 ------- Octokit.Reactive/Octokit.Reactive.csproj | 245 -------- .../Octokit.Reactive.csproj.DotSettings | 2 - Octokit.Reactive/Octokit.Reactive.xproj | 19 + Octokit.Reactive/packages.config | 8 - Octokit.Reactive/project.json | 31 + .../ClientConstructorTests.cs | 8 +- .../InterfaceHasAdditionalMethodsException.cs | 5 - .../InterfaceMethodsMismatchException.cs | 5 - .../InterfaceMissingMethodsException.cs | 5 - .../Exception/InterfaceNotFoundException.cs | 5 - .../ParameterCountMismatchException.cs | 5 - .../Exception/ParameterMismatchException.cs | 5 - .../Exception/ReturnValueMismatchException.cs | 5 - Octokit.Tests.Conventions/ModelTests.cs | 7 +- .../Octokit.Tests.Conventions.csproj | 125 ---- .../Octokit.Tests.Conventions.xproj | 22 + Octokit.Tests.Conventions/PaginationTests.cs | 7 +- .../SyncObservableClients.cs | 7 +- Octokit.Tests.Conventions/TypeExtensions.cs | 38 +- Octokit.Tests.Conventions/packages.config | 12 - Octokit.Tests.Conventions/project.json | 49 ++ Octokit.Tests.Integration/Helper.cs | 4 +- .../Octokit.Tests.Integration.csproj | 229 -------- .../Octokit.Tests.Integration.xproj | 21 + .../ObservableFollowersClientTests.cs | 4 +- Octokit.Tests.Integration/SelfTests.cs | 5 +- Octokit.Tests.Integration/packages.config | 13 - Octokit.Tests.Integration/project.json | 48 ++ .../Clients/AuthorizationsClientTests.cs | 8 +- Octokit.Tests/Exceptions/ApiExceptionTests.cs | 4 +- .../Exceptions/ApiValidationExceptionTests.cs | 4 +- .../RateLimitExceededExceptionTests.cs | 4 +- Octokit.Tests/Fixtures/EmbeddedResource.cs | 10 +- Octokit.Tests/Fixtures/Fixtures.cs | 35 +- Octokit.Tests/Http/RateLimitTests.cs | 4 +- Octokit.Tests/OctoKit.Tests-NetCore45.csproj | 204 ------- Octokit.Tests/Octokit.Tests-Portable.csproj | 220 ------- Octokit.Tests/Octokit.Tests.csproj | 319 ---------- .../Octokit.Tests.xproj | 6 +- .../Reactive/ObservableGistsTests.cs | 1 - Octokit.Tests/SelfTests.cs | 9 +- .../packages.Octokit.Tests-NetCore45.config | 14 - .../packages.Octokit.Tests-Portable.config | 18 - Octokit.Tests/packages.Octokit.Tests.config | 17 - Octokit.Tests/project.json | 42 ++ Octokit/Clients/ApiPagination.cs | 2 - Octokit/Clients/AuthorizationsClient.cs | 2 - Octokit/Clients/IAuthorizationsClient.cs | 2 - Octokit/Clients/IIssueTimelineClient.cs | 4 +- Octokit/Clients/IMiscellaneousClient.cs | 4 +- Octokit/Clients/IOrganizationsClient.cs | 5 +- Octokit/Clients/IReleasesClient.cs | 4 +- Octokit/Clients/IRepoCollaboratorsClient.cs | 2 - Octokit/Clients/IRepositoriesClient.cs | 2 - Octokit/Clients/IRepositoryBranchesClient.cs | 2 - Octokit/Clients/ITeamsClient.cs | 2 - Octokit/Clients/IssueTimelineClient.cs | 4 +- Octokit/Clients/IssuesEventsClient.cs | 4 +- Octokit/Clients/MiscellaneousClient.cs | 2 - Octokit/Clients/OrganizationsClient.cs | 2 - Octokit/Clients/ReleasesClient.cs | 4 +- Octokit/Clients/RepoCollaboratorsClient.cs | 4 +- Octokit/Clients/RepositoriesClient.cs | 2 - Octokit/Clients/RepositoryDeployKeysClient.cs | 2 - Octokit/Clients/TeamsClient.cs | 2 - Octokit/Exceptions/AbuseException.cs | 6 +- Octokit/Exceptions/ApiException.cs | 6 +- Octokit/Exceptions/ApiValidationException.cs | 6 +- Octokit/Exceptions/AuthorizationException.cs | 6 +- Octokit/Exceptions/ForbiddenException.cs | 6 +- .../InvalidGitIgnoreTemplateException.cs | 6 +- .../Exceptions/LegalRestrictionException.cs | 6 +- .../LoginAttemptsExceededException.cs | 6 +- Octokit/Exceptions/NotFoundException.cs | 6 +- ...PrivateRepositoryQuotaExceededException.cs | 6 +- .../PullRequestMismatchException.cs | 6 +- .../PullRequestNotMergeableException.cs | 6 +- .../Exceptions/RateLimitExceededException.cs | 6 +- .../Exceptions/RepositoryExistsException.cs | 6 +- .../Exceptions/RepositoryFormatException.cs | 6 +- .../RepositoryWebHookConfigException.cs | 6 +- .../TwoFactorAuthorizationException.cs | 6 +- .../TwoFactorChallengeFailedException.cs | 6 +- .../Exceptions/TwoFactorRequiredException.cs | 6 +- Octokit/Helpers/ApiExtensions.cs | 2 - Octokit/Helpers/EnumExtensions.cs | 1 + Octokit/Helpers/IApiPagination.cs | 2 - Octokit/Helpers/ReflectionExtensions.cs | 23 +- Octokit/Helpers/StringExtensions.cs | 10 +- Octokit/Http/ApiInfo.cs | 2 - Octokit/Http/ApiInfoParser.cs | 9 +- Octokit/Http/Connection.cs | 35 +- Octokit/Http/RateLimit.cs | 8 +- Octokit/Models/Request/InvitationUpdate.cs | 1 - Octokit/Models/Request/RequestParameters.cs | 1 + Octokit/Models/Response/ApiError.cs | 2 +- Octokit/Models/Response/ApiErrorDetail.cs | 2 +- Octokit/Octokit-Mono.csproj | 511 ---------------- Octokit/Octokit-MonoAndroid.csproj | 522 ----------------- Octokit/Octokit-Monotouch.csproj | 519 ----------------- Octokit/Octokit-Portable.csproj | 542 ----------------- Octokit/Octokit-netcore45.csproj | 527 ----------------- Octokit/Octokit.csproj | 545 ------------------ Octokit/Octokit.csproj.DotSettings | 6 - .../Octokit.xproj | 6 +- Octokit/SimpleJson.cs | 60 +- Octokit/packages.Octokit-Portable.config | 7 - Octokit/packages.config | 4 - Octokit/project.json | 50 ++ appveyor.yml | 7 +- build.cmd | 29 +- build.fsx | 337 ----------- build.sh | 23 +- build/.vscode/launch.json | 23 + build/.vscode/tasks.json | 16 + build/PdbGit/PdbGitAliases.cs | 21 + build/PdbGit/PdbGitMethod.cs | 5 + build/PdbGit/PdbGitRunner.cs | 90 +++ build/PdbGit/PdbGitSettings.cs | 11 + build/Program.cs | 31 + build/Tasks/Build.cs | 23 + build/Tasks/Clean.cs | 14 + build/Tasks/Default.cs | 6 + build/Tasks/IntegrationTests.cs | 39 ++ build/Tasks/LinkSources.cs | 48 ++ build/Tasks/Package.cs | 28 + build/Tasks/Restore.cs | 18 + build/Tasks/UnitTests.cs | 25 + build/Tasks/UpdateVersionInfo.cs | 23 + build/Utilities/BuildContext.cs | 31 + build/Utilities/BuildLifetime.cs | 143 +++++ build/Utilities/BuildVersion.cs | 16 + build/Utilities/Project.cs | 11 + build/build.sln | 22 + build/build.xproj | 19 + build/nuget.config | 6 + build/project.json | 18 + build/tools.project.json | 10 + global.json | 12 + 155 files changed, 1334 insertions(+), 6014 deletions(-) delete mode 100644 Octokit.Next.Tests/CalculatorTests.cs delete mode 100644 Octokit.Next.Tests/Properties/AssemblyInfo.cs delete mode 100644 Octokit.Next.Tests/project.json delete mode 100644 Octokit.Next/Calculator.cs delete mode 100644 Octokit.Next/Properties/AssemblyInfo.cs delete mode 100644 Octokit.Next/project.json delete mode 100644 Octokit.Reactive/Octokit.Reactive-Mono.csproj delete mode 100644 Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj delete mode 100644 Octokit.Reactive/Octokit.Reactive-Monotouch.csproj delete mode 100644 Octokit.Reactive/Octokit.Reactive.csproj delete mode 100644 Octokit.Reactive/Octokit.Reactive.csproj.DotSettings create mode 100644 Octokit.Reactive/Octokit.Reactive.xproj delete mode 100644 Octokit.Reactive/packages.config create mode 100644 Octokit.Reactive/project.json delete mode 100644 Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj create mode 100644 Octokit.Tests.Conventions/Octokit.Tests.Conventions.xproj delete mode 100644 Octokit.Tests.Conventions/packages.config create mode 100644 Octokit.Tests.Conventions/project.json delete mode 100644 Octokit.Tests.Integration/Octokit.Tests.Integration.csproj create mode 100644 Octokit.Tests.Integration/Octokit.Tests.Integration.xproj delete mode 100644 Octokit.Tests.Integration/packages.config create mode 100644 Octokit.Tests.Integration/project.json delete mode 100644 Octokit.Tests/OctoKit.Tests-NetCore45.csproj delete mode 100644 Octokit.Tests/Octokit.Tests-Portable.csproj delete mode 100644 Octokit.Tests/Octokit.Tests.csproj rename Octokit.Next.Tests/Octokit.Next.Tests.xproj => Octokit.Tests/Octokit.Tests.xproj (85%) delete mode 100644 Octokit.Tests/packages.Octokit.Tests-NetCore45.config delete mode 100644 Octokit.Tests/packages.Octokit.Tests-Portable.config delete mode 100644 Octokit.Tests/packages.Octokit.Tests.config create mode 100644 Octokit.Tests/project.json delete mode 100644 Octokit/Octokit-Mono.csproj delete mode 100644 Octokit/Octokit-MonoAndroid.csproj delete mode 100644 Octokit/Octokit-Monotouch.csproj delete mode 100644 Octokit/Octokit-Portable.csproj delete mode 100644 Octokit/Octokit-netcore45.csproj delete mode 100644 Octokit/Octokit.csproj delete mode 100644 Octokit/Octokit.csproj.DotSettings rename Octokit.Next/Octokit.Next.xproj => Octokit/Octokit.xproj (85%) delete mode 100644 Octokit/packages.Octokit-Portable.config delete mode 100644 Octokit/packages.config create mode 100644 Octokit/project.json delete mode 100644 build.fsx create mode 100644 build/.vscode/launch.json create mode 100644 build/.vscode/tasks.json create mode 100644 build/PdbGit/PdbGitAliases.cs create mode 100644 build/PdbGit/PdbGitMethod.cs create mode 100644 build/PdbGit/PdbGitRunner.cs create mode 100644 build/PdbGit/PdbGitSettings.cs create mode 100644 build/Program.cs create mode 100644 build/Tasks/Build.cs create mode 100644 build/Tasks/Clean.cs create mode 100644 build/Tasks/Default.cs create mode 100644 build/Tasks/IntegrationTests.cs create mode 100644 build/Tasks/LinkSources.cs create mode 100644 build/Tasks/Package.cs create mode 100644 build/Tasks/Restore.cs create mode 100644 build/Tasks/UnitTests.cs create mode 100644 build/Tasks/UpdateVersionInfo.cs create mode 100644 build/Utilities/BuildContext.cs create mode 100644 build/Utilities/BuildLifetime.cs create mode 100644 build/Utilities/BuildVersion.cs create mode 100644 build/Utilities/Project.cs create mode 100644 build/build.sln create mode 100644 build/build.xproj create mode 100644 build/nuget.config create mode 100644 build/project.json create mode 100644 build/tools.project.json create mode 100644 global.json diff --git a/.gitignore b/.gitignore index 04f07c74..ce0dac36 100644 --- a/.gitignore +++ b/.gitignore @@ -94,4 +94,13 @@ docs/_build Backup/ # .NET Core -project.lock.json \ No newline at end of file +*.lock.json + +# VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json + +# CAKE +tools/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 811de032..35172222 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,22 +5,14 @@ matrix: - os: linux dist: trusty sudo: required - mono: 4.2.3 dotnet: 1.0.0-preview2-003121 - os: osx osx_image: xcode8 - mono: 4.2.3 dotnet: 1.0.0-preview2-003121 before_install: - if test "$TRAVIS_OS_NAME" == "osx"; then ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi -install: - - nuget restore Octokit-Mono.sln - script: - - mono tools/nuget/NuGet.exe restore Octokit-Mono.sln - - ./build.sh BuildMono - - ./build.sh - dotnet --info - - ./build.sh UnitTestsDotNetCore + - ./build.sh diff --git a/Octokit.Core.sln b/Octokit.Core.sln index ed6aab09..035fbc0a 100644 --- a/Octokit.Core.sln +++ b/Octokit.Core.sln @@ -3,9 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Next", "Octokit.Next\Octokit.Next.xproj", "{4052AF53-4C1B-48D1-B873-BFD0351481C3}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit", "Octokit\Octokit.xproj", "{104E8324-C2B9-43BE-8040-36B736A64D45}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Next.Tests", "Octokit.Next.Tests\Octokit.Next.Tests.xproj", "{2740AF44-CB2E-4FD8-A221-248693978A0C}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Reactive", "Octokit.Reactive\Octokit.Reactive.xproj", "{06B32A68-FEE5-4C0C-989A-8A75D00D6D3E}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Tests", "Octokit.Tests\Octokit.Tests.xproj", "{E58EC0EA-B6E5-43AA-A7D2-AD0A6D4BB0D2}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Tests.Conventions", "Octokit.Tests.Conventions\Octokit.Tests.Conventions.xproj", "{A04124DC-D057-4DB0-8E5F-ECD114FA371A}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Octokit.Tests.Integration", "Octokit.Tests.Integration\Octokit.Tests.Integration.xproj", "{EF19E577-D810-4357-BF95-9029A359CB4E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +19,26 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4052AF53-4C1B-48D1-B873-BFD0351481C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4052AF53-4C1B-48D1-B873-BFD0351481C3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4052AF53-4C1B-48D1-B873-BFD0351481C3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4052AF53-4C1B-48D1-B873-BFD0351481C3}.Release|Any CPU.Build.0 = Release|Any CPU - {2740AF44-CB2E-4FD8-A221-248693978A0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2740AF44-CB2E-4FD8-A221-248693978A0C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2740AF44-CB2E-4FD8-A221-248693978A0C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2740AF44-CB2E-4FD8-A221-248693978A0C}.Release|Any CPU.Build.0 = Release|Any CPU + {104E8324-C2B9-43BE-8040-36B736A64D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {104E8324-C2B9-43BE-8040-36B736A64D45}.Debug|Any CPU.Build.0 = Debug|Any CPU + {104E8324-C2B9-43BE-8040-36B736A64D45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {104E8324-C2B9-43BE-8040-36B736A64D45}.Release|Any CPU.Build.0 = Release|Any CPU + {06B32A68-FEE5-4C0C-989A-8A75D00D6D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06B32A68-FEE5-4C0C-989A-8A75D00D6D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06B32A68-FEE5-4C0C-989A-8A75D00D6D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06B32A68-FEE5-4C0C-989A-8A75D00D6D3E}.Release|Any CPU.Build.0 = Release|Any CPU + {E58EC0EA-B6E5-43AA-A7D2-AD0A6D4BB0D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E58EC0EA-B6E5-43AA-A7D2-AD0A6D4BB0D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E58EC0EA-B6E5-43AA-A7D2-AD0A6D4BB0D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E58EC0EA-B6E5-43AA-A7D2-AD0A6D4BB0D2}.Release|Any CPU.Build.0 = Release|Any CPU + {A04124DC-D057-4DB0-8E5F-ECD114FA371A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A04124DC-D057-4DB0-8E5F-ECD114FA371A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A04124DC-D057-4DB0-8E5F-ECD114FA371A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A04124DC-D057-4DB0-8E5F-ECD114FA371A}.Release|Any CPU.Build.0 = Release|Any CPU + {EF19E577-D810-4357-BF95-9029A359CB4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF19E577-D810-4357-BF95-9029A359CB4E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF19E577-D810-4357-BF95-9029A359CB4E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF19E577-D810-4357-BF95-9029A359CB4E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Octokit.Next.Tests/CalculatorTests.cs b/Octokit.Next.Tests/CalculatorTests.cs deleted file mode 100644 index 7060e737..00000000 --- a/Octokit.Next.Tests/CalculatorTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Octokit.Next.Tests -{ - using Xunit; - - public class CalculatorTests - { - private readonly Calculator _sut; - - public CalculatorTests() - { - _sut = new Calculator(); - } - - [Theory] - [InlineData(1, 1, 2)] - [InlineData(1, 2, 3)] - [InlineData(2, 1, 3)] - [InlineData(-1, 1, 0)] - public void AddingTwoIntegers_ShouldReturnExpectedResult(int x, int y, int expected) - { - Assert.Equal(expected, _sut.Add(x, y)); - } - } -} diff --git a/Octokit.Next.Tests/Properties/AssemblyInfo.cs b/Octokit.Next.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index cc74232e..00000000 --- a/Octokit.Next.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Octokit.Next.Tests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2740af44-cb2e-4fd8-a221-248693978a0c")] diff --git a/Octokit.Next.Tests/project.json b/Octokit.Next.Tests/project.json deleted file mode 100644 index ca49aeef..00000000 --- a/Octokit.Next.Tests/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "1.0.0-*", - "testRunner": "xunit", - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - }, - "Octokit.Next": "*", - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "xunit": "2.2.0-beta2-build3300" - }, - "frameworks": { - "netcoreapp1.0": {} - } -} diff --git a/Octokit.Next/Calculator.cs b/Octokit.Next/Calculator.cs deleted file mode 100644 index 588dd523..00000000 --- a/Octokit.Next/Calculator.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Octokit.Next -{ - public class Calculator - { - public int Add(int x, int y) - { - return x + y; - } - } -} diff --git a/Octokit.Next/Properties/AssemblyInfo.cs b/Octokit.Next/Properties/AssemblyInfo.cs deleted file mode 100644 index 22c1c951..00000000 --- a/Octokit.Next/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Octokit.Next")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4052af53-4c1b-48d1-b873-bfd0351481c3")] diff --git a/Octokit.Next/project.json b/Octokit.Next/project.json deleted file mode 100644 index ae9aa1c1..00000000 --- a/Octokit.Next/project.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "NETStandard.Library": "1.6.0" - }, - - "frameworks": { - "netstandard1.1": {} - } -} diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs index 0a037406..d8ed9883 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLdapClient.cs @@ -3,7 +3,6 @@ using System.Reactive; using System.Reactive.Threading.Tasks; using Octokit; - namespace Octokit.Reactive { /// diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLicenseClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLicenseClient.cs index bf852483..3fbe6644 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLicenseClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseLicenseClient.cs @@ -2,7 +2,6 @@ using System.Reactive.Threading.Tasks; using Octokit; - namespace Octokit.Reactive { /// diff --git a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseOrganizationClient.cs b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseOrganizationClient.cs index 1f78574c..bf064920 100644 --- a/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseOrganizationClient.cs +++ b/Octokit.Reactive/Clients/Enterprise/ObservableEnterpriseOrganizationClient.cs @@ -2,7 +2,6 @@ using System.Reactive.Threading.Tasks; using Octokit; - namespace Octokit.Reactive { /// diff --git a/Octokit.Reactive/Clients/ObservableUserAdministrationClient.cs b/Octokit.Reactive/Clients/ObservableUserAdministrationClient.cs index bc0bf672..b5f8645b 100644 --- a/Octokit.Reactive/Clients/ObservableUserAdministrationClient.cs +++ b/Octokit.Reactive/Clients/ObservableUserAdministrationClient.cs @@ -4,7 +4,6 @@ using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; using System.Reactive.Linq; - namespace Octokit.Reactive { /// diff --git a/Octokit.Reactive/Octokit.Reactive-Mono.csproj b/Octokit.Reactive/Octokit.Reactive-Mono.csproj deleted file mode 100644 index 1f39b439..00000000 --- a/Octokit.Reactive/Octokit.Reactive-Mono.csproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {59AB16A2-5ED1-480F-80A1-D1D05D6C1BE4} - Library - Octokit.Reactive - Octokit.Reactive - v4.5 - 5 - - - true - full - false - obj\Debug\Mono - bin\Debug\Mono - DEBUG; - prompt - 4 - false - - - full - true - obj\Release\Mono - bin\Release\Mono - prompt - 4 - false - - - - - - ..\packages\Rx-Core.2.1.30214.0\lib\Net40\System.Reactive.Core.dll - - - ..\packages\Rx-Interfaces.2.1.30214.0\lib\Net40\System.Reactive.Interfaces.dll - - - ..\packages\Rx-Linq.2.1.30214.0\lib\Net40\System.Reactive.Linq.dll - - - ..\packages\Rx-PlatformServices.2.1.30214.0\lib\Net40\System.Reactive.PlatformServices.dll - - - - - Helpers\Ensure.cs - - - Helpers\Pagination.cs - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4} - Octokit-Mono - - - \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj b/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj deleted file mode 100644 index 2d50f637..00000000 --- a/Octokit.Reactive/Octokit.Reactive-MonoAndroid.csproj +++ /dev/null @@ -1,225 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {B24FC6FF-0801-4FC7-8AFF-05DE2C923869} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Octokit.Reactive - Resources - Assets - False - Octokit.Reactive - 5 - - - true - full - false - obj\Debug\MonoAndroid - bin\Debug\MonoAndroid - DEBUG; - prompt - 4 - None - false - - - full - true - obj\Release\MonoAndroid - bin\Release\MonoAndroid - prompt - 4 - false - false - - - - - - - - - ..\ext\Monoandroid\System.Reactive.Core.dll - - - ..\ext\Monoandroid\System.Reactive.Interfaces.dll - - - ..\ext\Monoandroid\System.Reactive.Linq.dll - - - ..\ext\Monoandroid\System.Reactive.PlatformServices.dll - - - - - Helpers\Ensure.cs - - - Helpers\Pagination.cs - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {B24FC6FA-B80C-4EC7-8AFF-05DE2C923869} - Octokit-MonoAndroid - - - \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj b/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj deleted file mode 100644 index c38c9094..00000000 --- a/Octokit.Reactive/Octokit.Reactive-Monotouch.csproj +++ /dev/null @@ -1,221 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {F4ADA431-8344-4B36-9A0B-C4D96AF53908} - {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Octokit.Reactive - Resources - Octokit.Reactive - 5 - - - true - full - false - obj\Debug\Monotouch - bin\Debug\Monotouch - DEBUG; - prompt - 4 - false - - - full - true - obj\Release\Monotouch - bin\Release\Monotouch - prompt - 4 - false - - - - - - - - - ..\ext\Monotouch\System.Reactive.Core.dll - - - ..\ext\Monotouch\System.Reactive.Interfaces.dll - - - ..\ext\Monotouch\System.Reactive.Linq.dll - - - ..\ext\Monotouch\System.Reactive.PlatformServices.dll - - - - - Helpers\Ensure.cs - - - Helpers\Pagination.cs - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {E4AD1421-8844-4236-9A0B-C4D96AF53908} - Octokit-Monotouch - - - \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj deleted file mode 100644 index 70733536..00000000 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ /dev/null @@ -1,245 +0,0 @@ - - - - - Debug - AnyCPU - {674B69B8-0780-4D54-AE2B-C15821FA51CB} - Library - Properties - Octokit.Reactive - Octokit.Reactive - v4.5 - 512 - 5 - - - true - full - false - obj\Debug\Net40 - bin\Debug\Net45\ - TRACE;DEBUG;CODE_ANALYSIS;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - true - true - ..\Octokit.ruleset - false - - - pdbonly - true - obj\Release\Net40 - bin\Release\Net45\ - TRACE;CODE_ANALYSIS;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - false - true - ..\Octokit.ruleset - bin\Release\Net45\Octokit.Reactive.XML - 1591 - - - - - - - - False - ..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - False - ..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - False - ..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll - - - False - ..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll - - - - - - - - - - Helpers\Ensure.cs - - - Helpers\Pagination.cs - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CustomDictionary.xml - - - - - {08dd4305-7787-4823-a53f-4d0f725a07f3} - Octokit - - - - - \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings b/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings deleted file mode 100644 index a4f335fe..00000000 --- a/Octokit.Reactive/Octokit.Reactive.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/Octokit.Reactive/Octokit.Reactive.xproj b/Octokit.Reactive/Octokit.Reactive.xproj new file mode 100644 index 00000000..e7fdd9cf --- /dev/null +++ b/Octokit.Reactive/Octokit.Reactive.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 06b32a68-fee5-4c0c-989a-8a75d00d6d3e + Octokit.Reactive + .\obj + .\bin\ + v4.6 + + + 2.0 + + + \ No newline at end of file diff --git a/Octokit.Reactive/packages.config b/Octokit.Reactive/packages.config deleted file mode 100644 index 571e4fe0..00000000 --- a/Octokit.Reactive/packages.config +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Octokit.Reactive/project.json b/Octokit.Reactive/project.json new file mode 100644 index 00000000..1de32a8a --- /dev/null +++ b/Octokit.Reactive/project.json @@ -0,0 +1,31 @@ +{ + "version": "1.0.0-*", + "title": "Octokit.Reactive", + "authors": [ + "GitHub" + ], + "description": "An IObservable based GitHub API client library for .NET using Reactive Extensions", + "xmlDoc": true, + "buildOptions": { + "compile": { + "includeFiles": [ + "../SolutionInfo.cs", + "../Octokit/Helpers/Ensure.cs", + "../Octokit/Helpers/Pagination.cs" + ] + } + }, + "packOptions": { + "summary": "An IObservable based GitHub API client library for .NET using Reactive Extensions" + }, + "dependencies": { + "Octokit": { + "target": "project" + }, + "System.Reactive": "3.1.0" + }, + "frameworks": { + "netstandard1.1": {}, + "net45": {} + } +} \ No newline at end of file diff --git a/Octokit.Tests.Conventions/ClientConstructorTests.cs b/Octokit.Tests.Conventions/ClientConstructorTests.cs index eadd60d5..048e3a5c 100644 --- a/Octokit.Tests.Conventions/ClientConstructorTests.cs +++ b/Octokit.Tests.Conventions/ClientConstructorTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using Xunit; namespace Octokit.Tests.Conventions @@ -14,14 +15,14 @@ namespace Octokit.Tests.Conventions const string constructorTestClassName = "TheCtor"; const string constructorTestMethodName = "EnsuresNonNullArguments"; - var classes = new HashSet(type.GetNestedTypes().Select(t => t.Name)); + var classes = new HashSet(type.GetTypeInfo().GetNestedTypes().Select(t => t.Name)); if (!classes.Contains(constructorTestClassName)) { throw new MissingClientConstructorTestClassException(type); } - var ctors = type.GetNestedTypes().Where(t => t.Name == constructorTestClassName) + var ctors = type.GetTypeInfo().GetNestedTypes().Where(t => t.Name == constructorTestClassName) .SelectMany(t => t.GetMethods()) .Where(info => info.ReturnType == typeof(void) && info.IsPublic) .Select(info => info.Name); @@ -36,9 +37,10 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetTestConstructorClasses() { var tests = typeof(GitHubClientTests) + .GetTypeInfo() .Assembly .ExportedTypes - .Where(type => type.IsClass && type.IsPublic && type.Name.EndsWith("ClientTests")) + .Where(type => type.GetTypeInfo().IsClass && type.GetTypeInfo().IsPublic && type.Name.EndsWith("ClientTests")) .Select(type => new[] { type }); return tests; } diff --git a/Octokit.Tests.Conventions/Exception/InterfaceHasAdditionalMethodsException.cs b/Octokit.Tests.Conventions/Exception/InterfaceHasAdditionalMethodsException.cs index 96bafa2a..d037bc62 100644 --- a/Octokit.Tests.Conventions/Exception/InterfaceHasAdditionalMethodsException.cs +++ b/Octokit.Tests.Conventions/Exception/InterfaceHasAdditionalMethodsException.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -15,10 +14,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(type, methodsMissingOnReactiveClient), innerException) { } - protected InterfaceHasAdditionalMethodsException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateMessage(Type type, IEnumerable methods) { var methodsFormatted = string.Join("\r\n", methods.Select(m => string.Format(" - {0}", m))); diff --git a/Octokit.Tests.Conventions/Exception/InterfaceMethodsMismatchException.cs b/Octokit.Tests.Conventions/Exception/InterfaceMethodsMismatchException.cs index b8564a60..1fde7f19 100644 --- a/Octokit.Tests.Conventions/Exception/InterfaceMethodsMismatchException.cs +++ b/Octokit.Tests.Conventions/Exception/InterfaceMethodsMismatchException.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Reflection; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -15,10 +14,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(type, clientInterface), innerException) { } - protected InterfaceMethodsMismatchException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string Format(ParameterInfo parameterInfo) { return string.Format("{0} {1}", parameterInfo.ParameterType.Name, parameterInfo.Name); diff --git a/Octokit.Tests.Conventions/Exception/InterfaceMissingMethodsException.cs b/Octokit.Tests.Conventions/Exception/InterfaceMissingMethodsException.cs index 268eaa5f..37146fe4 100644 --- a/Octokit.Tests.Conventions/Exception/InterfaceMissingMethodsException.cs +++ b/Octokit.Tests.Conventions/Exception/InterfaceMissingMethodsException.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -15,10 +14,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(type, methodsMissingOnReactiveClient), innerException) { } - protected InterfaceMissingMethodsException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateMessage(Type type, IEnumerable methods) { var methodsFormatted = string.Join("\r\n", methods.Select(m => string.Format(" - {0}", m))); diff --git a/Octokit.Tests.Conventions/Exception/InterfaceNotFoundException.cs b/Octokit.Tests.Conventions/Exception/InterfaceNotFoundException.cs index 6dd6f93a..cf27076c 100644 --- a/Octokit.Tests.Conventions/Exception/InterfaceNotFoundException.cs +++ b/Octokit.Tests.Conventions/Exception/InterfaceNotFoundException.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -15,10 +14,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(type), innerException) { } - protected InterfaceNotFoundException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateMessage(string type) { return string.Format("Could not find the interface {0}. Add this to the Octokit.Reactive project", type); diff --git a/Octokit.Tests.Conventions/Exception/ParameterCountMismatchException.cs b/Octokit.Tests.Conventions/Exception/ParameterCountMismatchException.cs index 24e9efc4..bd612a08 100644 --- a/Octokit.Tests.Conventions/Exception/ParameterCountMismatchException.cs +++ b/Octokit.Tests.Conventions/Exception/ParameterCountMismatchException.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -16,10 +15,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(method, expected, actual), innerException) { } - protected ParameterCountMismatchException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateMethodSignature(IEnumerable parameters) { return string.Join(",", parameters.Select(p => string.Format("{0} {1}", p.ParameterType.Name, p.Name))); diff --git a/Octokit.Tests.Conventions/Exception/ParameterMismatchException.cs b/Octokit.Tests.Conventions/Exception/ParameterMismatchException.cs index 519ad348..f43ae8d2 100644 --- a/Octokit.Tests.Conventions/Exception/ParameterMismatchException.cs +++ b/Octokit.Tests.Conventions/Exception/ParameterMismatchException.cs @@ -1,6 +1,5 @@ using System; using System.Reflection; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -14,10 +13,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(method, position, expected, actual), innerException) { } - protected ParameterMismatchException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateParameterSignature(ParameterInfo parameter) { return string.Format("{0} {1}", parameter.ParameterType.Name, parameter.Name); diff --git a/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs b/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs index 533cfb2c..f7271b25 100644 --- a/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs +++ b/Octokit.Tests.Conventions/Exception/ReturnValueMismatchException.cs @@ -1,6 +1,5 @@ using System; using System.Reflection; -using System.Runtime.Serialization; namespace Octokit.Tests.Conventions { @@ -14,10 +13,6 @@ namespace Octokit.Tests.Conventions : base(CreateMessage(method, expected, actual), innerException) { } - protected ReturnValueMismatchException(SerializationInfo info, StreamingContext context) - : base(info, context) - { } - static string CreateMessage(MethodInfo method, Type expected, Type actual) { return string.Format("Return value for {0}.{1} must be \"{2}\" but is \"{3}\"", method.DeclaringType.Name, method.Name, expected, actual); diff --git a/Octokit.Tests.Conventions/ModelTests.cs b/Octokit.Tests.Conventions/ModelTests.cs index 7da1fcec..9bf9f771 100644 --- a/Octokit.Tests.Conventions/ModelTests.cs +++ b/Octokit.Tests.Conventions/ModelTests.cs @@ -14,7 +14,7 @@ namespace Octokit.Tests.Conventions [MemberData("ModelTypes")] public void AllModelsHaveDebuggerDisplayAttribute(Type modelType) { - var attribute = modelType.GetCustomAttribute(inherit: false); + var attribute = modelType.GetTypeInfo().GetCustomAttribute(inherit: false); if (attribute == null) { throw new MissingDebuggerDisplayAttributeException(modelType); @@ -110,6 +110,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { return typeof(IGitHubClient) + .GetTypeInfo() .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) @@ -131,7 +132,7 @@ namespace Octokit.Tests.Conventions { var allModelTypes = new HashSet(); - var clientInterfaces = typeof(IGitHubClient).Assembly.ExportedTypes + var clientInterfaces = typeof(IGitHubClient).GetTypeInfo().Assembly.ExportedTypes .Where(type => type.IsClientInterface()); foreach (var exportedType in clientInterfaces) @@ -191,7 +192,7 @@ namespace Octokit.Tests.Conventions private static IEnumerable UnwrapGenericArguments(Type returnType) { - if (returnType.IsGenericType) + if (returnType.GetTypeInfo().IsGenericType) { var arguments = returnType.GetGenericArguments(); diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj deleted file mode 100644 index 412724b7..00000000 --- a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.csproj +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - Debug - AnyCPU - {5345E2E6-4E7C-40F8-831B-E491F6051D3C} - Library - Properties - Octokit.Tests.Conventions - Octokit.Tests.Conventions - v4.5 - 512 - - - 5 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - False - ..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - False - ..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {674b69b8-0780-4d54-ae2b-c15821fa51cb} - Octokit.Reactive - - - {149448d4-c2f2-4df9-86bd-03e3272f093b} - Octokit.Tests - - - {08dd4305-7787-4823-a53f-4d0f725a07f3} - Octokit - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/Octokit.Tests.Conventions/Octokit.Tests.Conventions.xproj b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.xproj new file mode 100644 index 00000000..185e1776 --- /dev/null +++ b/Octokit.Tests.Conventions/Octokit.Tests.Conventions.xproj @@ -0,0 +1,22 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + a04124dc-d057-4db0-8e5f-ecd114fa371a + Octokit.Tests.Conventions + .\obj + .\bin\ + v4.6 + + + 2.0 + + + + + + \ No newline at end of file diff --git a/Octokit.Tests.Conventions/PaginationTests.cs b/Octokit.Tests.Conventions/PaginationTests.cs index 2c4cb774..0b28e3e8 100644 --- a/Octokit.Tests.Conventions/PaginationTests.cs +++ b/Octokit.Tests.Conventions/PaginationTests.cs @@ -34,7 +34,7 @@ namespace Octokit.Tests.Conventions var methodsOrdered = clientInterface.GetMethodsOrdered(); var methodsThatCanPaginate = methodsOrdered - .Where(x => x.ReturnType.GetTypeInfo().TypeCategory == TypeCategory.ReadOnlyList) + .Where(x => x.ReturnType.GetCustomTypeInfo().TypeCategory == TypeCategory.ReadOnlyList) .Where(x => x.Name.StartsWith("Get") && !x.HasAttribute()); var invalidMethods = methodsThatCanPaginate @@ -89,7 +89,10 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { - return typeof(IGitHubClient).Assembly.ExportedTypes + return typeof(IGitHubClient) + .GetTypeInfo() + .Assembly + .ExportedTypes .Where(TypeExtensions.IsClientInterface) .Where(type => type != typeof(IStatisticsClient)) .Select(type => new[] { type }); diff --git a/Octokit.Tests.Conventions/SyncObservableClients.cs b/Octokit.Tests.Conventions/SyncObservableClients.cs index 02fd3981..e15fc001 100644 --- a/Octokit.Tests.Conventions/SyncObservableClients.cs +++ b/Octokit.Tests.Conventions/SyncObservableClients.cs @@ -17,8 +17,8 @@ namespace Octokit.Tests.Conventions var observableClient = clientInterface.GetObservableClientInterface(); var mainMethods = clientInterface.GetMethodsOrdered(); var observableMethods = observableClient.GetMethodsOrdered(); - var mainNames = Array.ConvertAll(mainMethods, m => m.Name); - var observableNames = Array.ConvertAll(observableMethods, m => m.Name); + var mainNames = mainMethods.Select(x => x.Name).ToArray(); + var observableNames = observableMethods.Select(x => x.Name).ToArray(); var methodsMissingOnReactiveClient = mainNames.Except(observableNames).ToList(); if (methodsMissingOnReactiveClient.Any()) @@ -68,7 +68,7 @@ namespace Octokit.Tests.Conventions private static Type GetObservableExpectedType(Type mainType) { - var typeInfo = mainType.GetTypeInfo(); + var typeInfo = mainType.GetCustomTypeInfo(); switch (typeInfo.TypeCategory) { case TypeCategory.ClientInterface: @@ -121,6 +121,7 @@ namespace Octokit.Tests.Conventions public static IEnumerable GetClientInterfaces() { return typeof(IGitHubClient) + .GetTypeInfo() .Assembly .ExportedTypes .Where(TypeExtensions.IsClientInterface) diff --git a/Octokit.Tests.Conventions/TypeExtensions.cs b/Octokit.Tests.Conventions/TypeExtensions.cs index 95610c51..b010b9ea 100644 --- a/Octokit.Tests.Conventions/TypeExtensions.cs +++ b/Octokit.Tests.Conventions/TypeExtensions.cs @@ -32,52 +32,53 @@ namespace Octokit.Tests.Conventions .ToArray(); } - public static TypeInfo GetTypeInfo(this Type type) + public static CustomTypeInfo GetCustomTypeInfo(this Type type) { - var typeInfo = new TypeInfo { Type = type, TypeCategory = TypeCategory.Other }; + var customTypeInfo = new CustomTypeInfo { Type = type, TypeCategory = TypeCategory.Other }; if (type.IsClientInterface()) { - typeInfo.TypeCategory = TypeCategory.ClientInterface; + customTypeInfo.TypeCategory = TypeCategory.ClientInterface; } else if (type.IsTask()) { - if (!type.IsGenericType) + if (!type.GetTypeInfo().IsGenericType) { - typeInfo.TypeCategory = TypeCategory.Task; + customTypeInfo.TypeCategory = TypeCategory.Task; } else { var taskResultType = type.GetGenericArgument(); if (taskResultType.IsList()) { - typeInfo.TypeCategory = TypeCategory.ReadOnlyList; - typeInfo.Type = taskResultType.GetGenericArgument(); + customTypeInfo.TypeCategory = TypeCategory.ReadOnlyList; + customTypeInfo.Type = taskResultType.GetGenericArgument(); } else { - typeInfo.TypeCategory = TypeCategory.GenericTask; - typeInfo.Type = taskResultType; + customTypeInfo.TypeCategory = TypeCategory.GenericTask; + customTypeInfo.Type = taskResultType; } } } - return typeInfo; + return customTypeInfo; } public static bool IsModel(this Type type) { - return !type.IsInterface && !type.IsEnum && type.Assembly == typeof(AuthorizationUpdate).Assembly; + var typeInfo = type.GetTypeInfo(); + return !typeInfo.IsInterface && !typeInfo.IsEnum && typeInfo.Assembly == typeof(AuthorizationUpdate).GetTypeInfo().Assembly; } public static bool IsClientInterface(this Type type) { - return type.IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IGitHubClient).Namespace; + return type.GetTypeInfo().IsInterface && type.Name.EndsWith(ClientSuffix) && type.Namespace == typeof(IGitHubClient).Namespace; } public static Type GetObservableClientInterface(this Type type) { var observableClient = typeof(IObservableEventsClient); var observableClientName = observableClient.Namespace + "." + ObservablePrefix + type.Name.Substring(RealNameIndex); - var observableInterface = observableClient.Assembly.GetType(observableClientName); + var observableInterface = observableClient.GetTypeInfo().Assembly.GetType(observableClientName); if (observableInterface == null) { throw new InterfaceNotFoundException(observableClientName); @@ -92,7 +93,7 @@ namespace Octokit.Tests.Conventions public static bool IsList(this Type type) { - return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IReadOnlyList<>); + return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(IReadOnlyList<>); } public static Type GetGenericArgument(this Type type) @@ -102,14 +103,15 @@ namespace Octokit.Tests.Conventions public static bool IsReadOnlyCollection(this Type type) { - var isReadOnlyList = type.HasGenericTypeDefinition(typeof(IReadOnlyList<>)); + var typeInfo = type.GetTypeInfo(); - var isReadOnlyDictionary = type.HasGenericTypeDefinition(typeof(IReadOnlyDictionary<,>)); + var isReadOnlyList = typeInfo.HasGenericTypeDefinition(typeof(IReadOnlyList<>)); + var isReadOnlyDictionary = typeInfo.HasGenericTypeDefinition(typeof(IReadOnlyDictionary<,>)); return isReadOnlyList || isReadOnlyDictionary; } - private static bool HasGenericTypeDefinition(this Type type, Type genericTypeDefinition) + private static bool HasGenericTypeDefinition(this TypeInfo type, Type genericTypeDefinition) { return type.IsGenericType && type.GetGenericTypeDefinition() == genericTypeDefinition; } @@ -117,7 +119,7 @@ namespace Octokit.Tests.Conventions public enum TypeCategory { Other, Task, GenericTask, ReadOnlyList, ClientInterface } - public struct TypeInfo + public struct CustomTypeInfo { public Type Type { get; set; } public TypeCategory TypeCategory { get; set; } diff --git a/Octokit.Tests.Conventions/packages.config b/Octokit.Tests.Conventions/packages.config deleted file mode 100644 index d8e9b479..00000000 --- a/Octokit.Tests.Conventions/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests.Conventions/project.json b/Octokit.Tests.Conventions/project.json new file mode 100644 index 00000000..256cd543 --- /dev/null +++ b/Octokit.Tests.Conventions/project.json @@ -0,0 +1,49 @@ +{ + "version": "1.0.0-*", + "testRunner": "xunit", + "title": "Octokit.Tests.Conventions", + "authors": [ + "GitHub" + ], + "description": "Convention-based tests for Octokit", + "xmlDoc": true, + "buildOptions": { + "nowarn": [ + "CS4014", + "CS1998" + ], + "compile": { + "includeFiles": [ + "../Octokit.Tests/Helpers/AssertEx.cs" + ] + } + }, + "frameworks": { + "netcoreapp1.0": { + "buildOptions": { + "define": [ + "NO_SERIALIZABLE", + "HAS_TYPEINFO" + ] + }, + "dependencies": { + "Octokit": { + "target": "project" + }, + "Octokit.Reactive": { + "target": "project" + }, + "Octokit.Tests": { + "target": "project" + }, + "NETStandard.Library": "1.6.0", + "xunit": "2.2.0-beta2-build3300", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Helper.cs b/Octokit.Tests.Integration/Helper.cs index d5225abe..32df12ef 100644 --- a/Octokit.Tests.Integration/Helper.cs +++ b/Octokit.Tests.Integration/Helper.cs @@ -1,7 +1,7 @@ using System; using System.Diagnostics; using System.IO; -using Octokit.Reactive; +using System.Reflection; namespace Octokit.Tests.Integration { @@ -183,7 +183,7 @@ namespace Octokit.Tests.Integration public static Stream LoadFixture(string fileName) { var key = "Octokit.Tests.Integration.fixtures." + fileName; - var stream = typeof(Helper).Assembly.GetManifestResourceStream(key); + var stream = typeof(Helper).GetTypeInfo().Assembly.GetManifestResourceStream(key); if (stream == null) { throw new InvalidOperationException( diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj deleted file mode 100644 index 6aef864f..00000000 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - Debug - AnyCPU - {01687D54-1D87-4562-A721-C57F1C94052C} - Library - Properties - Octokit.Tests.Integration - Octokit.Tests.Integration - v4.5 - 512 - - - 5 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 4014, 1998 - - - pdbonly - true - bin\Release\Net45\ - TRACE - prompt - 4 - 4014, 1998 - - - - - - - - - False - ..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - False - ..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - False - ..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll - - - - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {674b69b8-0780-4d54-ae2b-c15821fa51cb} - Octokit.Reactive - - - {149448d4-c2f2-4df9-86bd-03e3272f093b} - Octokit.Tests - - - {08dd4305-7787-4823-a53f-4d0f725a07f3} - Octokit - - - - - - - Designer - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.xproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.xproj new file mode 100644 index 00000000..5d3e4a90 --- /dev/null +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.xproj @@ -0,0 +1,21 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + ef19e577-d810-4357-bf95-9029a359cb4e + Octokit.Tests.Integration + .\obj + .\bin\ + + + 2.0 + + + + + + \ No newline at end of file diff --git a/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs index 1eb20be4..150fbcca 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableFollowersClientTests.cs @@ -165,8 +165,8 @@ namespace Octokit.Tests.Integration.Reactive _followersClient = new ObservableFollowersClient(github); // Follow someone to set initial state - _followersClient.Follow("alfhenrik").ToList(); - _followersClient.Follow("ryangribble").ToList(); + _followersClient.Follow("alfhenrik").Wait(); + _followersClient.Follow("ryangribble").Wait(); } [IntegrationTest] diff --git a/Octokit.Tests.Integration/SelfTests.cs b/Octokit.Tests.Integration/SelfTests.cs index b2362323..418b512d 100644 --- a/Octokit.Tests.Integration/SelfTests.cs +++ b/Octokit.Tests.Integration/SelfTests.cs @@ -1,4 +1,5 @@ -using Xunit; +using System.Reflection; +using Xunit; namespace Octokit.Tests.Integration { @@ -10,7 +11,7 @@ namespace Octokit.Tests.Integration [Fact] public void NoTestsUseAsyncVoid() { - var errors = typeof(SelfTests).Assembly.GetAsyncVoidMethodsList(); + var errors = typeof(SelfTests).GetTypeInfo().Assembly.GetAsyncVoidMethodsList(); Assert.Equal("", errors); } } diff --git a/Octokit.Tests.Integration/packages.config b/Octokit.Tests.Integration/packages.config deleted file mode 100644 index c9672de6..00000000 --- a/Octokit.Tests.Integration/packages.config +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests.Integration/project.json b/Octokit.Tests.Integration/project.json new file mode 100644 index 00000000..57a90a17 --- /dev/null +++ b/Octokit.Tests.Integration/project.json @@ -0,0 +1,48 @@ +{ + "version": "1.0.0-*", + "testRunner": "xunit", + "title": "Octokit.Tests.Integration", + "authors": [ + "GitHub" + ], + "description": "Integration tests for Octokit", + "xmlDoc": true, + "buildOptions": { + "nowarn": [ + "CS4014", + "CS1998" + ], + "compile": { + "includeFiles": [ + "../Octokit.Tests/Helpers/AssertEx.cs" + ] + }, + "embed": [ + "fixtures/hello-world.txt", + "fixtures/hello-world.zip" + ] + }, + "frameworks": { + "netcoreapp1.0": { + "buildOptions": {}, + "dependencies": { + "Octokit": { + "target": "project" + }, + "Octokit.Reactive": { + "target": "project" + }, + "Octokit.Tests": { + "target": "project" + }, + "NETStandard.Library": "1.6.0", + "xunit": "2.2.0-beta2-build3300", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/Octokit.Tests/Clients/AuthorizationsClientTests.cs b/Octokit.Tests/Clients/AuthorizationsClientTests.cs index c975fcba..cce9b585 100644 --- a/Octokit.Tests/Clients/AuthorizationsClientTests.cs +++ b/Octokit.Tests/Clients/AuthorizationsClientTests.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Net; +using System.Reflection; using System.Threading.Tasks; using NSubstitute; using Octokit.Internal; @@ -264,7 +266,7 @@ namespace Octokit.Tests.Clients Uri calledUri = null; dynamic calledBody = null; - client.Put(Arg.Do(u => calledUri = u), Arg.Do(body => calledBody = body)); + client.Put(Arg.Do(u => calledUri = u), Arg.Do(body => calledBody = body)); authEndpoint.GetOrCreateApplicationAuthentication("clientId", "secret", data); @@ -272,7 +274,9 @@ namespace Octokit.Tests.Clients Assert.Equal(calledUri.ToString(), "authorizations/clients/clientId"); Assert.NotNull(calledBody); - Assert.Equal(calledBody.fingerprint, "ha-ha-fingerprint"); + var fingerprintProperty = ((IEnumerable)calledBody.GetType().DeclaredProperties).FirstOrDefault(x => x.Name == "fingerprint"); + Assert.NotNull(fingerprintProperty); + Assert.Equal(fingerprintProperty.GetValue(calledBody), "ha-ha-fingerprint"); } } diff --git a/Octokit.Tests/Exceptions/ApiExceptionTests.cs b/Octokit.Tests/Exceptions/ApiExceptionTests.cs index 92ca45ac..639c3992 100644 --- a/Octokit.Tests/Exceptions/ApiExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiExceptionTests.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization.Formatters.Binary; +#endif using System.Text; using NSubstitute; using Octokit.Internal; @@ -96,7 +98,7 @@ namespace Octokit.Tests.Exceptions Assert.Equal("message2", thirdException.ApiError.Message); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { diff --git a/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs b/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs index 14d9aa9e..1348deeb 100644 --- a/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs +++ b/Octokit.Tests/Exceptions/ApiValidationExceptionTests.cs @@ -2,7 +2,9 @@ using System.IO; using System.Linq; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization.Formatters.Binary; +#endif using Octokit.Internal; using Xunit; @@ -39,7 +41,7 @@ namespace Octokit.Tests.Exceptions Assert.Equal("Validation Failed", exception.Message); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { diff --git a/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs b/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs index 66d6e672..82dc63a2 100644 --- a/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs +++ b/Octokit.Tests/Exceptions/RateLimitExceededExceptionTests.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Globalization; using System.IO; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization.Formatters.Binary; +#endif using Octokit.Internal; using Xunit; @@ -76,7 +78,7 @@ namespace Octokit.Tests.Exceptions Assert.Equal(expectedReset, exception.Reset); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { diff --git a/Octokit.Tests/Fixtures/EmbeddedResource.cs b/Octokit.Tests/Fixtures/EmbeddedResource.cs index 0e4accbc..445f00e1 100644 --- a/Octokit.Tests/Fixtures/EmbeddedResource.cs +++ b/Octokit.Tests/Fixtures/EmbeddedResource.cs @@ -20,7 +20,13 @@ namespace Octokit.Tests public string GetResourceAsString(Encoding encoding = null) { - encoding = encoding ?? Encoding.Default; + 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 using (var sr = new StreamReader(GetResourceStream(), encoding)) { @@ -30,7 +36,7 @@ namespace Octokit.Tests public Stream GetResourceStream() { - var assembly = Assembly ?? Assembly.GetExecutingAssembly(); + var assembly = Assembly ?? typeof(EmbeddedResource).GetTypeInfo().Assembly; return assembly.GetManifestResourceStream(ResourceName); } diff --git a/Octokit.Tests/Fixtures/Fixtures.cs b/Octokit.Tests/Fixtures/Fixtures.cs index faf5497a..edc9aef6 100644 --- a/Octokit.Tests/Fixtures/Fixtures.cs +++ b/Octokit.Tests/Fixtures/Fixtures.cs @@ -1,7 +1,39 @@ -namespace Octokit.Tests +#if HAS_TYPEINFO +using System.Reflection; +#endif + +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"); + + public static EmbeddedResource AuthorizationJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.authorization.json"); + + public static EmbeddedResource UserJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.user.json"); + + public static EmbeddedResource UserFullJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.user_full.json"); + + public static EmbeddedResource RepositoryJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.repository.json"); + + public static EmbeddedResource RepositoriesJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.repositories.json"); + + public static EmbeddedResource ReleasesJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.releases.json"); + + public static EmbeddedResource ReleaseJson = + new EmbeddedResource(typeof(Fixtures).GetTypeInfo().Assembly, "Octokit.Tests.Fixtures.release.json"); + + 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"); @@ -28,5 +60,6 @@ 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 90b8f3ee..c538f1ea 100644 --- a/Octokit.Tests/Http/RateLimitTests.cs +++ b/Octokit.Tests/Http/RateLimitTests.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +#if !NO_SERIALIZABLE using System.Runtime.Serialization.Formatters.Binary; +#endif using Xunit; namespace Octokit.Tests.Http @@ -69,7 +71,7 @@ namespace Octokit.Tests.Http Assert.Equal(expectedReset, rateLimit.Reset); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Fact] public void CanPopulateObjectFromSerializedData() { diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj deleted file mode 100644 index cc2abfdb..00000000 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - Debug - AnyCPU - {3F4686DA-8774-4940-823E-9138F4B42060} - Library - Properties - Octokit.Tests - Octokit.Tests-NetCore45 - v4.5 - 512 - - - 5 - - - true - full - false - bin\Debug\NetCore45\ - TRACE;DEBUG;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - prompt - 4 - 4014, 1998 - - - pdbonly - true - bin\Release\NetCore45\ - TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - prompt - 4 - 4014, 1998 - - - - ..\packages\NSubstitute.1.9.2.0\lib\net45\NSubstitute.dll - True - - - - - - - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {c8bc13b6-3fa3-4716-827d-e7706f976fe1} - Octokit-NetCore45 - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/Octokit.Tests/Octokit.Tests-Portable.csproj b/Octokit.Tests/Octokit.Tests-Portable.csproj deleted file mode 100644 index ec54096b..00000000 --- a/Octokit.Tests/Octokit.Tests-Portable.csproj +++ /dev/null @@ -1,220 +0,0 @@ - - - - - - Debug - AnyCPU - {CBE29DDD-F15C-46CC-A250-E6ECF55BEED4} - Library - Properties - Octokit.Tests-Portable - Octokit.Tests-Portable - v4.5 - 512 - - - 5 - - - true - full - false - bin\Debug\Portable\ - TRACE;DEBUG;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;PORTABLE - prompt - 4 - 4014, 1998 - - - pdbonly - true - bin\Release\Portable\ - TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;PORTABLE - prompt - 4 - 4014, 1998 - - - - ..\packages\NSubstitute.1.9.2.0\lib\net45\NSubstitute.dll - True - - - - - - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll - True - - - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71} - Octokit-Portable - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj deleted file mode 100644 index b0a797e9..00000000 --- a/Octokit.Tests/Octokit.Tests.csproj +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - Debug - AnyCPU - {149448D4-C2F2-4DF9-86BD-03E3272F093B} - Library - Properties - Octokit.Tests - Octokit.Tests - v4.5 - 512 - - - 5 - - - true - full - false - bin\Debug\Net45\ - TRACE;DEBUG;NET_45 - prompt - 4 - 4014, 1998 - - - pdbonly - true - bin\Release\Net45\ - TRACE;NET_45 - prompt - 4 - 4014, 1998 - - - - ..\packages\NSubstitute.1.9.2.0\lib\net45\NSubstitute.dll - True - - - - - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll - True - - - - False - ..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll - - - False - ..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll - - - False - ..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll - - - - - ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll - - - ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll - True - - - ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll - True - - - ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {674b69b8-0780-4d54-ae2b-c15821fa51cb} - Octokit.Reactive - - - {08dd4305-7787-4823-a53f-4d0f725a07f3} - Octokit - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/Octokit.Next.Tests/Octokit.Next.Tests.xproj b/Octokit.Tests/Octokit.Tests.xproj similarity index 85% rename from Octokit.Next.Tests/Octokit.Next.Tests.xproj rename to Octokit.Tests/Octokit.Tests.xproj index 17d797e1..33b3819a 100644 --- a/Octokit.Next.Tests/Octokit.Next.Tests.xproj +++ b/Octokit.Tests/Octokit.Tests.xproj @@ -6,11 +6,11 @@ - 2740af44-cb2e-4fd8-a221-248693978a0c - Octokit.Next.Tests + e58ec0ea-b6e5-43aa-a7d2-ad0a6d4bb0d2 + Octokit.Tests .\obj .\bin\ - v4.5 + v4.6 2.0 diff --git a/Octokit.Tests/Reactive/ObservableGistsTests.cs b/Octokit.Tests/Reactive/ObservableGistsTests.cs index d824c91c..5d69a5e2 100644 --- a/Octokit.Tests/Reactive/ObservableGistsTests.cs +++ b/Octokit.Tests/Reactive/ObservableGistsTests.cs @@ -4,7 +4,6 @@ using NSubstitute; using Octokit.Reactive; using Xunit; - namespace Octokit.Tests.Reactive { public class ObservableGistsTests diff --git a/Octokit.Tests/SelfTests.cs b/Octokit.Tests/SelfTests.cs index 30b554fd..98701b93 100644 --- a/Octokit.Tests/SelfTests.cs +++ b/Octokit.Tests/SelfTests.cs @@ -1,4 +1,7 @@ -using Xunit; +#if HAS_TYPEINFO +using System.Reflection; +#endif +using Xunit; /// /// Tests to make sure our tests are ok. @@ -8,7 +11,11 @@ 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.Tests/packages.Octokit.Tests-NetCore45.config b/Octokit.Tests/packages.Octokit.Tests-NetCore45.config deleted file mode 100644 index 9155f4cd..00000000 --- a/Octokit.Tests/packages.Octokit.Tests-NetCore45.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests/packages.Octokit.Tests-Portable.config b/Octokit.Tests/packages.Octokit.Tests-Portable.config deleted file mode 100644 index 516e61ce..00000000 --- a/Octokit.Tests/packages.Octokit.Tests-Portable.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests/packages.Octokit.Tests.config b/Octokit.Tests/packages.Octokit.Tests.config deleted file mode 100644 index 812ea8c4..00000000 --- a/Octokit.Tests/packages.Octokit.Tests.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit.Tests/project.json b/Octokit.Tests/project.json new file mode 100644 index 00000000..8165a766 --- /dev/null +++ b/Octokit.Tests/project.json @@ -0,0 +1,42 @@ +{ + "version": "1.0.0-*", + "testRunner": "xunit", + "title": "Octokit.Tests", + "authors": [ + "GitHub" + ], + "description": "Tests for Octokit", + "xmlDoc": true, + "buildOptions": { + "nowarn": [ + "CS4014", + "CS1998" + ] + }, + "frameworks": { + "netcoreapp1.0": { + "buildOptions": { + "define": [ + "NO_SERIALIZABLE", + "HAS_TYPEINFO" + ] + }, + "dependencies": { + "Octokit": { + "target": "project" + }, + "Octokit.Reactive": { + "target": "project" + }, + "NETStandard.Library": "1.6.0", + "NSubstitute": "2.0.0-rc", + "xunit": "2.2.0-beta2-build3300", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + } + } + } + } +} \ No newline at end of file diff --git a/Octokit/Clients/ApiPagination.cs b/Octokit/Clients/ApiPagination.cs index 926e0dfa..882edcd7 100644 --- a/Octokit/Clients/ApiPagination.cs +++ b/Octokit/Clients/ApiPagination.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Net; using System.Threading.Tasks; -#if NET_45 using System.Collections.ObjectModel; -#endif namespace Octokit { diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 7ca81d56..990d0b99 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -1,8 +1,6 @@ using System.Threading.Tasks; using System; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/IAuthorizationsClient.cs b/Octokit/Clients/IAuthorizationsClient.cs index fc2fec6e..e3f08b47 100644 --- a/Octokit/Clients/IAuthorizationsClient.cs +++ b/Octokit/Clients/IAuthorizationsClient.cs @@ -1,9 +1,7 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using System; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/IIssueTimelineClient.cs b/Octokit/Clients/IIssueTimelineClient.cs index f1883443..8f3da9e7 100644 --- a/Octokit/Clients/IIssueTimelineClient.cs +++ b/Octokit/Clients/IIssueTimelineClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -#endif namespace Octokit { diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 3f20fabf..15b5a8e6 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Threading.Tasks; +using System.Threading.Tasks; using System.Collections.Generic; -#endif using System.Diagnostics.CodeAnalysis; namespace Octokit diff --git a/Octokit/Clients/IOrganizationsClient.cs b/Octokit/Clients/IOrganizationsClient.cs index 5416aea4..adfff0c0 100644 --- a/Octokit/Clients/IOrganizationsClient.cs +++ b/Octokit/Clients/IOrganizationsClient.cs @@ -1,9 +1,8 @@ -using System; -#if NET_45 using System.Threading.Tasks; using System.Collections.Generic; -#endif + using System.Diagnostics.CodeAnalysis; +using System; namespace Octokit { diff --git a/Octokit/Clients/IReleasesClient.cs b/Octokit/Clients/IReleasesClient.cs index 33f81a8f..46293ecc 100644 --- a/Octokit/Clients/IReleasesClient.cs +++ b/Octokit/Clients/IReleasesClient.cs @@ -1,8 +1,6 @@ -#if NET_45 -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -#endif namespace Octokit { diff --git a/Octokit/Clients/IRepoCollaboratorsClient.cs b/Octokit/Clients/IRepoCollaboratorsClient.cs index 33788d0b..5cdc09f7 100644 --- a/Octokit/Clients/IRepoCollaboratorsClient.cs +++ b/Octokit/Clients/IRepoCollaboratorsClient.cs @@ -1,7 +1,5 @@ -#if NET_45 using System.Collections.Generic; using System.Threading.Tasks; -#endif namespace Octokit { diff --git a/Octokit/Clients/IRepositoriesClient.cs b/Octokit/Clients/IRepositoriesClient.cs index 8ae36358..3d15d2dc 100644 --- a/Octokit/Clients/IRepositoriesClient.cs +++ b/Octokit/Clients/IRepositoriesClient.cs @@ -1,9 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/IRepositoryBranchesClient.cs b/Octokit/Clients/IRepositoryBranchesClient.cs index cd96d646..6917598a 100644 --- a/Octokit/Clients/IRepositoryBranchesClient.cs +++ b/Octokit/Clients/IRepositoryBranchesClient.cs @@ -2,9 +2,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using System.Collections.ObjectModel; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/ITeamsClient.cs b/Octokit/Clients/ITeamsClient.cs index c07d6467..940e4be3 100644 --- a/Octokit/Clients/ITeamsClient.cs +++ b/Octokit/Clients/ITeamsClient.cs @@ -1,9 +1,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/IssueTimelineClient.cs b/Octokit/Clients/IssueTimelineClient.cs index d09dc763..4ea750e7 100644 --- a/Octokit/Clients/IssueTimelineClient.cs +++ b/Octokit/Clients/IssueTimelineClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -#endif namespace Octokit { diff --git a/Octokit/Clients/IssuesEventsClient.cs b/Octokit/Clients/IssuesEventsClient.cs index 6cb20fc9..f6d3e714 100644 --- a/Octokit/Clients/IssuesEventsClient.cs +++ b/Octokit/Clients/IssuesEventsClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Threading.Tasks; +using System.Threading.Tasks; using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index cf6242b9..3f5cd1c8 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; -#if NET_45 using System.Collections.ObjectModel; -#endif namespace Octokit { diff --git a/Octokit/Clients/OrganizationsClient.cs b/Octokit/Clients/OrganizationsClient.cs index e4936cc7..285287ec 100644 --- a/Octokit/Clients/OrganizationsClient.cs +++ b/Octokit/Clients/OrganizationsClient.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/ReleasesClient.cs b/Octokit/Clients/ReleasesClient.cs index cff6a882..5fe9f713 100644 --- a/Octokit/Clients/ReleasesClient.cs +++ b/Octokit/Clients/ReleasesClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Threading.Tasks; +using System.Threading.Tasks; using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/RepoCollaboratorsClient.cs b/Octokit/Clients/RepoCollaboratorsClient.cs index 4eda7655..be54ff95 100644 --- a/Octokit/Clients/RepoCollaboratorsClient.cs +++ b/Octokit/Clients/RepoCollaboratorsClient.cs @@ -1,7 +1,5 @@ -#if NET_45 -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; -#endif namespace Octokit { diff --git a/Octokit/Clients/RepositoriesClient.cs b/Octokit/Clients/RepositoriesClient.cs index f7cf8e71..22adc823 100644 --- a/Octokit/Clients/RepositoriesClient.cs +++ b/Octokit/Clients/RepositoriesClient.cs @@ -3,9 +3,7 @@ using System.Collections.ObjectModel; using System.Linq; using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/RepositoryDeployKeysClient.cs b/Octokit/Clients/RepositoryDeployKeysClient.cs index 51d0e4fd..81fd930f 100644 --- a/Octokit/Clients/RepositoryDeployKeysClient.cs +++ b/Octokit/Clients/RepositoryDeployKeysClient.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Clients/TeamsClient.cs b/Octokit/Clients/TeamsClient.cs index e398e6d3..6f70db13 100644 --- a/Octokit/Clients/TeamsClient.cs +++ b/Octokit/Clients/TeamsClient.cs @@ -1,9 +1,7 @@ using System; using System.Net; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Exceptions/AbuseException.cs b/Octokit/Exceptions/AbuseException.cs index d4379aee..624559e9 100644 --- a/Octokit/Exceptions/AbuseException.cs +++ b/Octokit/Exceptions/AbuseException.cs @@ -2,8 +2,10 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; using System.Security; +#endif namespace Octokit { @@ -11,7 +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. /// Containts the amount of seconds after which it's safe to retry the request. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -59,7 +61,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Request Forbidden - Abuse Detection"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of AbuseException /// diff --git a/Octokit/Exceptions/ApiException.cs b/Octokit/Exceptions/ApiException.cs index 853b2e67..ce2c15e9 100644 --- a/Octokit/Exceptions/ApiException.cs +++ b/Octokit/Exceptions/ApiException.cs @@ -1,7 +1,9 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; using Octokit.Internal; @@ -10,7 +12,7 @@ namespace Octokit /// /// Represents errors that occur from the GitHub API. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -139,7 +141,7 @@ namespace Octokit return new ApiError(responseContent); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of ApiException. /// diff --git a/Octokit/Exceptions/ApiValidationException.cs b/Octokit/Exceptions/ApiValidationException.cs index 0eac6a2e..3b76a8ed 100644 --- a/Octokit/Exceptions/ApiValidationException.cs +++ b/Octokit/Exceptions/ApiValidationException.cs @@ -2,14 +2,16 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -58,7 +60,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Validation Failed"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of ApiValidationException /// diff --git a/Octokit/Exceptions/AuthorizationException.cs b/Octokit/Exceptions/AuthorizationException.cs index ba8806b3..f47bb0de 100644 --- a/Octokit/Exceptions/AuthorizationException.cs +++ b/Octokit/Exceptions/AuthorizationException.cs @@ -2,14 +2,16 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -49,7 +51,7 @@ namespace Octokit { } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of AuthorizationException. /// diff --git a/Octokit/Exceptions/ForbiddenException.cs b/Octokit/Exceptions/ForbiddenException.cs index bcd82704..9f15d117 100644 --- a/Octokit/Exceptions/ForbiddenException.cs +++ b/Octokit/Exceptions/ForbiddenException.cs @@ -2,14 +2,16 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -41,7 +43,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Request Forbidden"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of ForbiddenException /// diff --git a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs index 0ff99248..6e0d8db5 100644 --- a/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs +++ b/Octokit/Exceptions/InvalidGitIgnoreTemplateException.cs @@ -1,13 +1,15 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -36,7 +38,7 @@ namespace Octokit } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of InvalidGitignoreTemplateException /// diff --git a/Octokit/Exceptions/LegalRestrictionException.cs b/Octokit/Exceptions/LegalRestrictionException.cs index df115d4d..d7ac60c2 100644 --- a/Octokit/Exceptions/LegalRestrictionException.cs +++ b/Octokit/Exceptions/LegalRestrictionException.cs @@ -2,7 +2,9 @@ using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif namespace Octokit { @@ -11,7 +13,7 @@ namespace Octokit /// This will returned if GitHub has been asked to takedown the requested resource due to /// a DMCA takedown. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -52,7 +54,7 @@ namespace Octokit "LegalRestrictionException created with wrong status code"); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of LegalRestrictionException /// diff --git a/Octokit/Exceptions/LoginAttemptsExceededException.cs b/Octokit/Exceptions/LoginAttemptsExceededException.cs index de83c864..56269c98 100644 --- a/Octokit/Exceptions/LoginAttemptsExceededException.cs +++ b/Octokit/Exceptions/LoginAttemptsExceededException.cs @@ -1,13 +1,15 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -38,7 +40,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Maximum number of login attempts exceeded"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of LoginAttemptsExceededException /// diff --git a/Octokit/Exceptions/NotFoundException.cs b/Octokit/Exceptions/NotFoundException.cs index 8169c7d7..4f64b26b 100644 --- a/Octokit/Exceptions/NotFoundException.cs +++ b/Octokit/Exceptions/NotFoundException.cs @@ -2,14 +2,16 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -45,7 +47,7 @@ namespace Octokit "NotFoundException created with wrong status code"); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of NotFoundException /// diff --git a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs b/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs index 47aec19a..c811b1ff 100644 --- a/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs +++ b/Octokit/Exceptions/PrivateRepositoryQuotaExceededException.cs @@ -1,6 +1,8 @@ using System; using System.Diagnostics.CodeAnalysis; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif namespace Octokit { @@ -8,7 +10,7 @@ namespace Octokit /// Exception thrown when creating a private repository, but the user's private quota is or would be exceeded /// by creating it. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -35,7 +37,7 @@ namespace Octokit } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of PrivateRepositoryQuotaExceededException /// diff --git a/Octokit/Exceptions/PullRequestMismatchException.cs b/Octokit/Exceptions/PullRequestMismatchException.cs index f16504b5..f94ab78c 100644 --- a/Octokit/Exceptions/PullRequestMismatchException.cs +++ b/Octokit/Exceptions/PullRequestMismatchException.cs @@ -2,7 +2,9 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif namespace Octokit { @@ -10,7 +12,7 @@ namespace Octokit /// Represents an error that occurs when the specified SHA /// doesn't match the current pull request's HEAD /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -43,7 +45,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Head branch was modified. Review and try the merge again."; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of . /// diff --git a/Octokit/Exceptions/PullRequestNotMergeableException.cs b/Octokit/Exceptions/PullRequestNotMergeableException.cs index ca4143dc..89ce79e1 100644 --- a/Octokit/Exceptions/PullRequestNotMergeableException.cs +++ b/Octokit/Exceptions/PullRequestNotMergeableException.cs @@ -2,7 +2,9 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif namespace Octokit { @@ -10,7 +12,7 @@ namespace Octokit /// Represents an error that occurs when the pull request is in an /// unmergeable state /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -43,7 +45,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Pull Request is not mergeable"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of . /// diff --git a/Octokit/Exceptions/RateLimitExceededException.cs b/Octokit/Exceptions/RateLimitExceededException.cs index 2f6fc61d..fe11f1b5 100644 --- a/Octokit/Exceptions/RateLimitExceededException.cs +++ b/Octokit/Exceptions/RateLimitExceededException.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; namespace Octokit @@ -16,7 +18,7 @@ namespace Octokit /// /// See http://developer.github.com/v3/#rate-limiting for more details. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -76,7 +78,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "API Rate Limit exceeded"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of RateLimitExceededException /// diff --git a/Octokit/Exceptions/RepositoryExistsException.cs b/Octokit/Exceptions/RepositoryExistsException.cs index 82ab94e5..3b847a90 100644 --- a/Octokit/Exceptions/RepositoryExistsException.cs +++ b/Octokit/Exceptions/RepositoryExistsException.cs @@ -1,7 +1,9 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; namespace Octokit @@ -9,7 +11,7 @@ namespace Octokit /// /// Exception thrown when creating a repository, but it already exists on the server. /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -95,7 +97,7 @@ namespace Octokit /// public bool OwnerIsOrganization { get; private set; } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of RepositoryExistsException. /// diff --git a/Octokit/Exceptions/RepositoryFormatException.cs b/Octokit/Exceptions/RepositoryFormatException.cs index bfc0d8ae..c0ab53b5 100644 --- a/Octokit/Exceptions/RepositoryFormatException.cs +++ b/Octokit/Exceptions/RepositoryFormatException.cs @@ -2,12 +2,14 @@ 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 !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -33,7 +35,7 @@ namespace Octokit } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of LoginAttemptsExceededException /// diff --git a/Octokit/Exceptions/RepositoryWebHookConfigException.cs b/Octokit/Exceptions/RepositoryWebHookConfigException.cs index 8102220e..c1be7e46 100644 --- a/Octokit/Exceptions/RepositoryWebHookConfigException.cs +++ b/Octokit/Exceptions/RepositoryWebHookConfigException.cs @@ -3,12 +3,14 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; namespace Octokit { -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -30,7 +32,7 @@ namespace Octokit get { return message; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of RepositoryWebHookConfigException /// diff --git a/Octokit/Exceptions/TwoFactorAuthorizationException.cs b/Octokit/Exceptions/TwoFactorAuthorizationException.cs index 5f47cafa..b1ab087f 100644 --- a/Octokit/Exceptions/TwoFactorAuthorizationException.cs +++ b/Octokit/Exceptions/TwoFactorAuthorizationException.cs @@ -2,12 +2,14 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; namespace Octokit { -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Represents a failed 2FA challenge from the API /// @@ -62,7 +64,7 @@ namespace Octokit /// public TwoFactorType TwoFactorType { get; private set; } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorRequiredException. /// diff --git a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs index 1266dc1c..3e1b799f 100644 --- a/Octokit/Exceptions/TwoFactorChallengeFailedException.cs +++ b/Octokit/Exceptions/TwoFactorChallengeFailedException.cs @@ -1,11 +1,13 @@ using System; using System.Diagnostics.CodeAnalysis; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; namespace Octokit { -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Represents a failed 2FA challenge from the API /// @@ -47,7 +49,7 @@ namespace Octokit return exception == null ? TwoFactorType.None : Connection.ParseTwoFactorType(exception.HttpResponse); } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorChallengeFailedException. /// diff --git a/Octokit/Exceptions/TwoFactorRequiredException.cs b/Octokit/Exceptions/TwoFactorRequiredException.cs index f2361c24..22f4276d 100644 --- a/Octokit/Exceptions/TwoFactorRequiredException.cs +++ b/Octokit/Exceptions/TwoFactorRequiredException.cs @@ -2,14 +2,16 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif namespace Octokit { /// /// /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", @@ -48,7 +50,7 @@ namespace Octokit get { return ApiErrorMessageSafe ?? "Two-factor authentication code is required"; } } -#if !NETFX_CORE +#if !NO_SERIALIZABLE /// /// Constructs an instance of TwoFactorRequiredException. /// diff --git a/Octokit/Helpers/ApiExtensions.cs b/Octokit/Helpers/ApiExtensions.cs index abfcafec..194b1c10 100644 --- a/Octokit/Helpers/ApiExtensions.cs +++ b/Octokit/Helpers/ApiExtensions.cs @@ -2,9 +2,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Helpers/EnumExtensions.cs b/Octokit/Helpers/EnumExtensions.cs index 15ac0640..83bb3fae 100644 --- a/Octokit/Helpers/EnumExtensions.cs +++ b/Octokit/Helpers/EnumExtensions.cs @@ -15,6 +15,7 @@ namespace Octokit var propString = prop.ToString(); var member = prop.GetType().GetMember(propString).FirstOrDefault(); + if (member == null) return null; var attribute = member.GetCustomAttributes(typeof(ParameterAttribute), false) diff --git a/Octokit/Helpers/IApiPagination.cs b/Octokit/Helpers/IApiPagination.cs index 607a02f4..b64463fa 100644 --- a/Octokit/Helpers/IApiPagination.cs +++ b/Octokit/Helpers/IApiPagination.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#if NET_45 using System.Collections.Generic; -#endif namespace Octokit { diff --git a/Octokit/Helpers/ReflectionExtensions.cs b/Octokit/Helpers/ReflectionExtensions.cs index 01c07b12..49265172 100644 --- a/Octokit/Helpers/ReflectionExtensions.cs +++ b/Octokit/Helpers/ReflectionExtensions.cs @@ -1,9 +1,9 @@ -using System; +using Octokit.Internal; +using Octokit.Reflection; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -using Octokit.Internal; -using Octokit.Reflection; namespace Octokit { @@ -39,19 +39,22 @@ namespace Octokit return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); } -#if !NETFX_CORE +#if !HAS_TYPEINFO public static Type GetTypeInfo(this Type type) { return type; } -#endif - -#if NETFX_CORE +#else public static IEnumerable GetMember(this Type type, string name) { return type.GetTypeInfo().DeclaredMembers.Where(m => m.Name == name); } + public static PropertyInfo GetProperty(this Type t, string propertyName) + { + return t.GetTypeInfo().GetDeclaredProperty(propertyName); + } + public static bool IsAssignableFrom(this Type type, Type otherType) { return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo()); @@ -59,7 +62,7 @@ namespace Octokit #endif public static IEnumerable GetAllProperties(this Type type) { -#if NETFX_CORE +#if HAS_TYPEINFO var typeInfo = type.GetTypeInfo(); var properties = typeInfo.DeclaredProperties; @@ -73,11 +76,7 @@ namespace Octokit public static bool IsEnumeration(this Type type) { -#if NETFX_CORE return type.GetTypeInfo().IsEnum; -#else - return type.IsEnum; -#endif } } } diff --git a/Octokit/Helpers/StringExtensions.cs b/Octokit/Helpers/StringExtensions.cs index 50e41f36..2ac1f6f1 100644 --- a/Octokit/Helpers/StringExtensions.cs +++ b/Octokit/Helpers/StringExtensions.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net; -using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -68,13 +67,6 @@ namespace Octokit return new Uri(template); } -#if NETFX_CORE - public static PropertyInfo GetProperty(this Type t, string propertyName) - { - return t.GetTypeInfo().GetDeclaredProperty(propertyName); - } -#endif - // :trollface: [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Ruby don't care. Ruby don't play that.")] @@ -123,7 +115,7 @@ namespace Octokit // Username may only contain alphanumeric characters or single hyphens // and cannot begin or end with a hyphen static readonly Regex nameWithOwner = new Regex("[a-z0-9.-]{1,}/[a-z0-9.-_]{1,}", -#if (!PORTABLE && !NETFX_CORE) +#if HAS_REGEX_COMPILED_OPTIONS RegexOptions.Compiled | #endif RegexOptions.IgnoreCase); diff --git a/Octokit/Http/ApiInfo.cs b/Octokit/Http/ApiInfo.cs index ce6ef0c2..83a0e00f 100644 --- a/Octokit/Http/ApiInfo.cs +++ b/Octokit/Http/ApiInfo.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -#if NET_45 using System.Collections.ObjectModel; -#endif namespace Octokit { diff --git a/Octokit/Http/ApiInfoParser.cs b/Octokit/Http/ApiInfoParser.cs index 9e47ba79..ca61e374 100644 --- a/Octokit/Http/ApiInfoParser.cs +++ b/Octokit/Http/ApiInfoParser.cs @@ -8,12 +8,11 @@ namespace Octokit.Internal internal static class ApiInfoParser { const RegexOptions regexOptions = -#if NETFX_CORE - RegexOptions.IgnoreCase; -#else - RegexOptions.Compiled | RegexOptions.IgnoreCase; - +#if HAS_REGEX_COMPILED_OPTIONS + RegexOptions.Compiled | #endif + RegexOptions.IgnoreCase; + static readonly Regex _linkRelRegex = new Regex("rel=\"(next|prev|first|last)\"", regexOptions); static readonly Regex _linkUriRegex = new Regex("<(.+)>", regexOptions); diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 58f6eec5..6a1bdaca 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -7,6 +7,9 @@ using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Octokit.Internal; +#if !HAS_ENVIRONMENT +using System.Runtime.InteropServices; +#endif namespace Octokit { @@ -59,7 +62,7 @@ namespace Octokit /// the user agent for analytics purposes. /// /// - /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise + /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise /// instance public Connection(ProductHeaderValue productInformation, Uri baseAddress) : this(productInformation, baseAddress, _anonymousCredentials) @@ -87,7 +90,7 @@ namespace Octokit /// the user agent for analytics purposes. /// /// - /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise + /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise /// instance /// Provides credentials to the client when making requests [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] @@ -104,7 +107,7 @@ namespace Octokit /// the user agent for analytics purposes. /// /// - /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise + /// The address to point this client to such as https://api.github.com or the URL to a GitHub Enterprise /// instance /// Provides credentials to the client when making requests /// A raw used to make requests @@ -539,9 +542,9 @@ namespace Octokit /// Gets or sets the credentials used by the connection. /// /// - /// You can use this property if you only have a single hard-coded credential. Otherwise, pass in an - /// to the constructor. - /// Setting this property will change the to use + /// You can use this property if you only have a single hard-coded credential. Otherwise, pass in an + /// to the constructor. + /// Setting this property will change the to use /// the default with just these credentials. /// public Credentials Credentials @@ -670,17 +673,19 @@ namespace Octokit static string FormatUserAgent(ProductHeaderValue productInformation) { + var format = +#if !HAS_ENVIRONMENT + "{0} ({1}; {2}; {3}; Octokit {4})"; +#else + "{0} ({1} {2}; {3}; {4}; Octokit {5})"; +#endif + return string.Format(CultureInfo.InvariantCulture, - "{0} ({1} {2}; {3}; {4}; Octokit {5})", + format, productInformation, -#if NETFX_CORE - // Microsoft doesn't want you changing your Windows Store Application based on the processor or - // Windows version. If we really wanted this information, we could do a best guess based on - // this approach: http://attackpattern.com/2013/03/device-information-in-windows-8-store-apps/ - // But I don't think we care all that much. - "WindowsRT", - "8+", - "unknown", +#if !HAS_ENVIRONMENT + RuntimeInformation.OSDescription, + RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant(), #else Environment.OSVersion.Platform, Environment.OSVersion.Version.ToString(3), diff --git a/Octokit/Http/RateLimit.cs b/Octokit/Http/RateLimit.cs index 6667ff09..2f1259bc 100644 --- a/Octokit/Http/RateLimit.cs +++ b/Octokit/Http/RateLimit.cs @@ -3,19 +3,21 @@ using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; +#if !NO_SERIALIZABLE using System.Runtime.Serialization; +#endif using System.Security; using Octokit.Helpers; using Octokit.Internal; namespace Octokit { -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RateLimit -#if !NETFX_CORE +#if !NO_SERIALIZABLE : ISerializable #endif { @@ -73,7 +75,7 @@ namespace Octokit : result; } -#if !NETFX_CORE +#if !NO_SERIALIZABLE protected RateLimit(SerializationInfo info, StreamingContext context) { Ensure.ArgumentNotNull(info, "info"); diff --git a/Octokit/Models/Request/InvitationUpdate.cs b/Octokit/Models/Request/InvitationUpdate.cs index 82c4a1b5..4c831d16 100644 --- a/Octokit/Models/Request/InvitationUpdate.cs +++ b/Octokit/Models/Request/InvitationUpdate.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Globalization; - namespace Octokit { /// diff --git a/Octokit/Models/Request/RequestParameters.cs b/Octokit/Models/Request/RequestParameters.cs index ccd7121c..de82010d 100644 --- a/Octokit/Models/Request/RequestParameters.cs +++ b/Octokit/Models/Request/RequestParameters.cs @@ -101,6 +101,7 @@ namespace Octokit static string GetParameterAttributeValueForEnumName(Type enumType, string name) { var member = enumType.GetMember(name).FirstOrDefault(); + if (member == null) return null; var attribute = member.GetCustomAttributes(typeof(ParameterAttribute), false) .Cast() diff --git a/Octokit/Models/Response/ApiError.cs b/Octokit/Models/Response/ApiError.cs index b6614a0f..609fb37b 100644 --- a/Octokit/Models/Response/ApiError.cs +++ b/Octokit/Models/Response/ApiError.cs @@ -8,7 +8,7 @@ namespace Octokit /// /// Error payload from the API reposnse /// -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [DebuggerDisplay("{DebuggerDisplay,nq}")] diff --git a/Octokit/Models/Response/ApiErrorDetail.cs b/Octokit/Models/Response/ApiErrorDetail.cs index cf7142c8..9e9d9f76 100644 --- a/Octokit/Models/Response/ApiErrorDetail.cs +++ b/Octokit/Models/Response/ApiErrorDetail.cs @@ -4,7 +4,7 @@ using System.Globalization; namespace Octokit { -#if !NETFX_CORE +#if !NO_SERIALIZABLE [Serializable] #endif [DebuggerDisplay("{DebuggerDisplay,nq}")] diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj deleted file mode 100644 index 20976b43..00000000 --- a/Octokit/Octokit-Mono.csproj +++ /dev/null @@ -1,511 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4} - Library - Octokit - Octokit - v4.5 - 5 - - - true - full - false - obj\Debug\Mono - bin\Debug\Mono - TRACE;DEBUG;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - false - - - full - true - obj\Release\Mono - TRACE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - bin\Release\Mono - prompt - 4 - false - bin\Release\Mono\Octokit.XML - 1591 - - - - - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - Code - - - - - - - Code - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj deleted file mode 100644 index 34abb1ce..00000000 --- a/Octokit/Octokit-MonoAndroid.csproj +++ /dev/null @@ -1,522 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {B24FC6FA-B80C-4EC7-8AFF-05DE2C923869} - {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Octokit - Resources - Assets - False - Octokit - 5 - - - true - full - false - obj\Debug\MonoAndroid - bin\Debug\MonoAndroid - DEBUG; - prompt - 4 - TRACE;DEBUG;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - None - false - - - full - true - obj\Release\MonoAndroid - bin\Release\MonoAndroid - TRACE;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - prompt - 4 - false - false - - - - - - - - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - Code - - - - - - - Code - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj deleted file mode 100644 index ca2b90c8..00000000 --- a/Octokit/Octokit-Monotouch.csproj +++ /dev/null @@ -1,519 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {E4AD1421-8844-4236-9A0B-C4D96AF53908} - {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Octokit - Resources - Octokit - 5 - - - true - full - false - obj\Debug\Monotouch - TRACE;DEBUG;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - bin\Debug\Monotouch - TRACE;DEBUG;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - prompt - 4 - false - - - full - true - TRACE;CODE_ANALYSIS;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45 - obj\Release\Monotouch - bin\Release\Monotouch - prompt - 4 - false - - - - - - - - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - Code - - - - - - - Code - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj deleted file mode 100644 index f7f50295..00000000 --- a/Octokit/Octokit-Portable.csproj +++ /dev/null @@ -1,542 +0,0 @@ - - - - - 11.0 - Debug - AnyCPU - {DDB20481-E17D-4E0A-B2C0-FFFF78D4ED71} - Library - Properties - Octokit - Octokit - v4.5 - Profile259 - 512 - en-US - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 5 - - - true - full - false - bin\Debug\Portable\ - TRACE;DEBUG;CODE_ANALYSIS;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;PORTABLE;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - ..\Octokit.ruleset - false - - - pdbonly - true - bin\Release\Portable\ - TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;PORTABLE;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - false - ..\Octokit.ruleset - bin\Release\Portable\Octokit.XML - 1591 - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CustomDictionary.xml - - - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll - True - - - ..\packages\Microsoft.Net.Http.2.2.29\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll - True - - - - - - - - - - - - - \ No newline at end of file diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj deleted file mode 100644 index 0afbd353..00000000 --- a/Octokit/Octokit-netcore45.csproj +++ /dev/null @@ -1,527 +0,0 @@ - - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {C8BC13B6-3FA3-4716-827D-E7706F976FE1} - Library - Properties - Octokit - Octokit - - - 512 - en-US - {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - en-US - 5 - 8.1 - 12 - - - true - full - false - obj\Debug\NetCore45 - bin\Debug\NetCore45 - TRACE;DEBUG;CODE_ANALYSIS;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - true - true - ..\Octokit.ruleset - - - pdbonly - true - obj\Release\NetCore45 - bin\Release\NetCore45\ - TRACE;NETFX_CORE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - true - ..\Octokit.ruleset - bin\Release\NetCore45\Octokit.XML - 1591 - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CustomDictionary.xml - - - - - \ No newline at end of file diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj deleted file mode 100644 index be2f9276..00000000 --- a/Octokit/Octokit.csproj +++ /dev/null @@ -1,545 +0,0 @@ - - - - - Debug - AnyCPU - {08DD4305-7787-4823-A53F-4D0F725A07F3} - Library - Properties - Octokit - Octokit - v4.5 - 512 - en-US - 5 - - - - - true - full - false - obj\Debug\Net45 - bin\Debug\Net45 - TRACE;DEBUG;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - true - /assemblycomparemode:StrongNameIgnoringVersion - ..\Octokit.ruleset - true - false - - - pdbonly - true - obj\Release\Net45 - bin\Release\Net45\ - TRACE;CODE_ANALYSIS;SIMPLE_JSON_OBJARRAYINTERNAL;SIMPLE_JSON_INTERNAL;NET_45;SIMPLE_JSON_READONLY_COLLECTIONS - prompt - 4 - false - true - ..\Octokit.ruleset - bin\Release\Net45\Octokit.XML - 1591 - - - - - - - - - - - - Properties\SolutionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - - Code - - - - - - - Code - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CustomDictionary.xml - - - - - - Designer - - - - - - - \ No newline at end of file diff --git a/Octokit/Octokit.csproj.DotSettings b/Octokit/Octokit.csproj.DotSettings deleted file mode 100644 index c337eb80..00000000 --- a/Octokit/Octokit.csproj.DotSettings +++ /dev/null @@ -1,6 +0,0 @@ - - True - True - True - True - True \ No newline at end of file diff --git a/Octokit.Next/Octokit.Next.xproj b/Octokit/Octokit.xproj similarity index 85% rename from Octokit.Next/Octokit.Next.xproj rename to Octokit/Octokit.xproj index 4f649fe3..1996957d 100644 --- a/Octokit.Next/Octokit.Next.xproj +++ b/Octokit/Octokit.xproj @@ -7,11 +7,11 @@ - 4052af53-4c1b-48d1-b873-bfd0351481c3 - Octokit.Next + 104e8324-c2b9-43be-8040-36b736a64d45 + Octokit .\obj .\bin\ - v4.5 + v4.6 diff --git a/Octokit/SimpleJson.cs b/Octokit/SimpleJson.cs index 78baee56..40dca76c 100644 --- a/Octokit/SimpleJson.cs +++ b/Octokit/SimpleJson.cs @@ -59,7 +59,9 @@ 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 @@ -88,12 +90,12 @@ namespace Octokit class JsonArray : List { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public JsonArray() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The capacity of the json array. public JsonArray(int capacity) : base(capacity) { } @@ -490,7 +492,7 @@ namespace Octokit /// /// This class encodes and decodes JSON strings. /// Spec. details, see http://www.json.org/ - /// + /// /// JSON uses Arrays and Objects. These correspond here to the datatypes JsonArray(IList<object>) and JsonObject(IDictionary<string,object>). /// All numbers are parsed to doubles. /// @@ -546,7 +548,12 @@ namespace Octokit object obj; if (TryDeserializeObject(json, out obj)) return obj; + +#if !NO_SERIALIZABLE throw new SerializationException("Invalid JSON string"); +#else + throw new Exception("Invalid JSON string"); +#endif } /// @@ -1756,24 +1763,55 @@ namespace Octokit return GetTypeInfo(type1).IsAssignableFrom(GetTypeInfo(type2)); } - public static bool IsTypeDictionary(Type type) + public static IEnumerable GetInterfaces(Type type) { #if SIMPLE_JSON_TYPEINFO - if (typeof(IDictionary<,>).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) - return true; + return type.GetTypeInfo().ImplementedInterfaces; #else + return type.GetInterfaces(); +#endif + } + + public static bool IsTypeDictionary(Type type) + { +#if !SIMPLE_JSON_TYPEINFO if (typeof(System.Collections.IDictionary).IsAssignableFrom(type)) return true; #endif - if (!GetTypeInfo(type).IsGenericType) + if (!IsTypeGeneric(type)) return false; - Type genericDefinition = type.GetGenericTypeDefinition(); - return genericDefinition == typeof(IDictionary<,>) + if (GetTypeInfo(type).IsInterface) + { + var interfaceDefinition = GetTypeInfo(type).GetGenericTypeDefinition(); + if (interfaceDefinition == typeof(IDictionary<,>) #if SIMPLE_JSON_READONLY_COLLECTIONS - || genericDefinition == typeof(IReadOnlyDictionary<,>) + || interfaceDefinition == typeof(IReadOnlyDictionary<,>) #endif - ; + ) + { + return true; + } + } + + var interfaces = GetInterfaces(type); + foreach (var i in interfaces) + { + if (IsTypeGeneric(i)) + { + var interfaceDefinition = GetTypeInfo(i).GetGenericTypeDefinition(); + if (interfaceDefinition == typeof(IDictionary<,>) +#if SIMPLE_JSON_READONLY_COLLECTIONS + || interfaceDefinition == typeof(IReadOnlyDictionary<,>) +#endif + ) + { + return true; + } + } + } + + return false; } public static bool IsNullableType(Type type) diff --git a/Octokit/packages.Octokit-Portable.config b/Octokit/packages.Octokit-Portable.config deleted file mode 100644 index 5e04ba62..00000000 --- a/Octokit/packages.Octokit-Portable.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Octokit/packages.config b/Octokit/packages.config deleted file mode 100644 index 3ea7ffea..00000000 --- a/Octokit/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/Octokit/project.json b/Octokit/project.json new file mode 100644 index 00000000..a5a90109 --- /dev/null +++ b/Octokit/project.json @@ -0,0 +1,50 @@ +{ + "version": "1.0.0-*", + "title": "Octokit", + "authors": [ + "GitHub" + ], + "description": "An async-based GitHub API client library for .NET", + "xmlDoc": true, + "buildOptions": { + "compile": { + "includeFiles": [ + "../SolutionInfo.cs" + ] + } + }, + "packOptions": { + "summary": "An async-based GitHub API client library for .NET" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + "buildOptions": { + "define": [ + "HAS_TYPEINFO", + "SIMPLE_JSON_INTERNAL", + "SIMPLE_JSON_OBJARRAYINTERNAL", + "SIMPLE_JSON_READONLY_COLLECTIONS", + "SIMPLE_JSON_TYPEINFO", + "NO_SERIALIZABLE" + ] + } + }, + "net45": { + "buildOptions": { + "define": [ + "HAS_ENVIRONMENT", + "HAS_REGEX_COMPILED_OPTIONS", + "SIMPLE_JSON_INTERNAL", + "SIMPLE_JSON_OBJARRAYINTERNAL", + "SIMPLE_JSON_READONLY_COLLECTIONS" + ] + }, + "frameworkAssemblies": { + "System.Net.Http": "4.0.0.0" + } + } + } +} \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 9b4320e3..fa95d0ad 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,11 +1,8 @@ init: - git config --global core.autocrlf input build_script: - - cmd: build.cmd BuildApp - - cmd: build.cmd UnitTests - - cmd: build.cmd ConventionTests - - cmd: build.cmd CreatePackages - - cmd: build.cmd UnitTestsDotNetCore + - dotnet --info + - cmd: build.cmd test: off nuget: account_feed: true diff --git a/build.cmd b/build.cmd index 789b8463..07a71339 100644 --- a/build.cmd +++ b/build.cmd @@ -1,35 +1,10 @@ @echo off -"tools\nuget\nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.1.0" -verbosity quiet -"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.39.1" -verbosity quiet -"tools\nuget\nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet -"tools\nuget\nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet -"tools\nuget\nuget.exe" "install" "FSharp.Data" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.3.2" -verbosity quiet - :Build cls -SET TARGET="Default" - -IF NOT [%1]==[] (set TARGET="%1") - -SET BUILDMODE="Release" -IF NOT [%2]==[] (set BUILDMODE="%2") - -:: because we want to run specific steps inline on qed -:: we need to break the dependency chain -:: this ensures we do a build before running any tests - -if %TARGET%=="Default" (SET RunBuild=1) -if %TARGET%=="RunUnitTests" (SET RunBuild=1) -if %TARGET%=="RunIntegrationTests" (SET RunBuild=1) -if %TARGET%=="CreatePackages" (SET RunBuild=1) - -if NOT "%RunBuild%"=="" ( -"tools\FAKE.Core\tools\Fake.exe" "build.fsx" "target=BuildApp" "buildMode=%BUILDMODE%" -) - -"tools\FAKE.Core\tools\Fake.exe" "build.fsx" "target=%TARGET%" "buildMode=%BUILDMODE%" +dotnet restore .\build --verbosity error +dotnet run -p .\build -- %* rem Bail if we're running a TeamCity build. if defined TEAMCITY_PROJECT_NAME goto Quit diff --git a/build.fsx b/build.fsx deleted file mode 100644 index 3a9a5067..00000000 --- a/build.fsx +++ /dev/null @@ -1,337 +0,0 @@ -#r @"tools/FAKE.Core/tools/FakeLib.dll" -#r @"tools/FSharp.Data/lib/net40/FSharp.Data.dll" -#r "System.Xml.Linq" -#load "tools/SourceLink.Fake/tools/SourceLink.fsx" -open Fake -open System -open System.IO -open SourceLink -open FSharp.Data - -let authors = ["GitHub"] - -// project name and description -let projectName = "Octokit" -let projectDescription = "An async-based GitHub API client library for .NET" -let projectSummary = projectDescription // TODO: write a summary - -let reactiveProjectName = "Octokit.Reactive" -let reactiveProjectDescription = "An IObservable based GitHub API client library for .NET using Reactive Extensions" -let reactiveProjectSummary = reactiveProjectDescription // TODO: write a summary - -// directories -let buildDir = "./Octokit/bin" -let reactiveBuildDir = "./Octokit.Reactive/bin" -let testResultsDir = "./testresults" -let packagingRoot = "./packaging/" -let samplesDir = "./samples" -let packagingDir = packagingRoot @@ "octokit" -let reactivePackagingDir = packagingRoot @@ "octokit.reactive" -let linqPadDir = "./tools/LINQPad" - -let releaseNotes = - ReadFile "ReleaseNotes.md" - |> ReleaseNotesHelper.parseReleaseNotes - -let buildMode = getBuildParamOrDefault "buildMode" "Release" - -MSBuildDefaults <- { - MSBuildDefaults with - ToolsVersion = Some "14.0" - Verbosity = Some MSBuildVerbosity.Minimal } - -Target "Clean" (fun _ -> - CleanDirs [buildDir; reactiveBuildDir; testResultsDir; packagingRoot; packagingDir; reactivePackagingDir] -) - -open Fake.AssemblyInfoFile -open Fake.Testing - -Target "AssemblyInfo" (fun _ -> - CreateCSharpAssemblyInfo "./SolutionInfo.cs" - [ Attribute.Product projectName - Attribute.Version releaseNotes.AssemblyVersion - Attribute.FileVersion releaseNotes.AssemblyVersion - Attribute.ComVisible false ] -) - -Target "CheckProjects" (fun _ -> - !! "./Octokit/Octokit*.csproj" - |> Fake.MSBuild.ProjectSystem.CompareProjectsTo "./Octokit/Octokit.csproj" - - !! "./Octokit.Reactive/Octokit.Reactive*.csproj" - |> Fake.MSBuild.ProjectSystem.CompareProjectsTo "./Octokit.Reactive/Octokit.Reactive.csproj" -) - -let codeFormatter = @"tools\Octokit.CodeFormatter\tools\CodeFormatter.exe" - -Target "FormatCode" (fun _ -> - [ "Octokit" - "Octokit.Reactive" - "Octokit.Tests" - "Octokit.Tests.Conventions" - "Octokit.Tests.Integration"] - |> Seq.iter (fun pf -> - let project = pf + "/" + pf + ".csproj" - ExecProcess (fun info -> - info.FileName <- codeFormatter - info.Arguments <- project + " /nocopyright /nounicode") (TimeSpan.FromMinutes 1.0) - |> ignore - ) -) - -Target "FixProjects" (fun _ -> - !! "./Octokit/Octokit*.csproj" - |> Fake.MSBuild.ProjectSystem.FixProjectFiles "./Octokit/Octokit.csproj" - - !! "./Octokit.Reactive/Octokit.Reactive*.csproj" - |> Fake.MSBuild.ProjectSystem.FixProjectFiles "./Octokit.Reactive/Octokit.Reactive.csproj" -) - -let setParams defaults = { - defaults with - ToolsVersion = Some("14.0") - Targets = ["Build"] - Properties = - [ - "Configuration", buildMode - ] - } - -let Exec command args = - let result = Shell.Exec(command, args) - if result <> 0 then failwithf "%s exited with error %d" command result - -Target "BuildApp" (fun _ -> - build setParams "./Octokit.sln" - |> DoNothing -) - -Target "BuildMono" (fun _ -> - // xbuild does not support msbuild tools version 14.0 and that is the reason - // for using the xbuild command directly instead of using msbuild - Exec "xbuild" "./Octokit-Mono.sln /t:Build /tv:12.0 /v:m /p:RestorePackages='False' /p:Configuration='Release' /logger:Fake.MsBuildLogger+ErrorLogger,'../octokit.net/tools/FAKE.Core/tools/FakeLib.dll'" -) - -Target "RestoreDotNetCore" (fun _ -> - [ "./Octokit.Next" - "./Octokit.Next.Tests" ] - |> Seq.iter (fun d -> - Fake.DotNetCli.Restore (fun p -> - { p with - WorkingDir = d }) - ) -) - -Target "BuildDotNetCore" (fun _ -> - !! "./**/project.json" - |> Fake.DotNetCli.Build id -) - -Target "UnitTestsDotNetCore" (fun _ -> - !! "./Octokit.Next.Tests" - |> Fake.DotNetCli.Test id -) - -Target "ConventionTests" (fun _ -> - !! (sprintf "./Octokit.Tests.Conventions/bin/%s/**/Octokit.Tests.Conventions.dll" buildMode) - |> xUnit2 (fun p -> - {p with - HtmlOutputPath = Some (testResultsDir @@ "xunit.html") }) -) - -Target "UnitTests" (fun _ -> - !! (sprintf "./Octokit.Tests/bin/%s/**/Octokit.Tests*.dll" buildMode) - |> xUnit2 (fun p -> - {p with - HtmlOutputPath = Some (testResultsDir @@ "xunit.html") }) -) - -Target "IntegrationTests" (fun _ -> - if hasBuildParam "OCTOKIT_GITHUBUSERNAME" && hasBuildParam "OCTOKIT_GITHUBPASSWORD" then - !! (sprintf "./Octokit.Tests.Integration/bin/%s/**/Octokit.Tests.Integration.dll" buildMode) - |> xUnit2 (fun p -> - {p with - HtmlOutputPath = Some (testResultsDir @@ "xunit.html") - TimeOut = TimeSpan.FromMinutes 10.0 }) - else - "The integration tests were skipped because the OCTOKIT_GITHUBUSERNAME and OCTOKIT_GITHUBPASSWORD environment variables are not set. " + - "Please configure these environment variables for a GitHub test account (DO NOT USE A \"REAL\" ACCOUNT)." - |> traceImportant -) - -Target "SourceLink" (fun _ -> - [ "Octokit/Octokit.csproj" - "Octokit/Octokit-netcore45.csproj" - "Octokit/Octokit-Portable.csproj" - "Octokit.Reactive/Octokit.Reactive.csproj" ] - |> Seq.iter (fun pf -> - let proj = VsProj.LoadRelease pf - let url = "https://raw.githubusercontent.com/octokit/octokit.net/{0}/%var2%" - SourceLink.Index proj.Compiles proj.OutputFilePdb __SOURCE_DIRECTORY__ url - ) -) - -type LinqPadSampleMetadata = XmlProvider<""" - - Octokit - Octokit.Reactive - Rx-Main - Octokit - System.Reactive.Linq - System.Threading.Tasks - -"""> - -Target "ValidateLINQPadSamples" (fun _ -> - - let splitFileContents = fun (file: FileInfo) -> - let content = File.ReadAllText(file.FullName) - let closeTag = "" - let openTagIndex = content.IndexOf("") - let closeTagIndex = content.IndexOf(closeTag) - let endOfXml = closeTagIndex + closeTag.Length - let xmlPart = content.Substring(openTagIndex, endOfXml - openTagIndex) - let rest = content.Substring(endOfXml) - - file.Name, xmlPart, rest - - let createTempFile = fun (fileName: string, metadataString: string, rest: string) -> - let metadata = LinqPadSampleMetadata.Parse(metadataString) - let assembliesDir = buildDir @@ "Release/Net45" - let reactiveAssembliesDir = reactiveBuildDir @@ "Release/Net45" - let tempFileName = Path.GetTempFileName() - use stream = File.OpenWrite(tempFileName) - use writer = new StreamWriter(stream) - - writer.WriteLine("ref {0}\\System.Reactive.Core.dll;", reactiveAssembliesDir); - writer.WriteLine("ref {0}\\System.Reactive.Interfaces.dll;", reactiveAssembliesDir); - writer.WriteLine("ref {0}\\System.Reactive.Linq.dll;", reactiveAssembliesDir); - writer.WriteLine("ref {0}\\Octokit.dll;", assembliesDir); - writer.WriteLine("ref {0}\\Octokit.Reactive.dll;", reactiveAssembliesDir); - writer.WriteLine("ref C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5\\System.Net.Http.dll;"); - - for metadataNamespace in metadata.Namespaces do - writer.WriteLine("using {0};", metadataNamespace) - - writer.WriteLine() - writer.WriteLine(rest) - - writer.Flush() - - fileName, tempFileName - - directoryInfo(samplesDir @@ "linqpad-samples") - |> filesInDir - |> Array.map (splitFileContents >> createTempFile) - |> Seq.iter (fun (fileName, sample) -> - printfn "Executing sample %s" fileName - let result = ExecProcess (fun info -> - info.FileName <- linqPadDir @@ "lprun.exe" - info.Arguments <- "-compileonly -lang=Program " + sample) (TimeSpan.FromMinutes 5.0) - - if result <> 0 then failwithf "lprun.exe returned with a non-zero exit code for %s" sample - ) -) - -Target "CreateOctokitPackage" (fun _ -> - let net45Dir = packagingDir @@ "lib/net45/" - let netcore45Dir = packagingDir @@ "lib/netcore451/" - let portableDir = packagingDir @@ "lib/portable-net45+wp80+win+wpa81/" - let linqpadSamplesDir = packagingDir @@ "linqpad-samples" - CleanDirs [net45Dir; netcore45Dir; portableDir;linqpadSamplesDir] - - CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.dll") - CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.XML") - CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.pdb") - CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.dll") - CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.XML") - CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.pdb") - CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.dll") - CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.XML") - CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.pdb") - CopyDir packagingDir "./samples" allFiles - CopyFiles packagingDir ["LICENSE.txt"; "README.md"; "ReleaseNotes.md"] - - NuGet (fun p -> - {p with - Authors = authors - Project = projectName - Description = projectDescription - OutputPath = packagingRoot - Summary = projectSummary - WorkingDir = packagingDir - Version = releaseNotes.AssemblyVersion - ReleaseNotes = toLines releaseNotes.Notes - AccessKey = getBuildParamOrDefault "nugetkey" "" - Publish = hasBuildParam "nugetkey" }) "octokit.nuspec" -) - -Target "CreateOctokitReactivePackage" (fun _ -> - let net45Dir = reactivePackagingDir @@ "lib/net45/" - let linqpadSamplesDir = reactivePackagingDir @@ "linqpad-samples" - CleanDirs [net45Dir;linqpadSamplesDir] - - CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.dll") - CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.XML") - CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.pdb") - CopyFiles reactivePackagingDir ["LICENSE.txt"; "README.md"; "ReleaseNotes.md"] - - NuGet (fun p -> - {p with - Authors = authors - Project = reactiveProjectName - Description = reactiveProjectDescription - OutputPath = packagingRoot - Summary = reactiveProjectSummary - WorkingDir = reactivePackagingDir - Version = releaseNotes.AssemblyVersion - ReleaseNotes = toLines releaseNotes.Notes - Dependencies = - ["Octokit", NormalizeVersion releaseNotes.AssemblyVersion - "Rx-Main", GetPackageVersion "./packages/" "Rx-Main"] - AccessKey = getBuildParamOrDefault "nugetkey" "" - Publish = hasBuildParam "nugetkey" }) "Octokit.Reactive.nuspec" -) - -Target "Default" DoNothing - -Target "CreatePackages" DoNothing - - -"Clean" - ==> "AssemblyInfo" - ==> "CheckProjects" - ==> "BuildApp" - -"Clean" - ==> "AssemblyInfo" - ==> "CheckProjects" - ==> "BuildMono" - -"RestoreDotNetCore" - ==> "BuildDotNetCore" - ==> "UnitTestsDotNetCore" - -"UnitTests" - ==> "Default" - -"ConventionTests" - ==> "Default" - -"IntegrationTests" - ==> "Default" - -"SourceLink" - ==> "CreatePackages" - -"CreateOctokitPackage" - ==> "CreatePackages" - -"CreateOctokitReactivePackage" - ==> "CreatePackages" - -"ValidateLINQPadSamples" - ==> "CreatePackages" - -RunTargetOrDefault "Default" diff --git a/build.sh b/build.sh index f4f849df..d7734583 100755 --- a/build.sh +++ b/build.sh @@ -1,22 +1,3 @@ #!/bin/bash -if test "$OS" = "Windows_NT" -then - # use .Net - -"./tools/nuget/nuget.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet -"./tools/nuget/nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.39.1" -verbosity quiet -"./tools/nuget/nuget.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet -"./tools/nuget/nuget.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet -"./tools/nuget/nuget.exe" "install" "FSharp.Data" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.3.2" -verbosity quiet -packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx -else - # use mono -mono "./tools/nuget/NuGet.exe" "install" "xunit.runner.console" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.0.0" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "4.39.1" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "SourceLink.Fake" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.1.0" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "Octokit.CodeFormatter" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "1.0.0-preview" -Pre -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "FSharp.Data" "-OutputDirectory" "tools" "-ExcludeVersion" "-version" "2.3.2" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "System.Net.Http" "-OutputDirectory" "tools" -verbosity quiet -mono "./tools/nuget/NuGet.exe" "install" "Microsoft.Net.Http" "-OutputDirectory" "tools" -verbosity quiet -mono ./tools/FAKE.Core/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx -fi +dotnet restore ./build --verbosity=error +dotnet run -p ./build -- "$@" diff --git a/build/.vscode/launch.json b/build/.vscode/launch.json new file mode 100644 index 00000000..46d477c6 --- /dev/null +++ b/build/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.0\\build.dll", + "args": [], + "cwd": "${workspaceRoot}", + "externalConsole": false, + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] +} \ No newline at end of file diff --git a/build/.vscode/tasks.json b/build/.vscode/tasks.json new file mode 100644 index 00000000..9cd37c15 --- /dev/null +++ b/build/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}\\project.json" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/build/PdbGit/PdbGitAliases.cs b/build/PdbGit/PdbGitAliases.cs new file mode 100644 index 00000000..f873a8b7 --- /dev/null +++ b/build/PdbGit/PdbGitAliases.cs @@ -0,0 +1,21 @@ +using Cake.Core; +using Cake.Core.IO; + +public static class PdbGitAliases +{ + public static void PdbGit(this ICakeContext context, FilePath pdbFile) + { + context.PdbGit(pdbFile, new PdbGitSettings()); + } + + public static void PdbGit(this ICakeContext context, FilePath pdbFile, PdbGitSettings settings) + { + var tool = new PdbGitTool( + context.FileSystem, + context.Environment, + context.ProcessRunner, + context.Tools); + + tool.Run(pdbFile, settings); + } +} diff --git a/build/PdbGit/PdbGitMethod.cs b/build/PdbGit/PdbGitMethod.cs new file mode 100644 index 00000000..964143b4 --- /dev/null +++ b/build/PdbGit/PdbGitMethod.cs @@ -0,0 +1,5 @@ +public enum PdbGitMethod +{ + Http, + Powershell +} \ No newline at end of file diff --git a/build/PdbGit/PdbGitRunner.cs b/build/PdbGit/PdbGitRunner.cs new file mode 100644 index 00000000..e04e3dfa --- /dev/null +++ b/build/PdbGit/PdbGitRunner.cs @@ -0,0 +1,90 @@ +using Cake.Core; +using Cake.Core.IO; +using Cake.Core.Tooling; +using System; +using System.Collections.Generic; +using System.Linq; + +public class PdbGitTool : Tool +{ + private readonly ICakeEnvironment _environment; + + public PdbGitTool( + IFileSystem fileSystem, + ICakeEnvironment environment, + IProcessRunner processRunner, + IToolLocator tools) + : base(fileSystem, environment, processRunner, tools) + { + _environment = environment; + } + + public void Run(FilePath pdbFile, PdbGitSettings settings) + { + if (pdbFile == null) + { + throw new ArgumentNullException(nameof(pdbFile)); + } + + if (settings == null) + { + throw new ArgumentNullException(nameof(settings)); + } + + Run(settings, GetArguments(pdbFile, settings)); + } + + private ProcessArgumentBuilder GetArguments(FilePath pdbFile, PdbGitSettings settings) + { + var builder = new ProcessArgumentBuilder(); + + // pdb file + builder.AppendQuoted(pdbFile.MakeAbsolute(_environment).FullPath); + + // Method + if (settings.Method.HasValue) + { + builder.Append("--method"); + builder.Append(settings.Method.Value.ToString()); + } + + // Repository URL + if (!string.IsNullOrEmpty(settings.RepositoryUrl)) + { + builder.Append("--url"); + builder.Append(settings.RepositoryUrl); + } + + // Commit + if (!string.IsNullOrEmpty(settings.CommitSha)) + { + builder.Append("--commit"); + builder.Append(settings.CommitSha); + } + + // Base directory + if (settings.BaseDirectory != null) + { + builder.Append("--baseDir"); + builder.AppendQuoted(settings.BaseDirectory.MakeAbsolute(_environment).FullPath); + } + + // Skip verify + if (settings.SkipVerify) + { + builder.Append("--skipVerify"); + } + + return builder; + } + + protected override IEnumerable GetToolExecutableNames() + { + return new[] { "pdbgit.exe" }; + } + + protected override string GetToolName() + { + return "PdbGit"; + } +} diff --git a/build/PdbGit/PdbGitSettings.cs b/build/PdbGit/PdbGitSettings.cs new file mode 100644 index 00000000..75a05bed --- /dev/null +++ b/build/PdbGit/PdbGitSettings.cs @@ -0,0 +1,11 @@ +using Cake.Core.IO; +using Cake.Core.Tooling; + +public class PdbGitSettings : ToolSettings +{ + public PdbGitMethod? Method { get; set; } + public string RepositoryUrl { get; set; } + public string CommitSha { get; set; } + public DirectoryPath BaseDirectory { get; set; } + public bool SkipVerify { get; set; } +} diff --git a/build/Program.cs b/build/Program.cs new file mode 100644 index 00000000..48c18c0e --- /dev/null +++ b/build/Program.cs @@ -0,0 +1,31 @@ +using System.IO; +using Cake.Core; +using Cake.Frosting; + +public class Program +{ + public static int Main(string[] args) + { + // Create the host. + var host = new CakeHostBuilder() + .WithArguments(args) + .ConfigureServices(services => + { + // Use a custom settings class. + services.UseContext(); + + // Use a custom lifetime to initialize the context. + services.UseLifetime(); + + if (Directory.GetCurrentDirectory().EndsWith("build")) + { + // Use the parent directory as the working directory. + services.UseWorkingDirectory(".."); + } + }) + .Build(); + + // Run the host. + return host.Run(); + } +} \ No newline at end of file diff --git a/build/Tasks/Build.cs b/build/Tasks/Build.cs new file mode 100644 index 00000000..07e6a863 --- /dev/null +++ b/build/Tasks/Build.cs @@ -0,0 +1,23 @@ +using Cake.Common.Diagnostics; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Build; +using Cake.Frosting; + +[Dependency(typeof(Restore))] +public class Build : FrostingTask +{ + public override void Run(BuildContext context) + { + foreach(var project in context.Projects) + { + context.Information("Building {0}...", project.Name); + context.DotNetCoreBuild( + project.Path.FullPath, + new DotNetCoreBuildSettings + { + Configuration = context.Configuration, + VersionSuffix = context.Suffix + }); + } + } +} \ No newline at end of file diff --git a/build/Tasks/Clean.cs b/build/Tasks/Clean.cs new file mode 100644 index 00000000..efbded6b --- /dev/null +++ b/build/Tasks/Clean.cs @@ -0,0 +1,14 @@ +using Cake.Common.IO; +using Cake.Frosting; + +public class Clean : FrostingTask +{ + public override void Run(BuildContext context) + { + if (context.DirectoryExists(context.OutputDir)) + { + context.DeleteDirectory(context.OutputDir, recursive: true); + } + context.CreateDirectory(context.OutputDir); + } +} \ No newline at end of file diff --git a/build/Tasks/Default.cs b/build/Tasks/Default.cs new file mode 100644 index 00000000..e1ae0d61 --- /dev/null +++ b/build/Tasks/Default.cs @@ -0,0 +1,6 @@ +using Cake.Frosting; + +[Dependency(typeof(Package))] +public class Default : FrostingTask +{ +} \ No newline at end of file diff --git a/build/Tasks/IntegrationTests.cs b/build/Tasks/IntegrationTests.cs new file mode 100644 index 00000000..631bdaf7 --- /dev/null +++ b/build/Tasks/IntegrationTests.cs @@ -0,0 +1,39 @@ +using System.Linq; +using Cake.Common.Diagnostics; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Test; +using Cake.Frosting; + +[Dependency(typeof(Build))] +public class IntegrationTests : FrostingTask +{ + public override void Run(BuildContext context) + { + foreach (var project in context.Projects.Where(x => x.IntegrationTests)) + { + context.Information("Executing Integration Tests Project {0}...", project.Name); + context.DotNetCoreTest( + project.Path.FullPath, + new DotNetCoreTestSettings + { + Configuration = context.Configuration, + NoBuild = true, + Verbose = false + }); + } + } + + public override bool ShouldRun(BuildContext context) + { + var environmentVariablesNames = new[] { "OCTOKIT_GITHUBUSERNAME", "OCTOKIT_GITHUBPASSWORD" }; + var areEnvironmentVariablesSet = environmentVariablesNames.All(x => !string.IsNullOrEmpty(context.Environment.GetEnvironmentVariable(x))); + + if (!areEnvironmentVariablesSet) + { + context.Warning($"The integration tests were skipped because the following environment variables are not set: {string.Join(", ", environmentVariablesNames)}."); + context.Warning("Please configure these environment variables for a GitHub test account (DO NOT USE A \"REAL\" ACCOUNT)."); + } + + return areEnvironmentVariablesSet; + } +} \ No newline at end of file diff --git a/build/Tasks/LinkSources.cs b/build/Tasks/LinkSources.cs new file mode 100644 index 00000000..d75a7867 --- /dev/null +++ b/build/Tasks/LinkSources.cs @@ -0,0 +1,48 @@ +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Core; +using Cake.Core.IO; +using Cake.Frosting; +using System.Linq; + +[Dependency(typeof(Build))] +public class LinkSources : FrostingTask +{ + public override void Run(BuildContext context) + { + var matchingDirectories = context + .Projects + .Where(x => !x.IsTests) + .Select(x => x.Name) + .ToArray(); + + var pdbFiles = context.Globber + .Match("**/*.pdb", x => x.Path.Segments.Intersect(matchingDirectories).Any()) + .Cast() + .ToArray(); + + var settings = new PdbGitSettings(); + if (context.AppVeyor && !context.IsOriginalRepo) + { + var appVeyorInformation = context.BuildSystem().AppVeyor.Environment; + + settings.RepositoryUrl = $"https://raw.githubusercontent.com/{appVeyorInformation.Repository.Name}"; + settings.CommitSha = appVeyorInformation.Repository.Commit.Id; + + context.Information($"The build doesn't run against the original repository"); + context.Information($"Using '{settings.RepositoryUrl}' as the repository URL and {settings.CommitSha} as the commit SHA"); + } + + foreach (var pdbFile in pdbFiles) + { + context.PdbGit(pdbFile); + } + + context.Information($"Successfully linked sources in {pdbFiles.Length} pdb files"); + } + + public override bool ShouldRun(BuildContext context) + { + return !context.Environment.Platform.IsUnix(); + } +} diff --git a/build/Tasks/Package.cs b/build/Tasks/Package.cs new file mode 100644 index 00000000..aa0232e8 --- /dev/null +++ b/build/Tasks/Package.cs @@ -0,0 +1,28 @@ +using Cake.Common.Diagnostics; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Pack; +using Cake.Frosting; + +[Dependency(typeof(UnitTests))] +[Dependency(typeof(LinkSources))] +public class Package : FrostingTask +{ + public override void Run(BuildContext context) + { + foreach (var project in context.Projects) + { + if (project.Publish) + { + context.Information("Packing {0}...", project.Name); + context.DotNetCorePack(project.Path.FullPath, new DotNetCorePackSettings() + { + OutputDirectory = context.OutputDir, + Configuration = context.Configuration, + VersionSuffix = context.Suffix, + NoBuild = true, + Verbose = false + }); + } + } + } +} \ No newline at end of file diff --git a/build/Tasks/Restore.cs b/build/Tasks/Restore.cs new file mode 100644 index 00000000..0adc6399 --- /dev/null +++ b/build/Tasks/Restore.cs @@ -0,0 +1,18 @@ +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Restore; +using Cake.Frosting; + +[Dependency(typeof(Clean))] +[Dependency(typeof(UpdateVersionInfo))] +public class Restore : FrostingTask +{ + public override void Run(BuildContext context) + { + context.DotNetCoreRestore( + ".", + new DotNetCoreRestoreSettings + { + Verbose = false + }); + } +} \ No newline at end of file diff --git a/build/Tasks/UnitTests.cs b/build/Tasks/UnitTests.cs new file mode 100644 index 00000000..fdb74ca1 --- /dev/null +++ b/build/Tasks/UnitTests.cs @@ -0,0 +1,25 @@ +using System.Linq; +using Cake.Common.Diagnostics; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Test; +using Cake.Frosting; + +[Dependency(typeof(Build))] +public class UnitTests : FrostingTask +{ + public override void Run(BuildContext context) + { + foreach (var project in context.Projects.Where(x => x.UnitTests)) + { + context.Information("Executing Unit Tests Project {0}...", project.Name); + context.DotNetCoreTest( + project.Path.FullPath, + new DotNetCoreTestSettings + { + Configuration = context.Configuration, + NoBuild = true, + Verbose = false + }); + } + } +} \ No newline at end of file diff --git a/build/Tasks/UpdateVersionInfo.cs b/build/Tasks/UpdateVersionInfo.cs new file mode 100644 index 00000000..ca571f25 --- /dev/null +++ b/build/Tasks/UpdateVersionInfo.cs @@ -0,0 +1,23 @@ +using System.Text; +using Cake.Common.Diagnostics; +using Cake.Frosting; + +public class UpdateVersionInfo : FrostingTask +{ + public override void Run(BuildContext context) + { + var newVersion = context.Version + "-*"; + context.Information("Updating version in project files to {0} ...", newVersion); + + foreach (var project in context.Projects) + { + var content = System.IO.File.ReadAllText(project.Path.FullPath, Encoding.UTF8); + var node = Newtonsoft.Json.Linq.JObject.Parse(content); + if (node["version"] != null && node["version"].ToString() != newVersion) + { + node["version"].Replace(newVersion); + System.IO.File.WriteAllText(project.Path.FullPath, node.ToString(), Encoding.UTF8); + }; + } + } +} \ No newline at end of file diff --git a/build/Utilities/BuildContext.cs b/build/Utilities/BuildContext.cs new file mode 100644 index 00000000..29243ce6 --- /dev/null +++ b/build/Utilities/BuildContext.cs @@ -0,0 +1,31 @@ +using Cake.Core; +using Cake.Frosting; + +public class BuildContext : FrostingContext +{ + public string Target { get; set; } + public string Configuration { get; set; } + public string Version { get; set; } + public string Suffix { get; set; } + + public string OutputDir { get; set; } + + public string MyGetSource { get; set; } + public string MyGetApiKey { get; set; } + + public bool IsLocalBuild { get; set; } + public bool IsPullRequest { get; set; } + public bool IsOriginalRepo { get; set; } + public bool IsTagged { get; set; } + public bool IsMasterBranch { get; set; } + public bool ForcePublish { get; set; } + + public bool AppVeyor { get; set; } + public bool TravisCI { get; set; } + public Project[] Projects { get; set; } + + public BuildContext(ICakeContext context) + : base(context) + { + } +} \ No newline at end of file diff --git a/build/Utilities/BuildLifetime.cs b/build/Utilities/BuildLifetime.cs new file mode 100644 index 00000000..c118bbf9 --- /dev/null +++ b/build/Utilities/BuildLifetime.cs @@ -0,0 +1,143 @@ +using System; +using System.Text; +using Cake.Common; +using Cake.Common.Build; +using Cake.Common.Diagnostics; +using Cake.Common.Tools.DotNetCore; +using Cake.Common.Tools.DotNetCore.Restore; +using Cake.Common.Tools.GitVersion; +using Cake.Core; +using Cake.Frosting; + +public class BuildLifetime : FrostingLifetime +{ + public override void Setup(BuildContext context) + { + context.Target = context.Argument("target", "Default"); + context.Configuration = context.Argument("configuration", "Release"); + + context.OutputDir = "./packaging/"; + + // Build system information. + var buildSystem = context.BuildSystem(); + context.IsLocalBuild = buildSystem.IsLocalBuild; + + context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor; + context.TravisCI = buildSystem.TravisCI.IsRunningOnTravisCI; + context.IsTagged = IsBuildTagged(buildSystem); + + if (context.AppVeyor) + { + context.IsPullRequest = buildSystem.AppVeyor.Environment.PullRequest.IsPullRequest; + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.AppVeyor.Environment.Repository.Name); + context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.AppVeyor.Environment.Repository.Branch); + } + else if (context.TravisCI) + { + context.IsPullRequest = !string.IsNullOrEmpty(buildSystem.TravisCI.Environment.Repository.PullRequest); + context.IsOriginalRepo = StringComparer.OrdinalIgnoreCase.Equals("octokit/octokit.net", buildSystem.TravisCI.Environment.Repository.Slug); + context.IsMasterBranch = StringComparer.OrdinalIgnoreCase.Equals("master", buildSystem.TravisCI.Environment.Build.Branch); + } + + + // Force publish? + context.ForcePublish = context.Argument("forcepublish", false); + + // Setup projects. + context.Projects = new Project[] + { + new Project { Name = "Octokit", Path = "./Octokit/project.json", Publish = true }, + new Project { Name = "Octokit.Reactive", Path = "./Octokit.Reactive/project.json", Publish = true }, + new Project { Name = "Octokit.Tests", Path = "./Octokit.Tests/project.json", UnitTests = true }, + new Project { Name = "Octokit.Tests.Conventions", Path = "./Octokit.Tests.Conventions/project.json", UnitTests = true }, + new Project { Name = "Octokit.Tests.Integration", Path = "./Octokit.Tests.Integration/project.json", IntegrationTests = true } + }; + + // Install tools + context.Information("Installing tools..."); + context.DotNetCoreRestore("./build/tools.project.json", new DotNetCoreRestoreSettings + { + PackagesDirectory = "./tools", + Verbosity = DotNetCoreRestoreVerbosity.Error, + Sources = new[] + { + "https://api.nuget.org/v3/index.json" + } + }); + + // Calculate semantic version. + var info = GetVersion(context); + context.Version = context.Argument("version", info.Version); + context.Suffix = context.Argument("suffix", info.Suffix); + + context.Information("Version: {0}", context.Version); + context.Information("Version suffix: {0}", context.Suffix); + context.Information("Configuration: {0}", context.Configuration); + context.Information("Target: {0}", context.Target); + context.Information("AppVeyor: {0}", context.AppVeyor); + context.Information("TravisCI: {0}", context.TravisCI); + } + + private static BuildVersion GetVersion(BuildContext context) + { + string version = null; + string semVersion = null; + + if (context.IsRunningOnWindows()) + { + context.Information("Calculating semantic version..."); + if (!context.IsLocalBuild) + { + context.GitVersion(new GitVersionSettings + { + OutputType = GitVersionOutput.BuildServer + }); + } + + GitVersion assertedVersions = context.GitVersion(new GitVersionSettings + { + OutputType = GitVersionOutput.Json + }); + version = assertedVersions.MajorMinorPatch; + semVersion = assertedVersions.LegacySemVerPadded; + } + + if (string.IsNullOrEmpty(version) || string.IsNullOrEmpty(semVersion)) + { + context.Information("Fetching verson from first project.json..."); + foreach (var project in context.Projects) + { + var content = System.IO.File.ReadAllText(project.Path.FullPath, Encoding.UTF8); + var node = Newtonsoft.Json.Linq.JObject.Parse(content); + if (node["version"] != null) + { + version = node["version"].ToString().Replace("-*", ""); + } + } + semVersion = version; + } + + if (string.IsNullOrWhiteSpace(version)) + { + throw new CakeException("Could not calculate version of build."); + } + + return new BuildVersion(version, semVersion.Substring(version.Length).TrimStart('-')); + } + + private static bool IsBuildTagged(BuildSystem buildSystem) + { + return buildSystem.AppVeyor.Environment.Repository.Tag.IsTag + && !string.IsNullOrWhiteSpace(buildSystem.AppVeyor.Environment.Repository.Tag.Name); + } + + private static string GetEnvironmentValueOrArgument(BuildContext context, string environmentVariable, string argumentName) + { + var arg = context.EnvironmentVariable(environmentVariable); + if (string.IsNullOrWhiteSpace(arg)) + { + arg = context.Argument(argumentName, null); + } + return arg; + } +} \ No newline at end of file diff --git a/build/Utilities/BuildVersion.cs b/build/Utilities/BuildVersion.cs new file mode 100644 index 00000000..7c040d76 --- /dev/null +++ b/build/Utilities/BuildVersion.cs @@ -0,0 +1,16 @@ +public class BuildVersion +{ + public string Version { get; private set; } + public string Suffix { get; private set; } + + public BuildVersion(string version, string suffix) + { + Version = version; + Suffix = suffix; + + if(string.IsNullOrWhiteSpace(Suffix)) + { + Suffix = null; + } + } +} \ No newline at end of file diff --git a/build/Utilities/Project.cs b/build/Utilities/Project.cs new file mode 100644 index 00000000..63e6c91d --- /dev/null +++ b/build/Utilities/Project.cs @@ -0,0 +1,11 @@ +using Cake.Core.IO; + +public class Project +{ + public string Name { get; set; } + public FilePath Path { get; set; } + public bool Publish { get; set; } + public bool UnitTests { get; set; } + public bool IntegrationTests { get; set; } + public bool IsTests => UnitTests || IntegrationTests; +} \ No newline at end of file diff --git a/build/build.sln b/build/build.sln new file mode 100644 index 00000000..c50f8348 --- /dev/null +++ b/build/build.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "build", "build.xproj", "{C05F6D11-E3DF-41D0-9BB3-D7DD334EF904}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C05F6D11-E3DF-41D0-9BB3-D7DD334EF904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C05F6D11-E3DF-41D0-9BB3-D7DD334EF904}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C05F6D11-E3DF-41D0-9BB3-D7DD334EF904}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C05F6D11-E3DF-41D0-9BB3-D7DD334EF904}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/build.xproj b/build/build.xproj new file mode 100644 index 00000000..c986142f --- /dev/null +++ b/build/build.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c05f6d11-e3df-41d0-9bb3-d7dd334ef904 + build + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/build/nuget.config b/build/nuget.config new file mode 100644 index 00000000..09f2371f --- /dev/null +++ b/build/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build/project.json b/build/project.json new file mode 100644 index 00000000..94dd97e8 --- /dev/null +++ b/build/project.json @@ -0,0 +1,18 @@ +{ + "version": "0.1.0-*", + "buildOptions": { + "emitEntryPoint": true + }, + "dependencies": { + "Cake.Frosting": "0.1.0-alpha0034", + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "frameworks": { + "netcoreapp1.0": { + "imports": "dnxcore50" + } + } +} \ No newline at end of file diff --git a/build/tools.project.json b/build/tools.project.json new file mode 100644 index 00000000..fc95712d --- /dev/null +++ b/build/tools.project.json @@ -0,0 +1,10 @@ +{ + "dependencies": { + "GitVersion.CommandLine": "3.6.2", + "PdbGit": "3.0.38" + }, + "frameworks": { + "net45": { + } + } +} \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 00000000..6f82af11 --- /dev/null +++ b/global.json @@ -0,0 +1,12 @@ +{ + "projects": [ + "Octokit", + "Octokit.Reactive", + "Octokit.Tests", + "Octokit.Tests.Conventions", + "Octokit.Tests.Integration" + ], + "sdk": { + "version": "1.0.0-preview2-003131" + } +} \ No newline at end of file