From 95756169d6c06660fe8a631c8f9f48b9b8fc3a86 Mon Sep 17 00:00:00 2001 From: Chris Martinez Date: Thu, 9 Mar 2017 08:35:42 -0800 Subject: [PATCH] Upgrade to VS2017 (#99) --- .editorconfig | 84 +++++++++ ApiVersioning.sln | 114 +++--------- ApiVersioningWithSamples.sln | 127 ++++--------- ...stomDictionary.xml => CustomDictionary.xml | 0 build.targets | 47 +++++ global.json | 4 - pack.ps1 | 22 --- .../aspnetcore/BasicSample/BasicSample.csproj | 37 ++++ .../aspnetcore/BasicSample/BasicSample.xproj | 19 -- samples/aspnetcore/BasicSample/project.json | 61 ------- .../ConventionsSample.csproj | 36 ++++ .../ConventionsSample/ConventionsSample.xproj | 19 -- .../aspnetcore/ConventionsSample/project.json | 60 ------ .../AdvancedODataWebApiSample.csproj | 10 + .../BasicODataWebApiSample.csproj | 18 +- .../BasicWebApiSample.csproj | 9 +- .../ByNamespaceWebApiSample.csproj | 10 +- .../ConventionsODataWebApiSample.csproj | 16 +- .../ConventionsWebApiSample.csproj | 9 +- src/Common/AdvertiseApiVersionsAttribute.cs | 22 +-- src/Common/ApiVersion.cs | 65 ++++--- src/Common/ApiVersionAttribute.cs | 12 +- src/Common/ApiVersionNeutralAttribute.cs | 2 +- src/Common/CollectionExtensions.cs | 12 +- src/Common/Common.projitems | 54 ++++++ src/Common/Common.shproj | 13 ++ src/Common/ControllerNameAttribute.cs | 2 +- src/Common/MapToApiVersionAttribute.cs | 12 +- src/Common/ReportApiVersionsAttribute.cs | 8 +- src/Common/TypeExtensions.cs | 6 +- .../AmbiguousApiVersionException.cs | 15 +- src/Common/Versioning/ApiVersionModel.cs | 32 ++-- .../Versioning/ApiVersionModelDebugView.cs | 16 +- .../Versioning/ApiVersionModelExtensions.cs | 2 +- src/Common/Versioning/ApiVersionReader.cs | 2 +- src/Common/Versioning/ApiVersioningOptions.cs | 20 +- .../Versioning/ApiVersionsBaseAttribute.cs | 20 +- src/Common/Versioning/AttributeExtensions.cs | 4 +- .../Versioning/ConstantApiVersionSelector.cs | 4 +- ...nApiVersionConventionBuilderCollectionT.cs | 6 +- .../ActionApiVersionConventionBuilderT.cs | 2 +- .../ControllerApiVersionConventionBuilderT.cs | 13 +- .../Conventions/ExpressionExtensions.cs | 10 +- ...CurrentImplementationApiVersionSelector.cs | 4 +- .../Versioning/DefaultApiVersionSelector.cs | 4 +- .../Versioning/HeaderApiVersionReader.cs | 2 +- src/Common/Versioning/IApiVersionNeutral.cs | 3 +- src/Common/Versioning/IApiVersionProvider.cs | 3 +- src/Common/Versioning/IApiVersionReader.cs | 2 +- src/Common/Versioning/IApiVersionSelector.cs | 2 +- .../LowestImplementedApiVersionSelector.cs | 4 +- .../Microsoft.AspNet.OData.Versioning.csproj | 31 ++++ .../Microsoft.AspNet.OData.Versioning.xproj | 19 -- .../OData.Edm/ApiVersionAnnotation.cs | 2 +- .../Properties/AssemblyInfo.cs | 3 - .../HttpConfigurationExtensions.cs | 22 +-- .../TypeExtensions.cs | 4 +- .../Builder/DelegatingModelConfiguration.cs | 6 +- .../Web.OData/Builder/IModelConfiguration.cs | 2 +- .../Builder/VersionedODataModelBuilder.cs | 9 +- .../UnversionedODataPathRouteConstraint.cs | 9 +- .../VersionedAttributeRoutingConvention.cs | 19 +- .../VersionedMetadataRoutingConvention.cs | 2 +- .../VersionedODataPathRouteConstraint.cs | 2 +- .../Routing/VersionedUrlHelperDecorator.cs | 9 +- .../project.json | 38 ---- .../ControllerNameAttribute.cs | 2 +- .../Controllers/ActionSelectionResult.cs | 4 +- .../Controllers/ActionSelectorCacheItem.cs | 76 ++++---- .../Controllers/AggregatedActionMapping.cs | 4 +- .../Controllers/ApiVersionActionSelector.cs | 12 +- .../Controllers/CandidateActionWithParams.cs | 10 +- .../CandidateHttpActionDescriptor.cs | 14 +- .../HttpControllerDescriptorComparer.cs | 13 +- .../HttpControllerDescriptorGroup.cs | 6 +- .../StandardActionSelectionCache.cs | 5 +- .../ApiVersionControllerAggregator.cs | 46 ++--- .../ApiVersionControllerSelector.cs | 17 +- .../Dispatcher/ControllerSelectionResult.cs | 2 +- .../Dispatcher/ControllerSelector.cs | 6 +- .../ConventionRouteControllerSelector.cs | 15 +- .../DirectRouteControllerSelector.cs | 17 +- .../Dispatcher/HttpControllerTypeCache.cs | 24 +-- .../HttpResponseExceptionFactory.cs | 23 +-- .../Microsoft.AspNet.WebApi.Versioning.csproj | 44 +++++ .../Microsoft.AspNet.WebApi.Versioning.xproj | 19 -- .../NullTraceWriter.cs | 12 +- .../Properties/AssemblyInfo.cs | 3 - .../ReportApiVersionsAttribute.cs | 2 +- .../Routing/ApiVersionRouteConstraint.cs | 7 +- .../Routing/CandidateAction.cs | 11 +- .../Routing/RouteDataTokenKeys.cs | 12 +- .../Routing/RouteValueKeys.cs | 8 +- .../SR.Designer.cs | 59 +++--- .../HttpActionDescriptorExtensions.cs | 9 +- .../HttpConfigurationExtensions.cs | 5 +- .../HttpControllerDescriptorExtensions.cs | 29 ++- .../HttpParameterBindingExtensions.cs | 4 +- .../HttpRouteDataExtensions.cs | 4 +- .../System.Web.Http/HttpRouteExtensions.cs | 21 +-- .../Versioning/ApiVersionModel.cs | 6 +- ...nApiVersionConventionBuilderCollectionT.cs | 2 +- .../ApiVersionConventionBuilder.cs | 6 +- .../ControllerApiVersionConventionBuilderT.cs | 9 +- .../Versioning/MediaTypeApiVersionReader.cs | 4 - .../project.json | 38 ---- .../ActionDescriptorExtensions.cs | 6 +- .../CollectionExtensions.cs | 17 +- .../ControllerNameAttribute.cs | 5 +- .../HttpContextExtensions.cs | 4 +- .../MapToApiVersionAttribute.cs | 2 +- ...Microsoft.AspNetCore.Mvc.Versioning.csproj | 45 +++++ .../Microsoft.AspNetCore.Mvc.Versioning.xproj | 19 -- .../Properties/AssemblyInfo.cs | 3 - .../ReportApiVersionsAttribute.cs | 2 +- .../Routing/ApiVersionRouteConstraint.cs | 7 +- .../SR.Designer.cs | 38 ++-- .../TypeExtensions.cs | 5 +- .../Versioning/ActionSelectionContext.cs | 6 +- .../Versioning/ApiVersionActionSelector.cs | 34 ++-- .../Versioning/ApiVersionConvention.cs | 10 +- .../Versioning/BadRequestHandler.cs | 2 +- .../ApiVersionConventionBuilder.cs | 6 +- .../ControllerApiVersionConventionBuilderT.cs | 13 +- .../Versioning/HeaderApiVersionReader.cs | 5 +- .../Versioning/ILoggerExtensions.cs | 16 +- .../Versioning/MediaTypeApiVersionReader.cs | 3 - .../Versioning/MethodNotAllowedHandler.cs | 2 +- .../Versioning/RequestHandler.cs | 2 +- .../project.json | 41 ----- src/Shared/Arg.cs | 2 +- src/Shared/Shared.projitems | 16 ++ src/Shared/Shared.shproj | 13 ++ src/Shared/SharedAssemblyInfo.cs | 10 +- src/Shared/StringExtensions.cs | 7 +- test/.editorconfig | 10 + .../Acceptance.Test.Shared.projitems | 19 ++ .../Acceptance.Test.Shared.shproj | 13 ++ test/Acceptance.Test.Shared/AcceptanceTest.cs | 71 ++++++++ .../HttpContentExtensions.cs | 10 +- .../OneApiError.cs | 6 +- .../OneApiErrorResponse.cs | 8 +- .../OneApiInnerError.cs | 6 +- .../TaskExtensions.cs | 8 +- ...osoft.AspNet.OData.Versioning.Tests.csproj | 26 +++ ...rosoft.AspNet.OData.Versioning.Tests.xproj | 22 --- .../OData.Edm/ApiVersionAnnotationTest.cs | 2 +- .../Properties/AssemblyInfo.cs | 19 -- .../HttpConfigurationExtensionsTest.cs | 10 +- .../Builder/VersionedODataModelBuilderTest.cs | 6 +- .../VersionedMetadataControllerTest.cs | 11 +- ...VersionedAttributeRoutingConventionTest.cs | 10 +- .../VersionedMetadataRoutingConventionTest.cs | 2 +- .../VersionedODataPathRouteConstraintTest.cs | 8 +- .../app.config | 23 ++- .../project.json | 25 --- .../AcceptanceTest.cs | 67 +------ .../FilteredControllerTypes.cs | 11 ++ ... query string and split into two types.cs} | 10 +- .../when using a url segment.cs} | 10 +- .../ByNamespace/ByNamespaceAcceptanceTest.cs | 4 +- .../when using a query string.cs} | 12 +- ...rl segment and attribute-based routing.cs} | 10 +- ...l segment and convention-based routing.cs} | 10 +- ... query string and split into two types.cs} | 10 +- .../when using a url segment.cs} | 10 +- .../when using media type negotiation.cs} | 13 +- .../HttpSimulatorHandler.cs | 13 +- ...soft.AspNet.WebApi.Acceptance.Tests.csproj | 32 ++++ ...osoft.AspNet.WebApi.Acceptance.Tests.xproj | 22 --- .../when orders is v1.cs} | 12 +- .../when orders is v3.cs} | 10 +- .../when orders is v2.cs} | 10 +- .../when people is any version.cs | 29 +++ .../when people is v1.cs | 65 +++++++ .../when people is v2.cs | 72 ++++++++ .../when people is v3.cs | 61 +++++++ ...le_ODataController_split_into_two_types.cs | 172 ------------------ .../OData/Basic/BasicAcceptanceTest.cs | 4 +- ... query string and split into two types.cs} | 16 +- .../when using a query string.cs} | 10 +- ...a url segment and split into two types.cs} | 12 +- .../when using a url segment.cs} | 8 +- .../Configuration/OrderModelConfiguration.cs | 17 +- .../Configuration/PersonModelConfiguration.cs | 8 +- ... query string and split into two types.cs} | 16 +- .../when using a query string.cs} | 10 +- ...a url segment and split into two types.cs} | 12 +- .../when using a url segment.cs} | 8 +- .../OData/ODataAcceptanceTest.cs | 12 +- .../OneApiErrorResponse.cs | 9 - .../OneApiInnerError.cs | 11 -- .../Properties/AssemblyInfo.cs | 19 -- .../TaskExtensions.cs | 16 -- .../app.config | 23 ++- .../project.json | 32 ---- .../ApiVersionAttributeTest.cs | 2 +- .../ApiVersionTest.cs | 2 +- .../ControllerNameAttributeTest.cs | 2 +- .../ApiVersionActionSelectorTest.cs | 6 +- ...rollerSelectorTest.AmbiguousControllers.cs | 12 +- .../ApiVersionControllerSelectorTest.cs | 4 +- ...soft.AspNet.WebApi.Versioning.Tests.csproj | 29 +++ ...osoft.AspNet.WebApi.Versioning.Tests.xproj | 22 --- .../Properties/AssemblyInfo.cs | 19 -- .../ReportApiVersionsAttributeTest.cs | 2 +- .../Simulators/AdminController.cs | 2 +- .../ApiVersionedRoute2Controller.cs | 2 +- .../Simulators/ApiVersionedRouteController.cs | 2 +- .../AttributeRoutedTest2Controller.cs | 2 +- .../AttributeRoutedTest4Controller.cs | 2 +- .../AttributeRoutedTestController.cs | 2 +- .../Simulators/Conventions2Controller.cs | 2 +- .../Simulators/NeutralController.cs | 7 +- .../Simulators/OrdersController.cs | 2 +- .../Simulators/TestController.cs | 7 +- .../Simulators/TestVersion2Controller.cs | 7 +- .../TestVersionNeutralController.cs | 7 +- .../HttpActionDescriptorExtensionsTest.cs | 4 +- .../HttpConfigurationExtensionsTest.cs | 2 +- .../HttpControllerDescriptorExtensionsTest.cs | 2 +- .../HttpRequestMessageExtensionsTest.cs | 2 +- .../ConstantApiVersionSelectorTest.cs | 2 +- ...iVersionConventionBuilderExtensionsTest.cs | 7 +- .../ActionConventionBuilderExtensionsTest.cs | 2 +- .../ApiVersionConventionBuilderTest.cs | 6 +- ...iVersionConventionBuilderExtensionsTest.cs | 2 +- ...trollerApiVersionConventionBuilderTTest.cs | 7 +- ...entImplementationApiVersionSelectorTest.cs | 2 +- .../DefaultApiVersionSelectorTest.cs | 2 +- .../Versioning/HeaderApiVersionReaderTest.cs | 2 +- ...LowestImplementedApiVersionSelectorTest.cs | 2 +- .../QueryStringApiVersionReaderTest.cs | 2 +- .../app.config | 9 +- .../project.json | 29 --- .../AcceptanceTest.cs | 66 +------ .../Basic/Controllers/Values2Controller.cs | 2 +- ... query string and split into two types.cs} | 10 +- .../when using a url segment.cs} | 10 +- .../when using a query string.cs} | 10 +- .../when using a url segment.cs} | 8 +- .../Controllers/Values2Controller.cs | 2 +- ... query string and split into two types.cs} | 10 +- .../when using a url segment.cs} | 10 +- ...Provider.cs => FilteredControllerTypes.cs} | 4 +- .../HttpContentExtensions.cs | 11 -- .../when using media type negotiation.cs} | 12 +- ...oft.AspNetCore.Mvc.Acceptance.Tests.csproj | 37 ++++ ...soft.AspNetCore.Mvc.Acceptance.Tests.xproj | 22 --- .../OneApiError.cs | 13 -- .../Properties/AssemblyInfo.cs | 19 -- .../project.json | 39 ---- .../xunit.runner.json | 5 +- .../ApplicationModels/ModelExtensionsTest.cs | 4 +- .../HttpContextExtensionsTest.cs | 2 +- ...oft.AspNetCore.Mvc.Versioning.Tests.csproj | 35 ++++ ...soft.AspNetCore.Mvc.Versioning.Tests.xproj | 22 --- .../Properties/AssemblyInfo.cs | 19 -- .../ReportApiVersionsAttributeTest.cs | 4 +- .../Simulators/AmbiguousController.cs | 2 +- .../Simulators/AmbiguousNeutralController.cs | 2 +- .../Simulators/AmbiguousToo2Controller.cs | 2 +- .../Simulators/AmbiguousTooController.cs | 2 +- .../ApiVersionedRoute2Controller.cs | 2 +- .../Simulators/ApiVersionedRouteController.cs | 2 +- .../AttributeRoutedAmbiguous2Controller.cs | 2 +- .../AttributeRoutedAmbiguous3Controller.cs | 2 +- .../AttributeRoutedAmbiguousController.cs | 2 +- .../AttributeRoutedTest2Controller.cs | 2 +- .../AttributeRoutedTest4Controller.cs | 2 +- .../AttributeRoutedTestController.cs | 2 +- ...AttributeRoutedVersionNeutralController.cs | 2 +- .../Simulators/ConventionsController.cs | 2 +- .../Simulators/NeutralController.cs | 2 +- .../Simulators/OrdersController.cs | 2 +- .../Simulators/TestVersion2Controller.cs | 2 +- .../ConstantApiVersionSelectorTest.cs | 2 +- .../ApiVersionConventionBuilderTest.cs | 4 +- ...trollerApiVersionConventionBuilderTTest.cs | 6 +- ...entImplementationApiVersionSelectorTest.cs | 2 +- .../DefaultApiVersionSelectorTest.cs | 2 +- .../Versioning/HeaderApiVersionReaderTest.cs | 2 +- ...LowestImplementedApiVersionSelectorTest.cs | 2 +- .../QueryStringApiVersionReaderTest.cs | 2 +- .../TestApiVersionActionSelector.cs | 2 +- .../Versioning/WebServer.cs | 13 +- .../project.json | 39 ---- .../xunit.runner.json | 5 +- test/Test.Common/Test.Common.projitems | 17 ++ test/Test.Common/Test.Common.shproj | 13 ++ .../ApiVersionModelExtensionsTest.cs | 2 +- .../Versioning/MaxSelectVersionData.cs | 2 +- .../Versioning/MinSelectVersionData.cs | 2 +- .../Versioning/SelectVersionData.cs | 2 +- 294 files changed, 1903 insertions(+), 2285 deletions(-) create mode 100644 .editorconfig rename src/Shared/CustomDictionary.xml => CustomDictionary.xml (100%) create mode 100644 build.targets delete mode 100644 global.json delete mode 100644 pack.ps1 create mode 100644 samples/aspnetcore/BasicSample/BasicSample.csproj delete mode 100644 samples/aspnetcore/BasicSample/BasicSample.xproj delete mode 100644 samples/aspnetcore/BasicSample/project.json create mode 100644 samples/aspnetcore/ConventionsSample/ConventionsSample.csproj delete mode 100644 samples/aspnetcore/ConventionsSample/ConventionsSample.xproj delete mode 100644 samples/aspnetcore/ConventionsSample/project.json create mode 100644 src/Common/Common.projitems create mode 100644 src/Common/Common.shproj create mode 100644 src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.csproj delete mode 100644 src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.xproj delete mode 100644 src/Microsoft.AspNet.OData.Versioning/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNet.OData.Versioning/project.json create mode 100644 src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.csproj delete mode 100644 src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.xproj delete mode 100644 src/Microsoft.AspNet.WebApi.Versioning/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNet.WebApi.Versioning/project.json create mode 100644 src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.csproj delete mode 100644 src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.xproj delete mode 100644 src/Microsoft.AspNetCore.Mvc.Versioning/Properties/AssemblyInfo.cs delete mode 100644 src/Microsoft.AspNetCore.Mvc.Versioning/project.json create mode 100644 src/Shared/Shared.projitems create mode 100644 src/Shared/Shared.shproj create mode 100644 test/.editorconfig create mode 100644 test/Acceptance.Test.Shared/Acceptance.Test.Shared.projitems create mode 100644 test/Acceptance.Test.Shared/Acceptance.Test.Shared.shproj create mode 100644 test/Acceptance.Test.Shared/AcceptanceTest.cs rename test/{Microsoft.AspNet.WebApi.Acceptance.Tests => Acceptance.Test.Shared}/HttpContentExtensions.cs (63%) rename test/{Microsoft.AspNet.WebApi.Acceptance.Tests => Acceptance.Test.Shared}/OneApiError.cs (70%) rename test/{Microsoft.AspNetCore.Mvc.Acceptance.Tests => Acceptance.Test.Shared}/OneApiErrorResponse.cs (57%) rename test/{Microsoft.AspNetCore.Mvc.Acceptance.Tests => Acceptance.Test.Shared}/OneApiInnerError.cs (64%) rename test/{Microsoft.AspNetCore.Mvc.Acceptance.Tests => Acceptance.Test.Shared}/TaskExtensions.cs (74%) create mode 100644 test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.csproj delete mode 100644 test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.xproj delete mode 100644 test/Microsoft.AspNet.OData.Versioning.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNet.OData.Versioning.Tests/project.json create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/FilteredControllerTypes.cs rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/{given/a_query_string_versioned_ApiController_split_into_two_types.cs => given a versioned ApiController/when using a query string and split into two types.cs} (82%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/{given/a_url_versioned_ApiController.cs => given a versioned ApiController/when using a url segment.cs} (85%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/{given/a_query_string_versioned_ApiController_per_namespace.cs => given a versioned ApiController per namespace/when using a query string.cs} (80%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/{given/a_url_versioned_and_attribute-routed_ApiController_per_namespace.cs => given a versioned ApiController per namespace/when using a url segment and attribute-based routing.cs} (71%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/{given/a_url_versioned_ApiController_per_namespace.cs => given a versioned ApiController per namespace/when using a url segment and convention-based routing.cs} (77%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/{given/a_query_string_versioned_ApiController_split_into_two_types_using_conventions.cs => given a versioned ApiController using conventions/when using a query string and split into two types.cs} (82%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/{given/a_url_versioned_ApiController_using_conventions.cs => given a versioned ApiController using conventions/when using a url segment.cs} (84%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/{given/an_ApiController_versioned_by_media_type_negotiation.cs => given a versioned ApiController/when using media type negotiation.cs} (84%) create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.csproj delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.xproj rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/{given/a_v1_orders_ApiController_using_convention_routing.cs => given a versioned ApiController mixed with OData controllers/when orders is v1.cs} (80%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/{given/a_v3_orders_ApiController_using_attribute_routing.cs => given a versioned ApiController mixed with OData controllers/when orders is v3.cs} (77%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/{given/a_v2_orders_ODataController.cs => given a versioned ODataController mixed Web API controllers/when orders is v2.cs} (80%) create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is any version.cs create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v1.cs create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v2.cs create mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v3.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_mix-in_people_ODataController_split_into_two_types.cs rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/{given/a_query_string_versioned_ODataController_split_into_two_types.cs => given a versioned ODataController/when using a query string and split into two types.cs} (83%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/{given/a_query_string_versioned_ODataController.cs => given a versioned ODataController/when using a query string.cs} (80%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/{given/a_url_versioned_ODataController_split_into_two_types.cs => given a versioned ODataController/when using a url segment and split into two types.cs} (82%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/{given/a_url_versioned_ODataController.cs => given a versioned ODataController/when using a url segment.cs} (78%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/{given/a_query_string_versioned_ODataController_split_into_two_types_using_conventions.cs => given a versioned ODataController using conventions/when using a query string and split into two types.cs} (83%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/{given/a_query_string_versioned_ODataController_using_conventions.cs => given a versioned ODataController using conventions/when using a query string.cs} (79%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/{given/a_url_versioned_ODataController_split_into_two_types_using_conventions.cs => given a versioned ODataController using conventions/when using a url segment and split into two types.cs} (82%) rename test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/{given/a_url_versioned_ODataController_using_conventions.cs => given a versioned ODataController using conventions/when using a url segment.cs} (77%) delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiErrorResponse.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiInnerError.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/TaskExtensions.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Acceptance.Tests/project.json create mode 100644 test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.csproj delete mode 100644 test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.xproj delete mode 100644 test/Microsoft.AspNet.WebApi.Versioning.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNet.WebApi.Versioning.Tests/project.json rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/{given/a_query_string_versioned_Controller_split_into_two_types.cs => given a versioned Controller/when using a query string and split into two types.cs} (82%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/{given/a_url_versioned_Controller.cs => given a versioned Controller/when using a url segment.cs} (85%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/{given/a_query_string_versioned_Controller_per_namespace.cs => given a versioned Controller per namespace/when using a query string.cs} (83%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/{given/a_url_versioned_Controller_per_namespace.cs => given a versioned Controller per namespace/when using a url segment.cs} (83%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/{given/a_query_string_versioned_Controller_split_into_two_types_using_conventions.cs => given a versioned Controller using conventions/when using a query string and split into two types.cs} (81%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/{given/a_url_versioned_Controller_using_conventions.cs => given a versioned Controller using conventions/when using a url segment.cs} (84%) rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/{FilteredControllerFeatureProvider.cs => FilteredControllerTypes.cs} (83%) delete mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/HttpContentExtensions.cs rename test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/{given/a_Controller_versioned_by_media_type_negotiation.cs => given a versioned Controller/when using media type negotiation.cs} (84%) create mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj delete mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj delete mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiError.cs delete mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/project.json create mode 100644 test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj delete mode 100644 test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj delete mode 100644 test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Properties/AssemblyInfo.cs delete mode 100644 test/Microsoft.AspNetCore.Mvc.Versioning.Tests/project.json create mode 100644 test/Test.Common/Test.Common.projitems create mode 100644 test/Test.Common/Test.Common.shproj rename test/{Common => Test.Common}/Versioning/ApiVersionModelExtensionsTest.cs (99%) rename test/{Common => Test.Common}/Versioning/MaxSelectVersionData.cs (99%) rename test/{Common => Test.Common}/Versioning/MinSelectVersionData.cs (99%) rename test/{Common => Test.Common}/Versioning/SelectVersionData.cs (99%) diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..2792529f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,84 @@ +# EditorConfig is awesome +# * http://EditorConfig.org +# * https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference + +# top-most .editorconfig file +root = true + +# don't use tabs for indentation +[*] +indent_style = space + +# code files +[*.{cs,csx,vb,vbx}] +indent_size = 4 + +# xml project files +[*.{csproj,vbproj,proj,projitems,shproj}] +indent_size = 2 + +# xml config files +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] +indent_size = 2 + +# json files +[*.json] +indent_size = 2 + +# whitespace handling +trim_trailing_whitespace = true +insert_final_newline = false + +# .net code style settings: +[*.{cs,vb}] +dotnet_sort_system_directives_first = false + +# avoid "this." and "me." if not necessary +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion + +# use language keywords instead of framework type names for type references +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion +dotnet_style_predefined_type_for_member_access = true:suggestion + +# suggest more modern language features when available +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion + +# csharp code style settings: +[*.cs] + +# prefer "var" everywhere +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion +csharp_style_var_elsewhere = true:suggestion + +# prefer method-like constructs to have a block body +csharp_style_expression_bodied_methods = false:none +csharp_style_expression_bodied_constructors = false:none +csharp_style_expression_bodied_operators = false:none + +# prefer property-like constructs to have an expression-body +csharp_style_expression_bodied_properties = true:none +csharp_style_expression_bodied_indexers = true:none +csharp_style_expression_bodied_accessors = true:none + +# suggest more modern language features when available +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_conditional_delegate_call = true:suggestion + +# newline settings +csharp_new_line_before_open_brace = all +csharp_new_line_before_else = true +csharp_new_line_before_catch = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = false \ No newline at end of file diff --git a/ApiVersioning.sln b/ApiVersioning.sln index 386b84c2..8752844f 100644 --- a/ApiVersioning.sln +++ b/ApiVersioning.sln @@ -1,110 +1,58 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{2EB04F47-AD85-4169-BA08-9104D9D29332}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0987757E-4D09-4523-B9C9-65B1E8832AA1}" ProjectSection(SolutionItems) = preProject - src\Shared\Arg.cs = src\Shared\Arg.cs - src\Shared\CustomDictionary.xml = src\Shared\CustomDictionary.xml - src\Shared\SharedAssemblyInfo.cs = src\Shared\SharedAssemblyInfo.cs - src\Shared\StringExtensions.cs = src\Shared\StringExtensions.cs + test\.editorconfig = test\.editorconfig EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0987757E-4D09-4523-B9C9-65B1E8832AA1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2957BAF3-9E50-4D82-B732-A34345C4A8F2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{2957BAF3-9E50-4D82-B732-A34345C4A8F2}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore appveyor.yml = appveyor.yml - global.json = global.json + build.targets = build.targets + CustomDictionary.xml = CustomDictionary.xml LICENSE = LICENSE - pack.ps1 = pack.ps1 README.md = README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{261B77B4-647B-4459-9FE8-4EFF910B28D0}" - ProjectSection(SolutionItems) = preProject - src\Common\AdvertiseApiVersionsAttribute.cs = src\Common\AdvertiseApiVersionsAttribute.cs - src\Common\ApiVersion.cs = src\Common\ApiVersion.cs - src\Common\ApiVersionAttribute.cs = src\Common\ApiVersionAttribute.cs - src\Common\ApiVersionNeutralAttribute.cs = src\Common\ApiVersionNeutralAttribute.cs - src\Common\CollectionExtensions.cs = src\Common\CollectionExtensions.cs - src\Common\ControllerNameAttribute.cs = src\Common\ControllerNameAttribute.cs - src\Common\MapToApiVersionAttribute.cs = src\Common\MapToApiVersionAttribute.cs - src\Common\ReportApiVersionsAttribute.cs = src\Common\ReportApiVersionsAttribute.cs - src\Common\TypeExtensions.cs = src\Common\TypeExtensions.cs - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{DE4EE45F-F8EA-4B32-B16F-441F946ACEF4}" - ProjectSection(SolutionItems) = preProject - src\Common\Versioning\AmbiguousApiVersionException.cs = src\Common\Versioning\AmbiguousApiVersionException.cs - src\Common\Versioning\ApiVersioningOptions.cs = src\Common\Versioning\ApiVersioningOptions.cs - src\Common\Versioning\ApiVersionModel.cs = src\Common\Versioning\ApiVersionModel.cs - src\Common\Versioning\ApiVersionModelDebugView.cs = src\Common\Versioning\ApiVersionModelDebugView.cs - src\Common\Versioning\ApiVersionModelExtensions.cs = src\Common\Versioning\ApiVersionModelExtensions.cs - src\Common\Versioning\ApiVersionReader.cs = src\Common\Versioning\ApiVersionReader.cs - src\Common\Versioning\ApiVersionsBaseAttribute.cs = src\Common\Versioning\ApiVersionsBaseAttribute.cs - src\Common\Versioning\AttributeExtensions.cs = src\Common\Versioning\AttributeExtensions.cs - src\Common\Versioning\ConstantApiVersionSelector.cs = src\Common\Versioning\ConstantApiVersionSelector.cs - src\Common\Versioning\CurrentImplementationApiVersionSelector.cs = src\Common\Versioning\CurrentImplementationApiVersionSelector.cs - src\Common\Versioning\DefaultApiVersionSelector.cs = src\Common\Versioning\DefaultApiVersionSelector.cs - src\Common\Versioning\HeaderApiVersionReader.cs = src\Common\Versioning\HeaderApiVersionReader.cs - src\Common\Versioning\IApiVersionNeutral.cs = src\Common\Versioning\IApiVersionNeutral.cs - src\Common\Versioning\IApiVersionProvider.cs = src\Common\Versioning\IApiVersionProvider.cs - src\Common\Versioning\IApiVersionReader.cs = src\Common\Versioning\IApiVersionReader.cs - src\Common\Versioning\IApiVersionSelector.cs = src\Common\Versioning\IApiVersionSelector.cs - src\Common\Versioning\LowestImplementedApiVersionSelector.cs = src\Common\Versioning\LowestImplementedApiVersionSelector.cs - src\Common\Versioning\QueryStringApiVersionReader.cs = src\Common\Versioning\QueryStringApiVersionReader.cs - src\Common\Versioning\QueryStringOrHeaderApiVersionReader.cs = src\Common\Versioning\QueryStringOrHeaderApiVersionReader.cs - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Versioning", "src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj", "{C39CCCBC-6B04-406F-96BE-CA796EFF34C5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{946F164B-5502-4629-AD75-04DD91D1128F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Versioning", "src\Microsoft.AspNet.WebApi.Versioning\Microsoft.AspNet.WebApi.Versioning.csproj", "{3BAC97ED-1A8E-4F5A-A716-DB5255F51C81}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{8D4E3E25-E532-4EF7-A36E-CEEC098C04B1}" - ProjectSection(SolutionItems) = preProject - test\Common\Versioning\ApiVersionModelExtensionsTest.cs = test\Common\Versioning\ApiVersionModelExtensionsTest.cs - test\Common\Versioning\MaxSelectVersionData.cs = test\Common\Versioning\MaxSelectVersionData.cs - test\Common\Versioning\MinSelectVersionData.cs = test\Common\Versioning\MinSelectVersionData.cs - test\Common\Versioning\SelectVersionData.cs = test\Common\Versioning\SelectVersionData.cs - EndProjectSection - ProjectSection(FolderStartupServices) = postProject - {82A7F48D-3B50-4B1E-B82E-3ADA8210C358} = {82A7F48D-3B50-4B1E-B82E-3ADA8210C358} - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.OData.Versioning", "src\Microsoft.AspNet.OData.Versioning\Microsoft.AspNet.OData.Versioning.csproj", "{48A2B488-23AB-4C83-AE30-0B8B735C4562}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Versioning", "src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.xproj", "{C39CCCBC-6B04-406F-96BE-CA796EFF34C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Versioning.Tests", "test\Microsoft.AspNetCore.Mvc.Versioning.Tests\Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj", "{69C59656-53D1-4ACB-92B5-8B34C8E62175}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Versioning", "src\Microsoft.AspNet.WebApi.Versioning\Microsoft.AspNet.WebApi.Versioning.xproj", "{3BAC97ED-1A8E-4F5A-A716-DB5255F51C81}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Versioning.Tests", "test\Microsoft.AspNet.WebApi.Versioning.Tests\Microsoft.AspNet.WebApi.Versioning.Tests.csproj", "{AEB074E1-E57A-4DD3-A972-3625B367CE5D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.OData.Versioning", "src\Microsoft.AspNet.OData.Versioning\Microsoft.AspNet.OData.Versioning.xproj", "{48A2B488-23AB-4C83-AE30-0B8B735C4562}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.OData.Versioning.Tests", "test\Microsoft.AspNet.OData.Versioning.Tests\Microsoft.AspNet.OData.Versioning.Tests.csproj", "{D87E54CC-C2D6-4AE5-806D-AE825B051C66}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Versioning.Tests", "test\Microsoft.AspNetCore.Mvc.Versioning.Tests\Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj", "{69C59656-53D1-4ACB-92B5-8B34C8E62175}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Acceptance.Tests", "test\Microsoft.AspNet.WebApi.Acceptance.Tests\Microsoft.AspNet.WebApi.Acceptance.Tests.csproj", "{5C31964D-EA8B-420B-9297-5ADFEFE54962}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Versioning.Tests", "test\Microsoft.AspNet.WebApi.Versioning.Tests\Microsoft.AspNet.WebApi.Versioning.Tests.xproj", "{AEB074E1-E57A-4DD3-A972-3625B367CE5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Acceptance.Tests", "test\Microsoft.AspNetCore.Mvc.Acceptance.Tests\Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj", "{4EED304C-D1A6-4866-8D7F-450D084FD25D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.OData.Versioning.Tests", "test\Microsoft.AspNet.OData.Versioning.Tests\Microsoft.AspNet.OData.Versioning.Tests.xproj", "{D87E54CC-C2D6-4AE5-806D-AE825B051C66}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Shared", "src\Shared\Shared.shproj", "{B7897873-6757-4684-83C0-39575821AE14}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Conventions", "Conventions", "{B24995FB-AF48-4E5D-9327-377A599BDE2A}" - ProjectSection(SolutionItems) = preProject - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderCollectionT.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderCollectionT.cs - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderT.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderT.cs - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ActionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ActionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderT.cs = src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderT.cs - src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ExpressionExtensions.cs = src\Common\Versioning\Conventions\ExpressionExtensions.cs - src\Common\Versioning\Conventions\IActionConventionBuilderT.cs = src\Common\Versioning\Conventions\IActionConventionBuilderT.cs - src\Common\Versioning\Conventions\IApiVersionConventionT.cs = src\Common\Versioning\Conventions\IApiVersionConventionT.cs - EndProjectSection +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Common", "src\Common\Common.shproj", "{6D0E834B-6422-44CD-9A85-E3BE9DEAD1BE}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Acceptance.Tests", "test\Microsoft.AspNet.WebApi.Acceptance.Tests\Microsoft.AspNet.WebApi.Acceptance.Tests.xproj", "{5C31964D-EA8B-420B-9297-5ADFEFE54962}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Test.Common", "test\Test.Common\Test.Common.shproj", "{F9297626-C37C-402B-AFD6-712F3E5E4D7C}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Acceptance.Tests", "test\Microsoft.AspNetCore.Mvc.Acceptance.Tests\Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj", "{4EED304C-D1A6-4866-8D7F-450D084FD25D}" +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Acceptance.Test.Shared", "test\Acceptance.Test.Shared\Acceptance.Test.Shared.shproj", "{6CDFB878-2642-4F98-AE35-621BAC581181}" EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + test\Acceptance.Test.Shared\Acceptance.Test.Shared.projitems*{6cdfb878-2642-4f98-ae35-621bac581181}*SharedItemsImports = 13 + src\Common\Common.projitems*{6d0e834b-6422-44cd-9a85-e3be9dead1be}*SharedItemsImports = 13 + src\Shared\Shared.projitems*{b7897873-6757-4684-83c0-39575821ae14}*SharedItemsImports = 13 + test\Test.Common\Test.Common.projitems*{f9297626-c37c-402b-afd6-712f3e5e4d7c}*SharedItemsImports = 13 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -147,19 +95,17 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {2EB04F47-AD85-4169-BA08-9104D9D29332} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} - {261B77B4-647B-4459-9FE8-4EFF910B28D0} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} - {DE4EE45F-F8EA-4B32-B16F-441F946ACEF4} = {261B77B4-647B-4459-9FE8-4EFF910B28D0} - {946F164B-5502-4629-AD75-04DD91D1128F} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} - {8D4E3E25-E532-4EF7-A36E-CEEC098C04B1} = {946F164B-5502-4629-AD75-04DD91D1128F} {C39CCCBC-6B04-406F-96BE-CA796EFF34C5} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} {3BAC97ED-1A8E-4F5A-A716-DB5255F51C81} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} {48A2B488-23AB-4C83-AE30-0B8B735C4562} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} {69C59656-53D1-4ACB-92B5-8B34C8E62175} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} {AEB074E1-E57A-4DD3-A972-3625B367CE5D} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} {D87E54CC-C2D6-4AE5-806D-AE825B051C66} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} - {B24995FB-AF48-4E5D-9327-377A599BDE2A} = {DE4EE45F-F8EA-4B32-B16F-441F946ACEF4} {5C31964D-EA8B-420B-9297-5ADFEFE54962} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} {4EED304C-D1A6-4866-8D7F-450D084FD25D} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} + {B7897873-6757-4684-83C0-39575821AE14} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} + {6D0E834B-6422-44CD-9A85-E3BE9DEAD1BE} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} + {F9297626-C37C-402B-AFD6-712F3E5E4D7C} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} + {6CDFB878-2642-4F98-AE35-621BAC581181} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} EndGlobalSection EndGlobal diff --git a/ApiVersioningWithSamples.sln b/ApiVersioningWithSamples.sln index 5d45f147..2e129e63 100644 --- a/ApiVersioningWithSamples.sln +++ b/ApiVersioningWithSamples.sln @@ -1,88 +1,34 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{2EB04F47-AD85-4169-BA08-9104D9D29332}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0987757E-4D09-4523-B9C9-65B1E8832AA1}" ProjectSection(SolutionItems) = preProject - src\Shared\Arg.cs = src\Shared\Arg.cs - src\Shared\CustomDictionary.xml = src\Shared\CustomDictionary.xml - src\Shared\SharedAssemblyInfo.cs = src\Shared\SharedAssemblyInfo.cs - src\Shared\StringExtensions.cs = src\Shared\StringExtensions.cs + test\.editorconfig = test\.editorconfig EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{0987757E-4D09-4523-B9C9-65B1E8832AA1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2957BAF3-9E50-4D82-B732-A34345C4A8F2}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "misc", "misc", "{2957BAF3-9E50-4D82-B732-A34345C4A8F2}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore + appveyor.yml = appveyor.yml + build.targets = build.targets + CustomDictionary.xml = CustomDictionary.xml LICENSE = LICENSE - pack.ps1 = pack.ps1 README.md = README.md EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{261B77B4-647B-4459-9FE8-4EFF910B28D0}" - ProjectSection(SolutionItems) = preProject - src\Common\AdvertiseApiVersionsAttribute.cs = src\Common\AdvertiseApiVersionsAttribute.cs - src\Common\ApiVersion.cs = src\Common\ApiVersion.cs - src\Common\ApiVersionAttribute.cs = src\Common\ApiVersionAttribute.cs - src\Common\ApiVersionNeutralAttribute.cs = src\Common\ApiVersionNeutralAttribute.cs - src\Common\CollectionExtensions.cs = src\Common\CollectionExtensions.cs - src\Common\ControllerNameAttribute.cs = src\Common\ControllerNameAttribute.cs - src\Common\MapToApiVersionAttribute.cs = src\Common\MapToApiVersionAttribute.cs - src\Common\ReportApiVersionsAttribute.cs = src\Common\ReportApiVersionsAttribute.cs - src\Common\TypeExtensions.cs = src\Common\TypeExtensions.cs - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{DE4EE45F-F8EA-4B32-B16F-441F946ACEF4}" - ProjectSection(SolutionItems) = preProject - src\Common\Versioning\ApiVersioningOptions.cs = src\Common\Versioning\ApiVersioningOptions.cs - src\Common\Versioning\ApiVersionModel.cs = src\Common\Versioning\ApiVersionModel.cs - src\Common\Versioning\ApiVersionModelDebugView.cs = src\Common\Versioning\ApiVersionModelDebugView.cs - src\Common\Versioning\ApiVersionModelExtensions.cs = src\Common\Versioning\ApiVersionModelExtensions.cs - src\Common\Versioning\ApiVersionReader.cs = src\Common\Versioning\ApiVersionReader.cs - src\Common\Versioning\ApiVersionRequestProperties.cs = src\Common\Versioning\ApiVersionRequestProperties.cs - src\Common\Versioning\ApiVersionsBaseAttribute.cs = src\Common\Versioning\ApiVersionsBaseAttribute.cs - src\Common\Versioning\AttributeExtensions.cs = src\Common\Versioning\AttributeExtensions.cs - src\Common\Versioning\ConstantApiVersionSelector.cs = src\Common\Versioning\ConstantApiVersionSelector.cs - src\Common\Versioning\CurrentImplementationApiVersionSelector.cs = src\Common\Versioning\CurrentImplementationApiVersionSelector.cs - src\Common\Versioning\DefaultApiVersionSelector.cs = src\Common\Versioning\DefaultApiVersionSelector.cs - src\Common\Versioning\ErrorResponseContext.cs = src\Common\Versioning\ErrorResponseContext.cs - src\Common\Versioning\HeaderApiVersionReader.cs = src\Common\Versioning\HeaderApiVersionReader.cs - src\Common\Versioning\IApiVersionNeutral.cs = src\Common\Versioning\IApiVersionNeutral.cs - src\Common\Versioning\IApiVersionProvider.cs = src\Common\Versioning\IApiVersionProvider.cs - src\Common\Versioning\IApiVersionReader.cs = src\Common\Versioning\IApiVersionReader.cs - src\Common\Versioning\IApiVersionSelector.cs = src\Common\Versioning\IApiVersionSelector.cs - src\Common\Versioning\IErrorResponseProvider.cs = src\Common\Versioning\IErrorResponseProvider.cs - src\Common\Versioning\LowestImplementedApiVersionSelector.cs = src\Common\Versioning\LowestImplementedApiVersionSelector.cs - src\Common\Versioning\MediaTypeApiVersionReader.cs = src\Common\Versioning\MediaTypeApiVersionReader.cs - src\Common\Versioning\QueryStringApiVersionReader.cs = src\Common\Versioning\QueryStringApiVersionReader.cs - src\Common\Versioning\UrlSegmentApiVersionReader.cs = src\Common\Versioning\UrlSegmentApiVersionReader.cs - EndProjectSection -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{915BB224-B1D0-4E27-A348-67FCC77AAA44}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "webapi", "webapi", "{F446ED94-368F-4F67-913B-16E82CA80DFC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "aspnetcore", "aspnetcore", "{900DD210-8500-4D89-A05D-C9526935A719}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "BasicSample", "samples\aspnetcore\BasicSample\BasicSample.xproj", "{59389B47-8280-411E-B840-D097AA1DCDEE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{946F164B-5502-4629-AD75-04DD91D1128F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Versioning", "Versioning", "{8D4E3E25-E532-4EF7-A36E-CEEC098C04B1}" - ProjectSection(SolutionItems) = preProject - test\Common\Versioning\ApiVersionModelExtensionsTest.cs = test\Common\Versioning\ApiVersionModelExtensionsTest.cs - test\Common\Versioning\MaxSelectVersionData.cs = test\Common\Versioning\MaxSelectVersionData.cs - test\Common\Versioning\MinSelectVersionData.cs = test\Common\Versioning\MinSelectVersionData.cs - test\Common\Versioning\SelectVersionData.cs = test\Common\Versioning\SelectVersionData.cs - EndProjectSection - ProjectSection(FolderStartupServices) = postProject - {82A7F48D-3B50-4B1E-B82E-3ADA8210C358} = {82A7F48D-3B50-4B1E-B82E-3ADA8210C358} - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BasicSample", "samples\aspnetcore\BasicSample\BasicSample.csproj", "{59389B47-8280-411E-B840-D097AA1DCDEE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicWebApiSample", "samples\webapi\BasicWebApiSample\BasicWebApiSample.csproj", "{D1DF9ECC-7D2F-4982-8E45-BD690EF80906}" ProjectSection(ProjectDependencies) = postProject @@ -94,17 +40,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicODataWebApiSample", "s {48A2B488-23AB-4C83-AE30-0B8B735C4562} = {48A2B488-23AB-4C83-AE30-0B8B735C4562} EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Versioning", "src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.xproj", "{C39CCCBC-6B04-406F-96BE-CA796EFF34C5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Versioning", "src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj", "{C39CCCBC-6B04-406F-96BE-CA796EFF34C5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Versioning", "src\Microsoft.AspNet.WebApi.Versioning\Microsoft.AspNet.WebApi.Versioning.xproj", "{3BAC97ED-1A8E-4F5A-A716-DB5255F51C81}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Versioning", "src\Microsoft.AspNet.WebApi.Versioning\Microsoft.AspNet.WebApi.Versioning.csproj", "{3BAC97ED-1A8E-4F5A-A716-DB5255F51C81}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.OData.Versioning", "src\Microsoft.AspNet.OData.Versioning\Microsoft.AspNet.OData.Versioning.xproj", "{48A2B488-23AB-4C83-AE30-0B8B735C4562}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.OData.Versioning", "src\Microsoft.AspNet.OData.Versioning\Microsoft.AspNet.OData.Versioning.csproj", "{48A2B488-23AB-4C83-AE30-0B8B735C4562}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Versioning.Tests", "test\Microsoft.AspNetCore.Mvc.Versioning.Tests\Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj", "{69C59656-53D1-4ACB-92B5-8B34C8E62175}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Versioning.Tests", "test\Microsoft.AspNetCore.Mvc.Versioning.Tests\Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj", "{69C59656-53D1-4ACB-92B5-8B34C8E62175}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Versioning.Tests", "test\Microsoft.AspNet.WebApi.Versioning.Tests\Microsoft.AspNet.WebApi.Versioning.Tests.xproj", "{AEB074E1-E57A-4DD3-A972-3625B367CE5D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Versioning.Tests", "test\Microsoft.AspNet.WebApi.Versioning.Tests\Microsoft.AspNet.WebApi.Versioning.Tests.csproj", "{AEB074E1-E57A-4DD3-A972-3625B367CE5D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.OData.Versioning.Tests", "test\Microsoft.AspNet.OData.Versioning.Tests\Microsoft.AspNet.OData.Versioning.Tests.xproj", "{D87E54CC-C2D6-4AE5-806D-AE825B051C66}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.OData.Versioning.Tests", "test\Microsoft.AspNet.OData.Versioning.Tests\Microsoft.AspNet.OData.Versioning.Tests.csproj", "{D87E54CC-C2D6-4AE5-806D-AE825B051C66}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedODataWebApiSample", "samples\webapi\AdvancedODataWebApiSample\AdvancedODataWebApiSample.csproj", "{E496EED0-F8C9-4FE9-83E6-75E47A3C41A1}" EndProject @@ -114,26 +60,27 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConventionsWebApiSample", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConventionsODataWebApiSample", "samples\webapi\ConventionsODataWebApiSample\ConventionsODataWebApiSample.csproj", "{9A22600C-7768-4D16-B67D-514F55942FAF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ConventionsSample", "samples\aspnetcore\ConventionsSample\ConventionsSample.xproj", "{1EFC221F-35CF-4B55-BD59-240D5B808E14}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConventionsSample", "samples\aspnetcore\ConventionsSample\ConventionsSample.csproj", "{1EFC221F-35CF-4B55-BD59-240D5B808E14}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.WebApi.Acceptance.Tests", "test\Microsoft.AspNet.WebApi.Acceptance.Tests\Microsoft.AspNet.WebApi.Acceptance.Tests.xproj", "{5C31964D-EA8B-420B-9297-5ADFEFE54962}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNet.WebApi.Acceptance.Tests", "test\Microsoft.AspNet.WebApi.Acceptance.Tests\Microsoft.AspNet.WebApi.Acceptance.Tests.csproj", "{5C31964D-EA8B-420B-9297-5ADFEFE54962}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Mvc.Acceptance.Tests", "test\Microsoft.AspNetCore.Mvc.Acceptance.Tests\Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj", "{4EED304C-D1A6-4866-8D7F-450D084FD25D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Mvc.Acceptance.Tests", "test\Microsoft.AspNetCore.Mvc.Acceptance.Tests\Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj", "{4EED304C-D1A6-4866-8D7F-450D084FD25D}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Conventions", "Conventions", "{2ABB1DE5-8E77-440D-9517-4A5E6877D1C5}" - ProjectSection(SolutionItems) = preProject - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderCollectionT.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderCollectionT.cs - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderT.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderT.cs - src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ActionApiVersionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ActionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ActionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderT.cs = src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderT.cs - src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderTExtensions.cs = src\Common\Versioning\Conventions\ControllerApiVersionConventionBuilderTExtensions.cs - src\Common\Versioning\Conventions\ExpressionExtensions.cs = src\Common\Versioning\Conventions\ExpressionExtensions.cs - src\Common\Versioning\Conventions\IActionConventionBuilderT.cs = src\Common\Versioning\Conventions\IActionConventionBuilderT.cs - src\Common\Versioning\Conventions\IApiVersionConventionT.cs = src\Common\Versioning\Conventions\IApiVersionConventionT.cs - EndProjectSection +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Shared", "src\Shared\Shared.shproj", "{B7897873-6757-4684-83C0-39575821AE14}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Common", "src\Common\Common.shproj", "{6D0E834B-6422-44CD-9A85-E3BE9DEAD1BE}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Test.Common", "test\Test.Common\Test.Common.shproj", "{F9297626-C37C-402B-AFD6-712F3E5E4D7C}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Acceptance.Test.Shared", "test\Acceptance.Test.Shared\Acceptance.Test.Shared.shproj", "{6CDFB878-2642-4F98-AE35-621BAC581181}" EndProject Global + GlobalSection(SharedMSBuildProjectFiles) = preSolution + test\Acceptance.Test.Shared\Acceptance.Test.Shared.projitems*{6cdfb878-2642-4f98-ae35-621bac581181}*SharedItemsImports = 13 + src\Common\Common.projitems*{6d0e834b-6422-44cd-9a85-e3be9dead1be}*SharedItemsImports = 13 + src\Shared\Shared.projitems*{b7897873-6757-4684-83c0-39575821ae14}*SharedItemsImports = 13 + test\Test.Common\Test.Common.projitems*{f9297626-c37c-402b-afd6-712f3e5e4d7c}*SharedItemsImports = 13 + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -208,14 +155,9 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {2EB04F47-AD85-4169-BA08-9104D9D29332} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} - {261B77B4-647B-4459-9FE8-4EFF910B28D0} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} - {DE4EE45F-F8EA-4B32-B16F-441F946ACEF4} = {261B77B4-647B-4459-9FE8-4EFF910B28D0} {F446ED94-368F-4F67-913B-16E82CA80DFC} = {915BB224-B1D0-4E27-A348-67FCC77AAA44} {900DD210-8500-4D89-A05D-C9526935A719} = {915BB224-B1D0-4E27-A348-67FCC77AAA44} {59389B47-8280-411E-B840-D097AA1DCDEE} = {900DD210-8500-4D89-A05D-C9526935A719} - {946F164B-5502-4629-AD75-04DD91D1128F} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} - {8D4E3E25-E532-4EF7-A36E-CEEC098C04B1} = {946F164B-5502-4629-AD75-04DD91D1128F} {D1DF9ECC-7D2F-4982-8E45-BD690EF80906} = {F446ED94-368F-4F67-913B-16E82CA80DFC} {8C09CD67-5153-413C-B870-2FC7488C2D53} = {F446ED94-368F-4F67-913B-16E82CA80DFC} {C39CCCBC-6B04-406F-96BE-CA796EFF34C5} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} @@ -231,6 +173,9 @@ Global {1EFC221F-35CF-4B55-BD59-240D5B808E14} = {900DD210-8500-4D89-A05D-C9526935A719} {5C31964D-EA8B-420B-9297-5ADFEFE54962} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} {4EED304C-D1A6-4866-8D7F-450D084FD25D} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} - {2ABB1DE5-8E77-440D-9517-4A5E6877D1C5} = {DE4EE45F-F8EA-4B32-B16F-441F946ACEF4} + {B7897873-6757-4684-83C0-39575821AE14} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} + {6D0E834B-6422-44CD-9A85-E3BE9DEAD1BE} = {4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF} + {F9297626-C37C-402B-AFD6-712F3E5E4D7C} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} + {6CDFB878-2642-4F98-AE35-621BAC581181} = {0987757E-4D09-4523-B9C9-65B1E8832AA1} EndGlobalSection EndGlobal diff --git a/src/Shared/CustomDictionary.xml b/CustomDictionary.xml similarity index 100% rename from src/Shared/CustomDictionary.xml rename to CustomDictionary.xml diff --git a/build.targets b/build.targets new file mode 100644 index 00000000..cb3363fb --- /dev/null +++ b/build.targets @@ -0,0 +1,47 @@ + + + + + Microsoft Corporation + $(Company) + Copyright © 2016. Microsoft Corporation. All rights reserved. + git + https://github.com/Microsoft/aspnet-api-versioning + http://go.microsoft.com/fwlink/?LinkID=288890 + https://github.com/Microsoft/aspnet-api-versioning/wiki + https://raw.githubusercontent.com/Microsoft/aspnet-api-versioning/master/LICENSE + true + true + true + true + 2.5 + en + true + true + $(MSBuildThisFileDirectory)\tools\key.snk + AllRules.ruleset + true + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml + $(MSBuildThisFileDirectory)\bin + + + + True + + + + $(AssemblyVersion.Split(`.`)[0]).$(AssemblyVersion.Split(`.`)[1]) + $([System.DateTime]::Now.IsDaylightSavingTime()) + $([System.DateTime]::Today.Subtract($([System.DateTime]::Parse("1/1/2000"))).ToString("%d")) + $([System.Convert]::ToInt32($([MSBuild]::Divide($([System.DateTime]::Now.TimeOfDay.Subtract($([System.TimeSpan]::FromHours(1.0))).TotalSeconds),2)))) + $([System.Convert]::ToInt32($([MSBuild]::Divide($([System.DateTime]::Now.TimeOfDay.TotalSeconds),2)))) + $(MajorAndMinorVersion).$(FileBuildNumber).$(FileBuildRevision) + + + + + CustomDictionary.xml + + + + \ No newline at end of file diff --git a/global.json b/global.json deleted file mode 100644 index 2e848ecb..00000000 --- a/global.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "projects": [ "src", "test" ], - "sdk": { "version": "1.0.0-preview2-003121" } -} \ No newline at end of file diff --git a/pack.ps1 b/pack.ps1 deleted file mode 100644 index 4d5b2122..00000000 --- a/pack.ps1 +++ /dev/null @@ -1,22 +0,0 @@ -param( -[String] $Configuration = "Release", -[String] $VersionStatus = "" -) - -Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent) - -if ( !(Test-Path NuGet) ) { - New-Item NuGet -ItemType Directory -} else { - Get-ChildItem NuGet -Filter *.nupkg | Remove-Item -Force -} - -$VersionSuffix = "" - -if ( ![String]::IsNullOrEmpty($VersionStatus)) { - $VersionSuffix = "--version-suffix" -} - -dotnet pack src\Microsoft.AspNetCore.Mvc.Versioning --configuration $Configuration --output NuGet $VersionSuffix $VersionStatus -dotnet pack src\Microsoft.AspNet.WebApi.Versioning --configuration $Configuration --output NuGet $VersionSuffix $VersionStatus -dotnet pack src\Microsoft.AspNet.OData.Versioning --configuration $Configuration --output NuGet $VersionSuffix $VersionStatus \ No newline at end of file diff --git a/samples/aspnetcore/BasicSample/BasicSample.csproj b/samples/aspnetcore/BasicSample/BasicSample.csproj new file mode 100644 index 00000000..032163b1 --- /dev/null +++ b/samples/aspnetcore/BasicSample/BasicSample.csproj @@ -0,0 +1,37 @@ + + + + netcoreapp1.0 + true + BasicSample + Exe + BasicSample + 1.0.3 + $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/aspnetcore/BasicSample/BasicSample.xproj b/samples/aspnetcore/BasicSample/BasicSample.xproj deleted file mode 100644 index 09278889..00000000 --- a/samples/aspnetcore/BasicSample/BasicSample.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 59389b47-8280-411e-b840-d097aa1dcdee - Microsoft.Examples - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - \ No newline at end of file diff --git a/samples/aspnetcore/BasicSample/project.json b/samples/aspnetcore/BasicSample/project.json deleted file mode 100644 index 6639a882..00000000 --- a/samples/aspnetcore/BasicSample/project.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - "Microsoft.AspNetCore.Mvc": "1.1.1", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", - "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", - "Microsoft.Extensions.Configuration.Json": "1.0.0", - "Microsoft.Extensions.Logging": "1.0.0", - "Microsoft.Extensions.Logging.Console": "1.0.0", - "Microsoft.Extensions.Logging.Debug": "1.0.0", - "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", - "Microsoft.AspNetCore.Mvc.Versioning": { - "target": "project", - "version": "" - }, - "Microsoft.AspNetCore.Diagnostics": "1.0.0" - }, - - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - - "publishOptions": { - "include": [ - "wwwroot", - "Views", - "Areas/**/Views", - "appsettings.json", - "web.config" - ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] - } -} diff --git a/samples/aspnetcore/ConventionsSample/ConventionsSample.csproj b/samples/aspnetcore/ConventionsSample/ConventionsSample.csproj new file mode 100644 index 00000000..bc26ae00 --- /dev/null +++ b/samples/aspnetcore/ConventionsSample/ConventionsSample.csproj @@ -0,0 +1,36 @@ + + + + netcoreapp1.0 + true + ConventionsSample + Exe + ConventionsSample + 1.0.3 + $(PackageTargetFallback);dotnet5.6;portable-net45+win8 + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/aspnetcore/ConventionsSample/ConventionsSample.xproj b/samples/aspnetcore/ConventionsSample/ConventionsSample.xproj deleted file mode 100644 index d16ee8d8..00000000 --- a/samples/aspnetcore/ConventionsSample/ConventionsSample.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 1efc221f-35cf-4b55-bd59-240d5b808e14 - Microsoft.Examples - .\obj - .\bin\ - v4.6.1 - - - 2.0 - - - \ No newline at end of file diff --git a/samples/aspnetcore/ConventionsSample/project.json b/samples/aspnetcore/ConventionsSample/project.json deleted file mode 100644 index 5e2ffa7a..00000000 --- a/samples/aspnetcore/ConventionsSample/project.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0", - "type": "platform" - }, - "Microsoft.AspNetCore.Mvc": "1.1.1", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", - "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", - "Microsoft.Extensions.Configuration.Json": "1.0.0", - "Microsoft.Extensions.Logging": "1.0.0", - "Microsoft.Extensions.Logging.Console": "1.0.0", - "Microsoft.Extensions.Logging.Debug": "1.0.0", - "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", - "Microsoft.AspNetCore.Mvc.Versioning": { - "target": "project", - "version": "" - } - }, - - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dotnet5.6", - "portable-net45+win8" - ] - } - }, - - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - - "runtimeOptions": { - "configProperties": { - "System.GC.Server": true - } - }, - - "publishOptions": { - "include": [ - "wwwroot", - "Views", - "Areas/**/Views", - "appsettings.json", - "web.config" - ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] - } -} \ No newline at end of file diff --git a/samples/webapi/AdvancedODataWebApiSample/AdvancedODataWebApiSample.csproj b/samples/webapi/AdvancedODataWebApiSample/AdvancedODataWebApiSample.csproj index fb777289..7e644568 100644 --- a/samples/webapi/AdvancedODataWebApiSample/AdvancedODataWebApiSample.csproj +++ b/samples/webapi/AdvancedODataWebApiSample/AdvancedODataWebApiSample.csproj @@ -141,6 +141,16 @@ + + + {48a2b488-23ab-4c83-ae30-0b8b735c4562} + Microsoft.AspNet.OData.Versioning + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/samples/webapi/BasicODataWebApiSample/BasicODataWebApiSample.csproj b/samples/webapi/BasicODataWebApiSample/BasicODataWebApiSample.csproj index 9e337317..675e6e3d 100644 --- a/samples/webapi/BasicODataWebApiSample/BasicODataWebApiSample.csproj +++ b/samples/webapi/BasicODataWebApiSample/BasicODataWebApiSample.csproj @@ -112,12 +112,6 @@ - - WebApi - - - WebApi.OData - @@ -142,6 +136,16 @@ + + + {48a2b488-23ab-4c83-ae30-0b8b735c4562} + Microsoft.AspNet.OData.Versioning + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) @@ -153,7 +157,7 @@ - True + False True 4129 / diff --git a/samples/webapi/BasicWebApiSample/BasicWebApiSample.csproj b/samples/webapi/BasicWebApiSample/BasicWebApiSample.csproj index 9bca0dd8..f929af2a 100644 --- a/samples/webapi/BasicWebApiSample/BasicWebApiSample.csproj +++ b/samples/webapi/BasicWebApiSample/BasicWebApiSample.csproj @@ -95,9 +95,6 @@ - - WebApi - @@ -118,6 +115,12 @@ + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/samples/webapi/ByNamespaceWebApiSample/ByNamespaceWebApiSample.csproj b/samples/webapi/ByNamespaceWebApiSample/ByNamespaceWebApiSample.csproj index 92733dab..bc6932d9 100644 --- a/samples/webapi/ByNamespaceWebApiSample/ByNamespaceWebApiSample.csproj +++ b/samples/webapi/ByNamespaceWebApiSample/ByNamespaceWebApiSample.csproj @@ -93,9 +93,6 @@ - - WebApi - @@ -119,7 +116,12 @@ - + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/samples/webapi/ConventionsODataWebApiSample/ConventionsODataWebApiSample.csproj b/samples/webapi/ConventionsODataWebApiSample/ConventionsODataWebApiSample.csproj index 204aff12..dce94d47 100644 --- a/samples/webapi/ConventionsODataWebApiSample/ConventionsODataWebApiSample.csproj +++ b/samples/webapi/ConventionsODataWebApiSample/ConventionsODataWebApiSample.csproj @@ -109,12 +109,6 @@ - - WebApi - - - WebApi.OData - @@ -139,6 +133,16 @@ + + + {48a2b488-23ab-4c83-ae30-0b8b735c4562} + Microsoft.AspNet.OData.Versioning + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/samples/webapi/ConventionsWebApiSample/ConventionsWebApiSample.csproj b/samples/webapi/ConventionsWebApiSample/ConventionsWebApiSample.csproj index 9b53c211..cad046aa 100644 --- a/samples/webapi/ConventionsWebApiSample/ConventionsWebApiSample.csproj +++ b/samples/webapi/ConventionsWebApiSample/ConventionsWebApiSample.csproj @@ -93,9 +93,6 @@ - - WebApi - @@ -116,6 +113,12 @@ + + + {3bac97ed-1a8e-4f5a-a716-db5255f51c81} + Microsoft.AspNet.WebApi.Versioning + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Common/AdvertiseApiVersionsAttribute.cs b/src/Common/AdvertiseApiVersionsAttribute.cs index c88ad159..568a7289 100644 --- a/src/Common/AdvertiseApiVersionsAttribute.cs +++ b/src/Common/AdvertiseApiVersionsAttribute.cs @@ -23,38 +23,26 @@ public partial class AdvertiseApiVersionsAttribute : ApiVersionsBaseAttribute, I /// Initializes a new instance of the class. /// /// The API version. - protected AdvertiseApiVersionsAttribute( ApiVersion version ) - : base( version ) - { - } + protected AdvertiseApiVersionsAttribute( ApiVersion version ) : base( version ) { } /// /// Initializes a new instance of the class. /// /// An array of API versions. - protected AdvertiseApiVersionsAttribute( params ApiVersion[] versions ) - : base( versions ) - { - } + protected AdvertiseApiVersionsAttribute( params ApiVersion[] versions ) : base( versions ) { } /// /// Initializes a new instance of the class. /// /// The API version string. - public AdvertiseApiVersionsAttribute( string version ) - : base( version ) - { - } + public AdvertiseApiVersionsAttribute( string version ) : base( version ) { } /// /// Initializes a new instance of the class. /// /// An array of API version strings. [CLSCompliant( false )] - public AdvertiseApiVersionsAttribute( params string[] versions ) - : base( versions ) - { - } + public AdvertiseApiVersionsAttribute( params string[] versions ) : base( versions ) { } bool IApiVersionProvider.AdvertiseOnly => true; @@ -76,4 +64,4 @@ public override int GetHashCode() return hashCode; } } -} +} \ No newline at end of file diff --git a/src/Common/ApiVersion.cs b/src/Common/ApiVersion.cs index c92528f8..c4776d4f 100644 --- a/src/Common/ApiVersion.cs +++ b/src/Common/ApiVersion.cs @@ -9,25 +9,27 @@ namespace Microsoft.AspNetCore.Mvc using System.Diagnostics.Contracts; using System.Globalization; using System.Text; - using System.Text.RegularExpressions; + using static System.DateTime; + using static System.Globalization.CultureInfo; + using static System.String; + using static System.Text.RegularExpressions.Regex; + using static System.Text.RegularExpressions.RegexOptions; /// /// Represents the application programming interface (API) version of a service. /// public class ApiVersion : IEquatable, IComparable, IFormattable { - private const string ParsePattern = @"^(\d{4}-\d{2}-\d{2})?\.?(\d{0,9})\.?(\d{0,9})\.?-?(.*)$"; - private const string GroupVersionFormat = "yyyy-MM-dd"; - private static Lazy defaultVersion = new Lazy( () => new ApiVersion( 1, 0 ) ); + const string ParsePattern = @"^(\d{4}-\d{2}-\d{2})?\.?(\d{0,9})\.?(\d{0,9})\.?-?(.*)$"; + const string GroupVersionFormat = "yyyy-MM-dd"; + static Lazy defaultVersion = new Lazy( () => new ApiVersion( 1, 0 ) ); /// /// Initializes a new instance of the class. /// /// The group version. public ApiVersion( DateTime groupVersion ) - : this( new DateTime?( groupVersion ), null, null, null ) - { - } + : this( new DateTime?( groupVersion ), null, null, null ) { } /// /// Initializes a new instance of the class. @@ -102,15 +104,17 @@ internal ApiVersion( DateTime? groupVersion, int? majorVersion, int? minorVersio GroupVersion = groupVersion; MajorVersion = majorVersion; MinorVersion = minorVersion; - Status = string.IsNullOrEmpty( status ) ? null : status; + Status = IsNullOrEmpty( status ) ? null : status; } [DebuggerStepThrough] [ContractArgumentValidator] - private static void RequireValidStatus( string status ) + static void RequireValidStatus( string status ) { if ( !IsValidStatus( status ) ) + { throw new ArgumentException( SR.ApiVersionBadStatus.FormatDefault( status ), nameof( status ) ); + } Contract.EndContractBlock(); } @@ -139,7 +143,7 @@ private static void RequireValidStatus( string status ) /// The minor version number or null. public int? MinorVersion { get; } - private int ImpliedMinorVersion => MinorVersion ?? 0; + int ImpliedMinorVersion => MinorVersion ?? 0; /// /// Gets the optional version status. @@ -157,8 +161,7 @@ private static void RequireValidStatus( string status ) /// True if the status is valid; otherwise, false. /// The status must be alphabetic or alpanumeric, start with a letter, and contain no spaces. [Pure] - public static bool IsValidStatus( string status ) => - string.IsNullOrEmpty( status ) ? false : Regex.IsMatch( status, @"^[a-zA-Z][a-zA-Z0-9]*$", RegexOptions.Singleline ); + public static bool IsValidStatus( string status ) => IsNullOrEmpty( status ) ? false : IsMatch( status, @"^[a-zA-Z][a-zA-Z0-9]*$", Singleline ); /// /// Parses the specified text into an API version. @@ -171,7 +174,7 @@ public static ApiVersion Parse( string text ) Arg.NotNullOrEmpty( text, nameof( text ) ); Contract.Ensures( Contract.Result() != null ); - var match = Regex.Match( text, ParsePattern, RegexOptions.Singleline ); + var match = Match( text, ParsePattern, Singleline ); if ( !match.Success ) { @@ -184,22 +187,20 @@ public static ApiVersion Parse( string text ) { status = match.Groups[4].Value; - if ( !string.IsNullOrEmpty( status ) && !IsValidStatus( status ) ) + if ( !IsNullOrEmpty( status ) && !IsValidStatus( status ) ) { throw new FormatException( SR.ApiVersionBadStatus.FormatDefault( status ) ); } } - var culture = CultureInfo.InvariantCulture; + var culture = InvariantCulture; var group = default( DateTime? ); var major = default( int? ); var minor = default( int? ); if ( match.Groups[1].Success ) { - var temp = default( DateTime ); - - if ( !DateTime.TryParseExact( match.Groups[1].Value, GroupVersionFormat, culture, DateTimeStyles.None, out temp ) ) + if ( !TryParseExact( match.Groups[1].Value, GroupVersionFormat, culture, DateTimeStyles.None, out var temp ) ) { throw new FormatException( SR.ApiVersionBadGroupVersion.FormatDefault( match.Groups[1].Value ) ); } @@ -241,12 +242,12 @@ public static bool TryParse( string text, out ApiVersion version ) version = null; - if ( string.IsNullOrEmpty( text ) ) + if ( IsNullOrEmpty( text ) ) { return false; } - var match = Regex.Match( text, ParsePattern, RegexOptions.Singleline ); + var match = Match( text, ParsePattern, Singleline ); if ( !match.Success ) { @@ -259,22 +260,20 @@ public static bool TryParse( string text, out ApiVersion version ) { status = match.Groups[4].Value; - if ( !string.IsNullOrEmpty( status ) && !IsValidStatus( status ) ) + if ( !IsNullOrEmpty( status ) && !IsValidStatus( status ) ) { return false; } } - var culture = CultureInfo.InvariantCulture; + var culture = InvariantCulture; var group = default( DateTime? ); var major = default( int? ); var minor = default( int? ); if ( match.Groups[1].Success ) { - var temp = default( DateTime ); - - if ( !DateTime.TryParseExact( match.Groups[1].Value, GroupVersionFormat, culture, DateTimeStyles.None, out temp ) ) + if ( !TryParseExact( match.Groups[1].Value, GroupVersionFormat, culture, DateTimeStyles.None, out var temp ) ) { return false; } @@ -305,7 +304,7 @@ public static bool TryParse( string text, out ApiVersion version ) return true; } - private void AppendGroupVersion( StringBuilder text, IFormatProvider formatProvider ) + void AppendGroupVersion( StringBuilder text, IFormatProvider formatProvider ) { Contract.Requires( text != null ); @@ -315,7 +314,7 @@ private void AppendGroupVersion( StringBuilder text, IFormatProvider formatProvi } } - private void AppendMajorAndMinorVersion( StringBuilder text, IFormatProvider formatProvider ) + void AppendMajorAndMinorVersion( StringBuilder text, IFormatProvider formatProvider ) { Contract.Requires( text != null ); @@ -343,11 +342,11 @@ private void AppendMajorAndMinorVersion( StringBuilder text, IFormatProvider for } } - private void AppendStatus( StringBuilder text ) + void AppendStatus( StringBuilder text ) { Contract.Requires( text != null ); - if ( text.Length > 0 && !string.IsNullOrEmpty( Status ) ) + if ( text.Length > 0 && !IsNullOrEmpty( Status ) ) { text.Append( '-' ); text.Append( Status ); @@ -387,13 +386,13 @@ private void AppendStatus( StringBuilder text ) /// /// The specified is null or any empty string. /// The specified is not one of the supported format values. - public virtual string ToString( string format ) => ToString( format, CultureInfo.InvariantCulture ); + public virtual string ToString( string format ) => ToString( format, InvariantCulture ); /// /// Returns the text representation of the version. /// /// The string representation of the version. - public override string ToString() => ToString( null, CultureInfo.InvariantCulture ); + public override string ToString() => ToString( null, InvariantCulture ); /// /// Determines whether the current object equals another object. @@ -469,7 +468,7 @@ private void AppendStatus( StringBuilder text ) /// /// The other to evaluate. /// True if the specified objet is equal to the current instance; otherwise, false. - public bool Equals( ApiVersion other ) + public virtual bool Equals( ApiVersion other ) { if ( other == null ) { @@ -592,4 +591,4 @@ public virtual string ToString( string format, IFormatProvider formatProvider ) return text.ToString(); } } -} +} \ No newline at end of file diff --git a/src/Common/ApiVersionAttribute.cs b/src/Common/ApiVersionAttribute.cs index cebb9cce..6188f188 100644 --- a/src/Common/ApiVersionAttribute.cs +++ b/src/Common/ApiVersionAttribute.cs @@ -21,19 +21,13 @@ public partial class ApiVersionAttribute : ApiVersionsBaseAttribute, IApiVersion /// Initializes a new instance of the class. /// /// The API version. - protected ApiVersionAttribute( ApiVersion version ) - : base( version ) - { - } + protected ApiVersionAttribute( ApiVersion version ) : base( version ) { } /// /// Initializes a new instance of the class. /// /// The API version string. - public ApiVersionAttribute( string version ) - : base( version ) - { - } + public ApiVersionAttribute( string version ) : base( version ) { } bool IApiVersionProvider.AdvertiseOnly => false; @@ -50,4 +44,4 @@ public ApiVersionAttribute( string version ) /// A hash code. public override int GetHashCode() => ( base.GetHashCode() * 397 ) ^ Deprecated.GetHashCode(); } -} +} \ No newline at end of file diff --git a/src/Common/ApiVersionNeutralAttribute.cs b/src/Common/ApiVersionNeutralAttribute.cs index d1546599..37cb1eb9 100644 --- a/src/Common/ApiVersionNeutralAttribute.cs +++ b/src/Common/ApiVersionNeutralAttribute.cs @@ -15,4 +15,4 @@ namespace Microsoft.AspNetCore.Mvc public sealed class ApiVersionNeutralAttribute : Attribute, IApiVersionNeutral { } -} +} \ No newline at end of file diff --git a/src/Common/CollectionExtensions.cs b/src/Common/CollectionExtensions.cs index a49c7285..e0f7a492 100644 --- a/src/Common/CollectionExtensions.cs +++ b/src/Common/CollectionExtensions.cs @@ -12,16 +12,14 @@ namespace Microsoft.AspNetCore.Mvc using static System.Globalization.CultureInfo; using static System.String; - internal static partial class CollectionExtensions + static partial class CollectionExtensions { internal static bool TryGetValue( this IDictionary dictionary, TKey key, out TValue value ) { Contract.Requires( dictionary != null ); Contract.Requires( key != null ); - object val; - - if ( dictionary.TryGetValue( key, out val ) && ( val is TValue ) ) + if ( dictionary.TryGetValue( key, out var val ) && ( val is TValue ) ) { value = (TValue) val; return true; @@ -38,9 +36,7 @@ internal static IReadOnlyList ToSortedReadOnlyList( this IEnumerable se Contract.Requires( sequence != null ); Contract.Ensures( Contract.Result>() != null ); - var list = sequence as List; - - if ( list != null ) + if ( sequence is List list ) { list.Sort(); return list; @@ -77,4 +73,4 @@ internal static string EnsureZeroOrOneApiVersions( this ICollection apiV throw new AmbiguousApiVersionException( message, apiVersions.OrderBy( v => v ) ); } } -} +} \ No newline at end of file diff --git a/src/Common/Common.projitems b/src/Common/Common.projitems new file mode 100644 index 00000000..21b5be05 --- /dev/null +++ b/src/Common/Common.projitems @@ -0,0 +1,54 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 6d0e834b-6422-44cd-9a85-e3be9dead1be + + + Microsoft + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Common/Common.shproj b/src/Common/Common.shproj new file mode 100644 index 00000000..745cc712 --- /dev/null +++ b/src/Common/Common.shproj @@ -0,0 +1,13 @@ + + + + 6d0e834b-6422-44cd-9a85-e3be9dead1be + 14.0 + + + + + + + + diff --git a/src/Common/ControllerNameAttribute.cs b/src/Common/ControllerNameAttribute.cs index 907e09a2..d2591c77 100644 --- a/src/Common/ControllerNameAttribute.cs +++ b/src/Common/ControllerNameAttribute.cs @@ -22,4 +22,4 @@ public sealed partial class ControllerNameAttribute /// The controller name. public string Name { get; } } -} +} \ No newline at end of file diff --git a/src/Common/MapToApiVersionAttribute.cs b/src/Common/MapToApiVersionAttribute.cs index f080f380..e21c85a2 100644 --- a/src/Common/MapToApiVersionAttribute.cs +++ b/src/Common/MapToApiVersionAttribute.cs @@ -21,22 +21,16 @@ public partial class MapToApiVersionAttribute : ApiVersionsBaseAttribute, IApiVe /// Initializes a new instance of the class. /// /// The API version. - protected MapToApiVersionAttribute( ApiVersion version ) - : base( version ) - { - } + protected MapToApiVersionAttribute( ApiVersion version ) : base( version ) { } /// /// Initializes a new instance of the class. /// /// The API version string. - public MapToApiVersionAttribute( string version ) - : base( version ) - { - } + public MapToApiVersionAttribute( string version ) : base( version ) { } bool IApiVersionProvider.AdvertiseOnly => false; bool IApiVersionProvider.Deprecated => false; } -} +} \ No newline at end of file diff --git a/src/Common/ReportApiVersionsAttribute.cs b/src/Common/ReportApiVersionsAttribute.cs index db84dc60..f712b122 100644 --- a/src/Common/ReportApiVersionsAttribute.cs +++ b/src/Common/ReportApiVersionsAttribute.cs @@ -20,8 +20,8 @@ namespace Microsoft.AspNetCore.Mvc [AttributeUsage( Class | Method, Inherited = true, AllowMultiple = false )] public sealed partial class ReportApiVersionsAttribute : ActionFilterAttribute { - private const string ApiSupportedVersions = "api-supported-versions"; - private const string ApiDeprecatedVersions = "api-deprecated-versions"; - private const string ValueSeparator = ", "; + const string ApiSupportedVersions = "api-supported-versions"; + const string ApiDeprecatedVersions = "api-deprecated-versions"; + const string ValueSeparator = ", "; } -} +} \ No newline at end of file diff --git a/src/Common/TypeExtensions.cs b/src/Common/TypeExtensions.cs index 041aded8..ca9535cc 100644 --- a/src/Common/TypeExtensions.cs +++ b/src/Common/TypeExtensions.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Mvc using static System.Nullable; using static System.ComponentModel.TypeDescriptor; - internal static partial class TypeExtensions + static partial class TypeExtensions { internal static bool IsSimpleType( this Type type ) { @@ -21,7 +21,7 @@ internal static bool IsSimpleType( this Type type ) #endif type.Equals( typeof( string ) ) || type.Equals( typeof( DateTime ) ) || - type.Equals( typeof( Decimal ) ) || + type.Equals( typeof( decimal ) ) || type.Equals( typeof( Guid ) ) || type.Equals( typeof( DateTimeOffset ) ) || type.Equals( typeof( TimeSpan ) ); @@ -45,4 +45,4 @@ internal static bool IsSimpleUnderlyingType( this Type type ) internal static bool CanConvertFromString( this Type type ) => type.IsSimpleUnderlyingType() || type.HasStringConverter(); } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/AmbiguousApiVersionException.cs b/src/Common/Versioning/AmbiguousApiVersionException.cs index 4da7fef7..99b4c52e 100644 --- a/src/Common/Versioning/AmbiguousApiVersionException.cs +++ b/src/Common/Versioning/AmbiguousApiVersionException.cs @@ -19,15 +19,14 @@ namespace Microsoft.AspNetCore.Mvc.Versioning #endif public class AmbiguousApiVersionException : Exception { - private readonly string[] apiVersions; + readonly string[] apiVersions; /// /// Initializes a new instance of the class. /// /// The associated error message. /// The sequence of ambiguous API versions. - public AmbiguousApiVersionException( string message, IEnumerable apiVersions ) - : base( message ) + public AmbiguousApiVersionException( string message, IEnumerable apiVersions ) : base( message ) { Arg.NotNull( apiVersions, nameof( apiVersions ) ); this.apiVersions = apiVersions.ToArray(); @@ -39,8 +38,7 @@ public AmbiguousApiVersionException( string message, IEnumerable apiVers /// The associated error message. /// The sequence of ambiguous API versions. /// The inner exception that caused the current exception, if any. - public AmbiguousApiVersionException( string message, IEnumerable apiVersions, Exception innerException ) - : base( message, innerException ) + public AmbiguousApiVersionException( string message, IEnumerable apiVersions, Exception innerException ) : base( message, innerException ) { Arg.NotNull( apiVersions, nameof( apiVersions ) ); this.apiVersions = apiVersions.ToArray(); @@ -57,11 +55,8 @@ public AmbiguousApiVersionException( string message, IEnumerable apiVers /// /// The serialization info the exception is being deserialized with. /// The streaming context the exception is being deserialized from. - protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext context ) - : base( info, context ) - { + protected AmbiguousApiVersionException( SerializationInfo info, StreamingContext context ) : base( info, context ) => apiVersions = (string[]) info.GetValue( nameof( apiVersions ), typeof( string[] ) ); - } /// /// Gets information about the exception being serialized. @@ -75,4 +70,4 @@ public override void GetObjectData( SerializationInfo info, StreamingContext con } #endif } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/ApiVersionModel.cs b/src/Common/Versioning/ApiVersionModel.cs index d9e5fadc..2a3e1498 100644 --- a/src/Common/Versioning/ApiVersionModel.cs +++ b/src/Common/Versioning/ApiVersionModel.cs @@ -17,20 +17,20 @@ namespace Microsoft.AspNetCore.Mvc.Versioning [DebuggerTypeProxy( typeof( ApiVersionModelDebugView ) )] public sealed partial class ApiVersionModel { - private const int DefaultModel = 0; - private const int NeutralModel = 1; - private const int EmptyModel = 2; - private static readonly Lazy defaultVersion = new Lazy( () => new ApiVersionModel( DefaultModel ) ); - private static readonly Lazy neutralVersion = new Lazy( () => new ApiVersionModel( NeutralModel ) ); - private static readonly Lazy emptyVersion = new Lazy( () => new ApiVersionModel( EmptyModel ) ); - private static readonly Lazy> emptyVersions = new Lazy>( () => new ApiVersion[0] ); - private static readonly Lazy> defaultVersions = new Lazy>( () => new[] { ApiVersion.Default } ); - private readonly Lazy> declaredVersions; - private readonly Lazy> implementedVersions; - private readonly Lazy> supportedVersions; - private readonly Lazy> deprecatedVersions; - - private ApiVersionModel( int kind ) + const int DefaultModel = 0; + const int NeutralModel = 1; + const int EmptyModel = 2; + static readonly Lazy defaultVersion = new Lazy( () => new ApiVersionModel( DefaultModel ) ); + static readonly Lazy neutralVersion = new Lazy( () => new ApiVersionModel( NeutralModel ) ); + static readonly Lazy emptyVersion = new Lazy( () => new ApiVersionModel( EmptyModel ) ); + static readonly Lazy> emptyVersions = new Lazy>( () => new ApiVersion[0] ); + static readonly Lazy> defaultVersions = new Lazy>( () => new[] { ApiVersion.Default } ); + readonly Lazy> declaredVersions; + readonly Lazy> implementedVersions; + readonly Lazy> supportedVersions; + readonly Lazy> deprecatedVersions; + + ApiVersionModel( int kind ) { switch ( kind ) { @@ -162,10 +162,10 @@ public ApiVersionModel( this.declaredVersions = new Lazy>( declaredVersions.ToSortedReadOnlyList ); this.supportedVersions = new Lazy>( supportedVersions.Union( advertisedVersions ).ToSortedReadOnlyList ); this.deprecatedVersions = new Lazy>( deprecatedVersions.Union( deprecatedAdvertisedVersions ).ToSortedReadOnlyList ); - this.implementedVersions = new Lazy>( () => this.supportedVersions.Value.Union( this.deprecatedVersions.Value ).ToSortedReadOnlyList() ); + implementedVersions = new Lazy>( () => this.supportedVersions.Value.Union( this.deprecatedVersions.Value ).ToSortedReadOnlyList() ); } - private string DebuggerDisplayText => IsApiVersionNeutral ? "*.*" : string.Join( ", ", DeclaredApiVersions ); + string DebuggerDisplayText => IsApiVersionNeutral ? "*.*" : string.Join( ", ", DeclaredApiVersions ); /// /// Gets the default API version information. diff --git a/src/Common/Versioning/ApiVersionModelDebugView.cs b/src/Common/Versioning/ApiVersionModelDebugView.cs index 06f5ab38..8eb7427b 100644 --- a/src/Common/Versioning/ApiVersionModelDebugView.cs +++ b/src/Common/Versioning/ApiVersionModelDebugView.cs @@ -6,10 +6,12 @@ namespace Microsoft.AspNetCore.Mvc.Versioning { using System; using System.Diagnostics.Contracts; + using static System.String; - internal sealed class ApiVersionModelDebugView + sealed class ApiVersionModelDebugView { - private readonly ApiVersionModel model; + const string Comma = ", "; + readonly ApiVersionModel model; public ApiVersionModelDebugView( ApiVersionModel model ) { @@ -19,12 +21,12 @@ public ApiVersionModelDebugView( ApiVersionModel model ) public bool VersionNeutral => model.IsApiVersionNeutral; - public string Declared => string.Join( ", ", model.DeclaredApiVersions ); + public string Declared => Join( Comma, model.DeclaredApiVersions ); - public string Implemented => string.Join( ", ", model.ImplementedApiVersions ); + public string Implemented => Join( Comma, model.ImplementedApiVersions ); - public string Supported => string.Join( ", ", model.SupportedApiVersions ); + public string Supported => Join( Comma, model.SupportedApiVersions ); - public string Deprecated => string.Join( ", ", model.DeprecatedApiVersions ); + public string Deprecated => Join( Comma, model.DeprecatedApiVersions ); } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/ApiVersionModelExtensions.cs b/src/Common/Versioning/ApiVersionModelExtensions.cs index cb1c9cdc..dfb4b5b9 100644 --- a/src/Common/Versioning/ApiVersionModelExtensions.cs +++ b/src/Common/Versioning/ApiVersionModelExtensions.cs @@ -100,4 +100,4 @@ public static ApiVersionModel Aggregate( this IEnumerable versi return new ApiVersionModel( supported, deprecated ); } } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/ApiVersionReader.cs b/src/Common/Versioning/ApiVersionReader.cs index a91edbb4..7f5f5928 100644 --- a/src/Common/Versioning/ApiVersionReader.cs +++ b/src/Common/Versioning/ApiVersionReader.cs @@ -11,10 +11,10 @@ namespace Microsoft.AspNetCore.Mvc.Versioning using System.Linq; using System.Collections.Generic; using System.Diagnostics.Contracts; + using static System.String; #if WEBAPI using HttpRequest = System.Net.Http.HttpRequestMessage; #endif - using static System.String; /// /// Provides utility functions for service API version readers. diff --git a/src/Common/Versioning/ApiVersioningOptions.cs b/src/Common/Versioning/ApiVersioningOptions.cs index 7ab8b76b..e52435b1 100644 --- a/src/Common/Versioning/ApiVersioningOptions.cs +++ b/src/Common/Versioning/ApiVersioningOptions.cs @@ -18,19 +18,16 @@ namespace Microsoft.AspNetCore.Mvc.Versioning /// public partial class ApiVersioningOptions { - private ApiVersion defaultApiVersion = ApiVersion.Default; - private IApiVersionReader apiVersionReader = Combine( new QueryStringApiVersionReader(), new UrlSegmentApiVersionReader() ); - private IApiVersionSelector apiVersionSelector; - private IErrorResponseProvider errorResponseProvider = new DefaultErrorResponseProvider(); - private ApiVersionConventionBuilder conventions = new ApiVersionConventionBuilder(); + ApiVersion defaultApiVersion = ApiVersion.Default; + IApiVersionReader apiVersionReader = Combine( new QueryStringApiVersionReader(), new UrlSegmentApiVersionReader() ); + IApiVersionSelector apiVersionSelector; + IErrorResponseProvider errorResponseProvider = new DefaultErrorResponseProvider(); + ApiVersionConventionBuilder conventions = new ApiVersionConventionBuilder(); /// /// Initializes a new instance of the class. /// - public ApiVersioningOptions() - { - apiVersionSelector = new DefaultApiVersionSelector( this ); - } + public ApiVersioningOptions() => apiVersionSelector = new DefaultApiVersionSelector( this ); /// /// Gets or sets a value indicating whether requests report the service API version compatibility @@ -66,10 +63,7 @@ public ApiVersioningOptions() /// The default API version. The default value is . public ApiVersion DefaultApiVersion { - get - { - return defaultApiVersion; - } + get => defaultApiVersion; set { Arg.NotNull( value, nameof( value ) ); diff --git a/src/Common/Versioning/ApiVersionsBaseAttribute.cs b/src/Common/Versioning/ApiVersionsBaseAttribute.cs index e19dac34..f5889035 100644 --- a/src/Common/Versioning/ApiVersionsBaseAttribute.cs +++ b/src/Common/Versioning/ApiVersionsBaseAttribute.cs @@ -17,18 +17,14 @@ namespace Microsoft.AspNetCore.Mvc.Versioning [SuppressMessage( "Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", Justification = "An accessor property is provided, but the values are typed; not strings." )] public abstract class ApiVersionsBaseAttribute : Attribute { - private readonly Lazy computedHashCode; - private readonly Lazy> versions; + readonly Lazy computedHashCode; + readonly Lazy> versions; /// /// Initializes a new instance of the class. /// /// The API version. - protected ApiVersionsBaseAttribute( ApiVersion version ) - : this( new[] { version } ) - { - Arg.NotNull( version, nameof( version ) ); - } + protected ApiVersionsBaseAttribute( ApiVersion version ) : this( new[] { version } ) => Arg.NotNull( version, nameof( version ) ); /// /// Initializes a new instance of the class. @@ -46,11 +42,7 @@ protected ApiVersionsBaseAttribute( params ApiVersion[] versions ) /// Initializes a new instance of the class. /// /// The API version string. - public ApiVersionsBaseAttribute( string version ) - : this( new[] { version } ) - { - Arg.NotNullOrEmpty( version, nameof( version ) ); - } + public ApiVersionsBaseAttribute( string version ) : this( new[] { version } ) => Arg.NotNullOrEmpty( version, nameof( version ) ); /// /// Initializes a new instance of the class. @@ -65,7 +57,7 @@ public ApiVersionsBaseAttribute( params string[] versions ) this.versions = new Lazy>( () => versions.Select( Parse ).Distinct().ToSortedReadOnlyList() ); } - private static int ComputeHashCode( IEnumerable versions ) + static int ComputeHashCode( IEnumerable versions ) { Contract.Requires( versions != null ); @@ -111,4 +103,4 @@ private static int ComputeHashCode( IEnumerable versions ) /// A hash code. public override int GetHashCode() => computedHashCode.Value; } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/AttributeExtensions.cs b/src/Common/Versioning/AttributeExtensions.cs index 68ddf7bd..73b5e618 100644 --- a/src/Common/Versioning/AttributeExtensions.cs +++ b/src/Common/Versioning/AttributeExtensions.cs @@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning using System.Diagnostics.Contracts; using System.Linq; - internal static class AttributeExtensions + static class AttributeExtensions { internal static IReadOnlyList GetImplementedApiVersions( this IEnumerable attributes ) where T : IApiVersionProvider { @@ -57,4 +57,4 @@ orderby version return versions.Distinct().ToArray(); } } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/ConstantApiVersionSelector.cs b/src/Common/Versioning/ConstantApiVersionSelector.cs index 900b582b..cd4fc73b 100644 --- a/src/Common/Versioning/ConstantApiVersionSelector.cs +++ b/src/Common/Versioning/ConstantApiVersionSelector.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning #endif public sealed class ConstantApiVersionSelector : IApiVersionSelector { - private readonly ApiVersion version; + readonly ApiVersion version; /// /// Initializes a new instance of the class. @@ -40,4 +40,4 @@ public ConstantApiVersionSelector( ApiVersion version ) /// This method always returns the constant API version the selector was initialized with. public ApiVersion SelectVersion( HttpRequest request, ApiVersionModel model ) => version; } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs b/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs index bd683fa1..4aaec1bb 100644 --- a/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs +++ b/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs @@ -16,8 +16,8 @@ namespace Microsoft.AspNetCore.Mvc.Versioning.Conventions /// public partial class ActionApiVersionConventionBuilderCollection : IReadOnlyCollection> { - private readonly ControllerApiVersionConventionBuilder controllerBuilder; - private readonly IList> actionBuilderMappings = new List>(); + readonly ControllerApiVersionConventionBuilder controllerBuilder; + readonly IList> actionBuilderMappings = new List>(); /// /// Initializes a new instance of the class. @@ -89,7 +89,7 @@ public virtual IEnumerator> GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - private sealed partial class ActionBuilderMapping + sealed partial class ActionBuilderMapping { internal ActionBuilderMapping( MethodInfo method, ActionApiVersionConventionBuilder builder ) { diff --git a/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderT.cs b/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderT.cs index b7a9ade9..cf909c51 100644 --- a/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderT.cs +++ b/src/Common/Versioning/Conventions/ActionApiVersionConventionBuilderT.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning.Conventions /// public partial class ActionApiVersionConventionBuilder { - private readonly HashSet mappedVersions = new HashSet(); + readonly HashSet mappedVersions = new HashSet(); /// /// Initializes a new instance of the class. diff --git a/src/Common/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs b/src/Common/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs index 2c5ee0ae..8b90f358 100644 --- a/src/Common/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs +++ b/src/Common/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs @@ -16,18 +16,15 @@ namespace Microsoft.AspNetCore.Mvc.Versioning.Conventions /// public partial class ControllerApiVersionConventionBuilder { - private readonly HashSet supportedVersions = new HashSet(); - private readonly HashSet deprecatedVersions = new HashSet(); - private readonly HashSet advertisedVersions = new HashSet(); - private readonly HashSet deprecatedAdvertisedVersions = new HashSet(); + readonly HashSet supportedVersions = new HashSet(); + readonly HashSet deprecatedVersions = new HashSet(); + readonly HashSet advertisedVersions = new HashSet(); + readonly HashSet deprecatedAdvertisedVersions = new HashSet(); /// /// Initializes a new instance of the class. /// - public ControllerApiVersionConventionBuilder() - { - ActionBuilders = new ActionApiVersionConventionBuilderCollection( this ); - } + public ControllerApiVersionConventionBuilder() => ActionBuilders = new ActionApiVersionConventionBuilderCollection( this ); /// /// Gets or sets a value indicating whether the current controller is API version-neutral. diff --git a/src/Common/Versioning/Conventions/ExpressionExtensions.cs b/src/Common/Versioning/Conventions/ExpressionExtensions.cs index 97dadf4b..5667b621 100644 --- a/src/Common/Versioning/Conventions/ExpressionExtensions.cs +++ b/src/Common/Versioning/Conventions/ExpressionExtensions.cs @@ -9,21 +9,19 @@ namespace Microsoft.AspNetCore.Mvc.Versioning.Conventions using System.Linq.Expressions; using System.Reflection; - internal static class ExpressionExtensions + static class ExpressionExtensions { internal static MethodInfo ExtractMethod( this Expression expression ) { Contract.Requires( expression != null ); Contract.Ensures( Contract.Result() != null ); - var methodCall = expression.Body as MethodCallExpression; - - if ( methodCall == null ) + if ( expression.Body is MethodCallExpression methodCall ) { - throw new InvalidOperationException( SR.InvalidActionMethodExpression.FormatDefault( expression ) ); + return methodCall.Method; } - return methodCall.Method; + throw new InvalidOperationException( SR.InvalidActionMethodExpression.FormatDefault( expression ) ); } } } \ No newline at end of file diff --git a/src/Common/Versioning/CurrentImplementationApiVersionSelector.cs b/src/Common/Versioning/CurrentImplementationApiVersionSelector.cs index 5a30c1cd..d8f92978 100644 --- a/src/Common/Versioning/CurrentImplementationApiVersionSelector.cs +++ b/src/Common/Versioning/CurrentImplementationApiVersionSelector.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning #endif public class CurrentImplementationApiVersionSelector : IApiVersionSelector { - private readonly ApiVersioningOptions options; + readonly ApiVersioningOptions options; /// /// Initializes a new instance of the class. @@ -60,4 +60,4 @@ public virtual ApiVersion SelectVersion( HttpRequest request, ApiVersionModel mo return model.ImplementedApiVersions.Where( v => v.Status == null ).Max( v => v ) ?? options.DefaultApiVersion; } } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/DefaultApiVersionSelector.cs b/src/Common/Versioning/DefaultApiVersionSelector.cs index e69478e8..b86079c4 100644 --- a/src/Common/Versioning/DefaultApiVersionSelector.cs +++ b/src/Common/Versioning/DefaultApiVersionSelector.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning #endif public sealed class DefaultApiVersionSelector : IApiVersionSelector { - private readonly ApiVersioningOptions options; + readonly ApiVersioningOptions options; /// /// Initializes a new instance of the class. @@ -39,4 +39,4 @@ public DefaultApiVersionSelector( ApiVersioningOptions options ) /// The selected API version. public ApiVersion SelectVersion( HttpRequest request, ApiVersionModel model ) => options.DefaultApiVersion; } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/HeaderApiVersionReader.cs b/src/Common/Versioning/HeaderApiVersionReader.cs index 033863a1..ffeef1c8 100644 --- a/src/Common/Versioning/HeaderApiVersionReader.cs +++ b/src/Common/Versioning/HeaderApiVersionReader.cs @@ -45,4 +45,4 @@ public HeaderApiVersionReader( params string[] headerNames ) /// HTTP header names are evaluated in a case-insensitive manner. public ICollection HeaderNames { get; } = new HashSet( OrdinalIgnoreCase ); } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/IApiVersionNeutral.cs b/src/Common/Versioning/IApiVersionNeutral.cs index 1ed51346..e5a54629 100644 --- a/src/Common/Versioning/IApiVersionNeutral.cs +++ b/src/Common/Versioning/IApiVersionNeutral.cs @@ -13,5 +13,4 @@ namespace Microsoft.AspNetCore.Mvc.Versioning public interface IApiVersionNeutral { } -} - +} \ No newline at end of file diff --git a/src/Common/Versioning/IApiVersionProvider.cs b/src/Common/Versioning/IApiVersionProvider.cs index 2da057dd..e167f30d 100644 --- a/src/Common/Versioning/IApiVersionProvider.cs +++ b/src/Common/Versioning/IApiVersionProvider.cs @@ -32,5 +32,4 @@ public interface IApiVersionProvider /// A read-only list of API versions. IReadOnlyList Versions { get; } } -} - +} \ No newline at end of file diff --git a/src/Common/Versioning/IApiVersionReader.cs b/src/Common/Versioning/IApiVersionReader.cs index 9e38ed5d..e7e1413b 100644 --- a/src/Common/Versioning/IApiVersionReader.cs +++ b/src/Common/Versioning/IApiVersionReader.cs @@ -26,4 +26,4 @@ public interface IApiVersionReader /// The raw, unparsed service API version value read from the request or null if request does not contain an API version. string Read( HttpRequest request ); } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/IApiVersionSelector.cs b/src/Common/Versioning/IApiVersionSelector.cs index d47c82d3..a838084c 100644 --- a/src/Common/Versioning/IApiVersionSelector.cs +++ b/src/Common/Versioning/IApiVersionSelector.cs @@ -28,4 +28,4 @@ public interface IApiVersionSelector /// The selected API version. ApiVersion SelectVersion( HttpRequest request, ApiVersionModel model ); } -} +} \ No newline at end of file diff --git a/src/Common/Versioning/LowestImplementedApiVersionSelector.cs b/src/Common/Versioning/LowestImplementedApiVersionSelector.cs index a27986a6..ad0ff103 100644 --- a/src/Common/Versioning/LowestImplementedApiVersionSelector.cs +++ b/src/Common/Versioning/LowestImplementedApiVersionSelector.cs @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning #endif public class LowestImplementedApiVersionSelector : IApiVersionSelector { - private readonly ApiVersioningOptions options; + readonly ApiVersioningOptions options; /// /// Initializes a new instance of the class. @@ -60,4 +60,4 @@ public virtual ApiVersion SelectVersion( HttpRequest request, ApiVersionModel mo return model.ImplementedApiVersions.Where( v => v.Status == null ).Min( v => v ) ?? options.DefaultApiVersion; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.csproj b/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.csproj new file mode 100644 index 00000000..d45a64bc --- /dev/null +++ b/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.csproj @@ -0,0 +1,31 @@ + + + + 2.0.1 + 2.0.1.0 + net45 + Microsoft.AspNet.OData.Versioning + Microsoft ASP.NET Web API Versioning for OData v4.0 + A service API versioning library for Microsoft ASP.NET Web API and OData v4.0. + Microsoft + Microsoft;AspNet;AspNetWebAPI;OData;Versioning + • Fixes route template parameter name binding (Issue #40) + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.xproj b/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.xproj deleted file mode 100644 index 382f1d50..00000000 --- a/src/Microsoft.AspNet.OData.Versioning/Microsoft.AspNet.OData.Versioning.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 48a2b488-23ab-4c83-ae30-0b8b735c4562 - Microsoft - .\obj - .\bin\ - v4.5 - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/OData.Edm/ApiVersionAnnotation.cs b/src/Microsoft.AspNet.OData.Versioning/OData.Edm/ApiVersionAnnotation.cs index 8574a5ae..70936357 100644 --- a/src/Microsoft.AspNet.OData.Versioning/OData.Edm/ApiVersionAnnotation.cs +++ b/src/Microsoft.AspNet.OData.Versioning/OData.Edm/ApiVersionAnnotation.cs @@ -24,4 +24,4 @@ public ApiVersionAnnotation( ApiVersion apiVersion ) /// The annotated API version. public ApiVersion ApiVersion { get; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.OData.Versioning/Properties/AssemblyInfo.cs deleted file mode 100644 index 68ae73e1..00000000 --- a/src/Microsoft.AspNet.OData.Versioning/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyProduct( "Microsoft.AspNet.OData.Versioning" )] \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/System.Web.Http/HttpConfigurationExtensions.cs b/src/Microsoft.AspNet.OData.Versioning/System.Web.Http/HttpConfigurationExtensions.cs index eb7e98ce..81840004 100644 --- a/src/Microsoft.AspNet.OData.Versioning/System.Web.Http/HttpConfigurationExtensions.cs +++ b/src/Microsoft.AspNet.OData.Versioning/System.Web.Http/HttpConfigurationExtensions.cs @@ -25,13 +25,13 @@ /// public static class HttpConfigurationExtensions { - private const string ResolverSettingsKey = "System.Web.OData.ResolverSettingsKey"; - private const string UnversionedRouteSuffix = "-Unversioned"; - private const string ApiVersionConstraintName = "apiVersion"; - private const string ApiVersionConstraint = "{" + ApiVersionConstraintName + "}"; - private static readonly Lazy> setResolverSettings = new Lazy>( GetResolverSettingsMutator ); + const string ResolverSettingsKey = "System.Web.OData.ResolverSettingsKey"; + const string UnversionedRouteSuffix = "-Unversioned"; + const string ApiVersionConstraintName = "apiVersion"; + const string ApiVersionConstraint = "{" + ApiVersionConstraintName + "}"; + static readonly Lazy> setResolverSettings = new Lazy>( GetResolverSettingsMutator ); - private static Action GetResolverSettingsMutator() + static Action GetResolverSettingsMutator() { Contract.Ensures( Contract.Result>() != null ); @@ -48,7 +48,7 @@ private static Action GetResolverSettingsMutato return action; } - private static void SetResolverSettings( this HttpConfiguration configuration, IODataPathHandler pathHandler ) + static void SetResolverSettings( this HttpConfiguration configuration, IODataPathHandler pathHandler ) { Contract.Requires( configuration != null ); @@ -77,7 +77,7 @@ private static void SetResolverSettings( this HttpConfiguration configuration, I setResolverSettings.Value( handler, configuration.Properties[ResolverSettingsKey] ); } - private static IList EnsureConventions( IList conventions ) + static IList EnsureConventions( IList conventions ) { Contract.Requires( conventions != null ); Contract.Ensures( Contract.Result>() != null ); @@ -362,7 +362,7 @@ public static ODataRoute MapVersionedODataRoute( return route; } - private static ODataPathRouteConstraint MakeVersionedODataRouteConstraint( + static ODataPathRouteConstraint MakeVersionedODataRouteConstraint( ODataPathRouteConstraint routeConstraint, IODataPathHandler pathHandler, IList routeConventions, @@ -387,7 +387,7 @@ private static ODataPathRouteConstraint MakeVersionedODataRouteConstraint( return new VersionedODataPathRouteConstraint( pathHandler, model, versionedRouteName, routeConventions.ToArray(), apiVersion ); } - private static void AddApiVersionConstraintIfNecessary( ODataRoute route ) + static void AddApiVersionConstraintIfNecessary( ODataRoute route ) { Contract.Requires( route != null ); @@ -412,7 +412,7 @@ private static void AddApiVersionConstraintIfNecessary( ODataRoute route ) } } - private static void AddRouteToRespondWithBadRequestWhenAtLeastOneRouteCouldMatch( string routeName, string routePrefix, HttpRouteCollection routes, List odataRoutes, List unversionedConstraints ) + static void AddRouteToRespondWithBadRequestWhenAtLeastOneRouteCouldMatch( string routeName, string routePrefix, HttpRouteCollection routes, List odataRoutes, List unversionedConstraints ) { Contract.Requires( !IsNullOrEmpty( routeName ) ); Contract.Requires( routes != null ); diff --git a/src/Microsoft.AspNet.OData.Versioning/TypeExtensions.cs b/src/Microsoft.AspNet.OData.Versioning/TypeExtensions.cs index dc08b866..29160e25 100644 --- a/src/Microsoft.AspNet.OData.Versioning/TypeExtensions.cs +++ b/src/Microsoft.AspNet.OData.Versioning/TypeExtensions.cs @@ -3,8 +3,8 @@ using System; using System.Web.OData; - internal static class TypeExtensions + static class TypeExtensions { internal static bool IsODataController( this Type controllerType ) => typeof( ODataController ).IsAssignableFrom( controllerType ); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/DelegatingModelConfiguration.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/DelegatingModelConfiguration.cs index 7c40c1b4..41ed436f 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/DelegatingModelConfiguration.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/DelegatingModelConfiguration.cs @@ -5,9 +5,9 @@ using System.Diagnostics.Contracts; using System.Web.OData.Builder; - internal sealed class DelegatingModelConfiguration : IModelConfiguration + sealed class DelegatingModelConfiguration : IModelConfiguration { - private readonly Action action; + readonly Action action; internal DelegatingModelConfiguration( Action action ) { @@ -17,4 +17,4 @@ internal DelegatingModelConfiguration( Action act public void Apply( ODataModelBuilder builder, ApiVersion apiVersion ) => action( builder, apiVersion ); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/IModelConfiguration.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/IModelConfiguration.cs index 332f7748..91797af8 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/IModelConfiguration.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/IModelConfiguration.cs @@ -15,4 +15,4 @@ public interface IModelConfiguration /// The API version associated with the . void Apply( ODataModelBuilder builder, ApiVersion apiVersion ); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/VersionedODataModelBuilder.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/VersionedODataModelBuilder.cs index 9a907058..6154f3c9 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/VersionedODataModelBuilder.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Builder/VersionedODataModelBuilder.cs @@ -19,8 +19,8 @@ /// public class VersionedODataModelBuilder { - private readonly HttpConfiguration configuration; - private Func modelBuilderFactory = () => new ODataConventionModelBuilder(); + readonly HttpConfiguration configuration; + Func modelBuilderFactory = () => new ODataConventionModelBuilder(); /// /// Initializes a new instance of the @@ -75,7 +75,7 @@ public Func ModelBuilderFactory /// value is null. public Action OnModelCreated { get; set; } - private IEnumerable GetMergedConfigurations() + IEnumerable GetMergedConfigurations() { Contract.Ensures( Contract.Result>() != null ); @@ -160,9 +160,8 @@ public virtual IEnumerable GetEdmModels() protected virtual void ConfigureMetadataController( HttpConfiguration configuration, IEnumerable supportedApiVersions, IEnumerable deprecatedApiVersions ) { var controllerMapping = configuration.Services.GetHttpControllerSelector().GetControllerMapping(); - var controllerDescriptor = default( HttpControllerDescriptor ); - if ( !controllerMapping.TryGetValue( "VersionedMetadata", out controllerDescriptor )) + if ( !controllerMapping.TryGetValue( "VersionedMetadata", out var controllerDescriptor ) ) { return; } diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/UnversionedODataPathRouteConstraint.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/UnversionedODataPathRouteConstraint.cs index 803103fb..38248f4a 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/UnversionedODataPathRouteConstraint.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/UnversionedODataPathRouteConstraint.cs @@ -1,7 +1,6 @@ namespace Microsoft.Web.OData.Routing { using Http; - using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; @@ -10,10 +9,10 @@ using System.Web.Http.Routing; using static System.Web.Http.Routing.HttpRouteDirection; - internal sealed class UnversionedODataPathRouteConstraint : IHttpRouteConstraint + sealed class UnversionedODataPathRouteConstraint : IHttpRouteConstraint { - private readonly ApiVersion apiVersion; - private readonly IEnumerable innerConstraints; + readonly ApiVersion apiVersion; + readonly IEnumerable innerConstraints; internal UnversionedODataPathRouteConstraint( IEnumerable innerConstraints ) { @@ -29,7 +28,7 @@ internal UnversionedODataPathRouteConstraint( IHttpRouteConstraint innerConstrai this.apiVersion = apiVersion; } - private bool MatchAnyVersion => apiVersion == null; + bool MatchAnyVersion => apiVersion == null; public bool Match( HttpRequestMessage request, IHttpRoute route, string parameterName, IDictionary values, HttpRouteDirection routeDirection ) { diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedAttributeRoutingConvention.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedAttributeRoutingConvention.cs index 4c49e2fa..672c3975 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedAttributeRoutingConvention.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedAttributeRoutingConvention.cs @@ -1,6 +1,5 @@ namespace Microsoft.Web.OData.Routing { - using Http; using Microsoft.OData.Edm; using System.Collections.Generic; using System.Diagnostics.Contracts; @@ -20,10 +19,7 @@ public class VersionedAttributeRoutingConvention : AttributeRoutingConvention /// /// The EDM model associated with the routing convention. /// The current HTTP configuration. - public VersionedAttributeRoutingConvention( IEdmModel model, HttpConfiguration configuration ) - : base( model, configuration ) - { - } + public VersionedAttributeRoutingConvention( IEdmModel model, HttpConfiguration configuration ) : base( model, configuration ) { } /// /// Initializes a new instance of the class. @@ -32,19 +28,14 @@ public VersionedAttributeRoutingConvention( IEdmModel model, HttpConfiguration c /// The current HTTP configuration. /// The OData path template handler associated with the routing convention. public VersionedAttributeRoutingConvention( IEdmModel model, HttpConfiguration configuration, IODataPathTemplateHandler pathTemplateHandler ) - : base( model, configuration, pathTemplateHandler ) - { - } + : base( model, configuration, pathTemplateHandler ) { } /// /// Initializes a new instance of the class. /// /// The EDM model associated with the routing convention. /// The sequence of controller descriptors - public VersionedAttributeRoutingConvention( IEdmModel model, IEnumerable controllers ) - : base( model, controllers ) - { - } + public VersionedAttributeRoutingConvention( IEdmModel model, IEnumerable controllers ) : base( model, controllers ) { } /// /// Initializes a new instance of the class. @@ -54,9 +45,7 @@ public VersionedAttributeRoutingConvention( IEdmModel model, IEnumerable /// The OData path template handler associated with the routing convention. public VersionedAttributeRoutingConvention( IEdmModel model, IEnumerable controllers, IODataPathTemplateHandler pathTemplateHandler ) - : base( model, controllers, pathTemplateHandler ) - { - } + : base( model, controllers, pathTemplateHandler ) { } /// /// Returns a value indicating whether the specified controller should be mapped using attribute routing conventions. diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedMetadataRoutingConvention.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedMetadataRoutingConvention.cs index bf287a51..9b057eab 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedMetadataRoutingConvention.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedMetadataRoutingConvention.cs @@ -66,4 +66,4 @@ public virtual string SelectAction( ODataPath odataPath, HttpControllerContext c return null; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedODataPathRouteConstraint.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedODataPathRouteConstraint.cs index 6b40bf8e..b604cb7d 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedODataPathRouteConstraint.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedODataPathRouteConstraint.cs @@ -40,7 +40,7 @@ public VersionedODataPathRouteConstraint( ApiVersion = apiVersion; } - private static bool IsServiceDocumentOrMetadataRoute( IDictionary values ) + static bool IsServiceDocumentOrMetadataRoute( IDictionary values ) { Contract.Requires( values != null ); object value; diff --git a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedUrlHelperDecorator.cs b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedUrlHelperDecorator.cs index 0423bc97..34a18ae8 100644 --- a/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedUrlHelperDecorator.cs +++ b/src/Microsoft.AspNet.OData.Versioning/Web.OData/Routing/VersionedUrlHelperDecorator.cs @@ -1,14 +1,13 @@ namespace Microsoft.Web.OData.Routing { - using System; using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Web.Http.Routing; - internal sealed class VersionedUrlHelperDecorator : UrlHelper + sealed class VersionedUrlHelperDecorator : UrlHelper { - private readonly UrlHelper decorated; - private readonly object apiVersion; + readonly UrlHelper decorated; + readonly object apiVersion; internal VersionedUrlHelperDecorator( UrlHelper decorated, object apiVersion ) { @@ -24,7 +23,7 @@ internal VersionedUrlHelperDecorator( UrlHelper decorated, object apiVersion ) } } - private void EnsureApiVersionRouteValue( IDictionary routeValues ) => routeValues[nameof( apiVersion )] = apiVersion; + void EnsureApiVersionRouteValue( IDictionary routeValues ) => routeValues[nameof( apiVersion )] = apiVersion; public override string Content( string path ) => decorated.Content( path ); diff --git a/src/Microsoft.AspNet.OData.Versioning/project.json b/src/Microsoft.AspNet.OData.Versioning/project.json deleted file mode 100644 index 4d1a4885..00000000 --- a/src/Microsoft.AspNet.OData.Versioning/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": "2.0.1-*", - "authors": [ "Microsoft" ], - "title": "Microsoft ASP.NET Web API Versioning for OData v4.0", - "copyright": "Copyright \u00A9 2016. Microsoft Corporation. All rights reserved.", - "description": "A service API versioning library for Microsoft ASP.NET Web API and OData v4.0.", - "language": "en", - - "dependencies": { - "Microsoft.AspNet.OData": "[5.9.1,6.0.0)", - "Microsoft.AspNet.WebApi.Versioning": "2.0.3-*" - }, - - "frameworks": { - "net45": { - } - }, - - "buildOptions": { - "compile": [ "**/*.cs", "../shared/*.cs" ], - "keyFile": "../../tools/key.snk", - "xmlDoc": true - }, - - "packOptions": { - "summary": "Provides API versioning for RESTful services created using ASP.NET Web API and OData v4.0", - "tags": [ "Microsoft", "AspNet", "AspNetWebAPI", "OData", "Versioning" ], - "owners": [ "Microsoft" ], - "releaseNotes": "\u2022 Fixes route template parameter name binding (Issue #40)", - "iconUrl": "http://go.microsoft.com/fwlink/?LinkID=288890", - "licenseUrl": "https://raw.githubusercontent.com/Microsoft/aspnet-api-versioning/master/LICENSE", - "requireLicenseAcceptance": true, - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/aspnet-api-versioning" - } - } -} diff --git a/src/Microsoft.AspNet.WebApi.Versioning/ControllerNameAttribute.cs b/src/Microsoft.AspNet.WebApi.Versioning/ControllerNameAttribute.cs index 91100ba9..05a0fd08 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/ControllerNameAttribute.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/ControllerNameAttribute.cs @@ -17,4 +17,4 @@ public ControllerNameAttribute( string name ) Name = name; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectionResult.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectionResult.cs index e258c528..e1fdd000 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectionResult.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectionResult.cs @@ -9,7 +9,7 @@ /// public partial class ApiVersionActionSelector { - private sealed class ActionSelectionResult + sealed class ActionSelectionResult { internal ActionSelectionResult( HttpActionDescriptor action ) { @@ -30,4 +30,4 @@ internal ActionSelectionResult( Exception exception ) internal Exception Exception { get; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectorCacheItem.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectorCacheItem.cs index ee01cfdf..72993541 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectorCacheItem.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ActionSelectorCacheItem.cs @@ -24,19 +24,19 @@ public partial class ApiVersionActionSelector { /// /// All caching is in a dedicated cache class, which may be optionally shared across selector instances. - /// Make this a private nested class so that nobody else can conflict with our state. + /// Make this a nested class so that nobody else can conflict with our state. /// Cache is initialized during ctor on a single thread. /// - private sealed class ActionSelectorCacheItem + sealed class ActionSelectorCacheItem { - private static readonly HttpMethod[] cacheListVerbKinds = new[] { HttpMethod.Get, HttpMethod.Put, HttpMethod.Post }; - private static readonly Type ApiControllerType = typeof( ApiController ); - private readonly HttpControllerDescriptor controllerDescriptor; - private readonly CandidateAction[] combinedCandidateActions; - private readonly IDictionary actionParameterNames = new Dictionary(); - private readonly ILookup combinedActionNameMapping; - private readonly HashSet allowedMethods = new HashSet(); - private StandardActionSelectionCache standardActions; + static readonly HttpMethod[] cacheListVerbKinds = new[] { HttpMethod.Get, HttpMethod.Put, HttpMethod.Post }; + static readonly Type ApiControllerType = typeof( ApiController ); + readonly HttpControllerDescriptor controllerDescriptor; + readonly CandidateAction[] combinedCandidateActions; + readonly IDictionary actionParameterNames = new Dictionary(); + readonly ILookup combinedActionNameMapping; + readonly HashSet allowedMethods = new HashSet(); + StandardActionSelectionCache standardActions; internal ActionSelectorCacheItem( HttpControllerDescriptor controllerDescriptor ) { @@ -73,7 +73,7 @@ internal ActionSelectorCacheItem( HttpControllerDescriptor controllerDescriptor internal HttpControllerDescriptor HttpControllerDescriptor => controllerDescriptor; - private void InitializeStandardActions() + void InitializeStandardActions() { if ( standardActions != null ) { @@ -148,7 +148,7 @@ internal HttpActionDescriptor SelectAction( HttpControllerContext controllerCont throw firstAttempt.Exception; } - private ActionSelectionResult FindAction( HttpControllerContext controllerContext, Func, HttpActionDescriptor> selector, bool ignoreSubRoutes ) + ActionSelectionResult FindAction( HttpControllerContext controllerContext, Func, HttpActionDescriptor> selector, bool ignoreSubRoutes ) { Contract.Requires( controllerContext != null ); Contract.Requires( selector != null ); @@ -161,9 +161,7 @@ private ActionSelectionResult FindAction( HttpControllerContext controllerContex return new ActionSelectionResult( new HttpResponseException( CreateSelectionError( controllerContext ) ) ); } - var action = selector( controllerContext, selectedCandidates ) as CandidateHttpActionDescriptor; - - if ( action != null ) + if ( selector( controllerContext, selectedCandidates ) is CandidateHttpActionDescriptor action ) { ElevateRouteData( controllerContext, action.CandidateAction ); return new ActionSelectionResult( action ); @@ -179,9 +177,9 @@ private ActionSelectionResult FindAction( HttpControllerContext controllerContex return new ActionSelectionResult( new InvalidOperationException( SR.ApiControllerActionSelector_AmbiguousMatch.FormatDefault( ambiguityList ) ) ); } - private static void ElevateRouteData( HttpControllerContext controllerContext, CandidateActionWithParams selectedCandidate ) => controllerContext.RouteData = selectedCandidate.RouteDataSource; + static void ElevateRouteData( HttpControllerContext controllerContext, CandidateActionWithParams selectedCandidate ) => controllerContext.RouteData = selectedCandidate.RouteDataSource; - private IReadOnlyList FindMatchingActions( HttpControllerContext controllerContext, bool ignoreSubRoutes = false, bool ignoreVerbs = false ) + IReadOnlyList FindMatchingActions( HttpControllerContext controllerContext, bool ignoreSubRoutes = false, bool ignoreVerbs = false ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result>() != null ); @@ -201,7 +199,7 @@ private IReadOnlyList FindMatchingActions( HttpCo } [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Caller is responsible for disposing of response instance." )] - private HttpResponseMessage CreateSelectionError( HttpControllerContext controllerContext ) + HttpResponseMessage CreateSelectionError( HttpControllerContext controllerContext ) { Contract.Ensures( Contract.Result() != null ); @@ -220,7 +218,7 @@ private HttpResponseMessage CreateSelectionError( HttpControllerContext controll } [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Caller is responsible for disposing of response instance." )] - private static HttpResponseMessage CreateBadRequestResponse( HttpControllerContext controllerContext ) + static HttpResponseMessage CreateBadRequestResponse( HttpControllerContext controllerContext ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result() != null ); @@ -231,7 +229,7 @@ private static HttpResponseMessage CreateBadRequestResponse( HttpControllerConte } [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Handled by the caller." )] - private HttpResponseMessage CreateActionNotFoundResponse( HttpControllerContext controllerContext ) + HttpResponseMessage CreateActionNotFoundResponse( HttpControllerContext controllerContext ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result() != null ); @@ -241,7 +239,7 @@ private HttpResponseMessage CreateActionNotFoundResponse( HttpControllerContext return controllerContext.Request.CreateErrorResponse( NotFound, message, messageDetail ); } - private static List GetInitialCandidateWithParameterListForDirectRoutes( HttpControllerContext controllerContext, IEnumerable subRoutes, bool ignoreVerbs ) + static List GetInitialCandidateWithParameterListForDirectRoutes( HttpControllerContext controllerContext, IEnumerable subRoutes, bool ignoreVerbs ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result>() != null ); @@ -261,9 +259,8 @@ private static List GetInitialCandidateWithParameterL { var combinedParameterNames = GetCombinedParameterNames( queryNameValuePairs, subRouteData.Values ); var candidates = subRouteData.Route.GetDirectRouteCandidates(); - var actionName = default( string ); - subRouteData.Values.TryGetValue( RouteValueKeys.Action, out actionName ); + subRouteData.Values.TryGetValue( RouteValueKeys.Action, out string actionName ); foreach ( var candidate in candidates ) { @@ -280,7 +277,7 @@ private static List GetInitialCandidateWithParameterL return candidateActionWithParams; } - private IEnumerable GetInitialCandidateWithParameterListForRegularRoutes( HttpControllerContext controllerContext, bool ignoreVerbs = false ) + IEnumerable GetInitialCandidateWithParameterListForRegularRoutes( HttpControllerContext controllerContext, bool ignoreVerbs = false ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result>() != null ); @@ -289,17 +286,16 @@ private IEnumerable GetInitialCandidateWithParameterL return GetCandidateActionsWithBindings( controllerContext, candidates ); } - private CandidateAction[] GetInitialCandidateList( HttpControllerContext controllerContext, bool ignoreVerbs = false ) + CandidateAction[] GetInitialCandidateList( HttpControllerContext controllerContext, bool ignoreVerbs = false ) { Contract.Requires( controllerContext != null ); Contract.Ensures( Contract.Result() != null ); - var actionName = default( string ); var incomingMethod = controllerContext.Request.Method; var routeData = controllerContext.RouteData; var candidates = default( CandidateAction[] ); - if ( routeData.Values.TryGetValue( RouteValueKeys.Action, out actionName ) ) + if ( routeData.Values.TryGetValue( RouteValueKeys.Action, out string actionName ) ) { var actionsFoundByName = standardActions.StandardActionNameMapping[actionName].ToArray(); @@ -343,12 +339,12 @@ private CandidateAction[] GetInitialCandidateList( HttpControllerContext control return candidates; } - private static CandidateAction[] FilterIncompatibleVerbs( HttpMethod incomingMethod, CandidateAction[] candidatesFoundByName ) => + static CandidateAction[] FilterIncompatibleVerbs( HttpMethod incomingMethod, CandidateAction[] candidatesFoundByName ) => candidatesFoundByName.Where( c => c.ActionDescriptor.SupportedHttpMethods.Contains( incomingMethod ) ).ToArray(); internal ILookup GetActionMapping() => combinedActionNameMapping; - private static ISet GetCombinedParameterNames( IEnumerable> queryNameValuePairs, IDictionary routeValues ) + static ISet GetCombinedParameterNames( IEnumerable> queryNameValuePairs, IDictionary routeValues ) { Contract.Requires( routeValues != null ); Contract.Ensures( Contract.Result>() != null ); @@ -371,7 +367,7 @@ private static ISet GetCombinedParameterNames( IEnumerable FindActionMatchRequiredRouteAndQueryParameters( IEnumerable candidatesFound ) + List FindActionMatchRequiredRouteAndQueryParameters( IEnumerable candidatesFound ) { Contract.Requires( candidatesFound != null ); Contract.Ensures( Contract.Result>() != null ); @@ -391,10 +387,10 @@ private List FindActionMatchRequiredRouteAndQueryPara return matches; } - private List FindActionMatchMostRouteAndQueryParameters( List candidatesFound ) => + List FindActionMatchMostRouteAndQueryParameters( List candidatesFound ) => candidatesFound.Count < 2 ? candidatesFound : candidatesFound.GroupBy( c => actionParameterNames[c.ActionDescriptor].Length ).OrderByDescending( g => g.Key ).First().ToList(); - private static CandidateActionWithParams[] GetCandidateActionsWithBindings( HttpControllerContext controllerContext, CandidateAction[] candidatesFound ) + static CandidateActionWithParams[] GetCandidateActionsWithBindings( HttpControllerContext controllerContext, CandidateAction[] candidatesFound ) { Contract.Requires( controllerContext != null ); Contract.Requires( candidatesFound != null ); @@ -410,7 +406,7 @@ private static CandidateActionWithParams[] GetCandidateActionsWithBindings( Http return candidatesWithParams; } - private static bool IsSubset( string[] actionParameters, ISet routeAndQueryParameters ) + static bool IsSubset( string[] actionParameters, ISet routeAndQueryParameters ) { Contract.Requires( actionParameters != null ); Contract.Requires( routeAndQueryParameters != null ); @@ -426,7 +422,7 @@ private static bool IsSubset( string[] actionParameters, ISet routeAndQu return true; } - private static List RunOrderFilter( List candidatesFound ) + static List RunOrderFilter( List candidatesFound ) { Contract.Requires( candidatesFound != null ); Contract.Ensures( Contract.Result>() != null ); @@ -441,7 +437,7 @@ private static List RunOrderFilter( List c.CandidateAction.Order == minOrder ).AsList(); } - private static List RunPrecedenceFilter( List candidatesFound ) + static List RunPrecedenceFilter( List candidatesFound ) { Contract.Requires( candidatesFound != null ); Contract.Ensures( Contract.Result>() != null ); @@ -456,7 +452,7 @@ private static List RunPrecedenceFilter( List c.CandidateAction.Precedence == highestPrecedence ).AsList(); } - private static CandidateAction[] FindActionsForVerb( HttpMethod verb, CandidateAction[][] actionsByVerb, CandidateAction[] otherActions ) + static CandidateAction[] FindActionsForVerb( HttpMethod verb, CandidateAction[][] actionsByVerb, CandidateAction[] otherActions ) { Contract.Requires( verb != null ); Contract.Requires( actionsByVerb != null ); @@ -474,7 +470,7 @@ private static CandidateAction[] FindActionsForVerb( HttpMethod verb, CandidateA return FindActionsForVerbWorker( verb, otherActions ); } - private static CandidateAction[] FindActionsForVerbWorker( HttpMethod verb, CandidateAction[] candidates ) + static CandidateAction[] FindActionsForVerbWorker( HttpMethod verb, CandidateAction[] candidates ) { Contract.Requires( verb != null ); Contract.Requires( candidates != null ); @@ -485,7 +481,7 @@ private static CandidateAction[] FindActionsForVerbWorker( HttpMethod verb, Cand return listCandidates.ToArray(); } - private static void FindActionsForVerbWorker( HttpMethod verb, CandidateAction[] candidates, List listCandidates ) + static void FindActionsForVerbWorker( HttpMethod verb, CandidateAction[] candidates, List listCandidates ) { Contract.Requires( verb != null ); Contract.Requires( candidates != null ); @@ -530,7 +526,7 @@ internal static string CreateAmbiguousMatchList( IEnumerable public partial class ApiVersionActionSelector { - private sealed class AggregatedActionMapping : ILookup + sealed class AggregatedActionMapping : ILookup { - private readonly IReadOnlyList> actionMappings; + readonly IReadOnlyList> actionMappings; internal AggregatedActionMapping( IReadOnlyList> actionMappings ) { diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ApiVersionActionSelector.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ApiVersionActionSelector.cs index 1c95bef7..d270cebd 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ApiVersionActionSelector.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/ApiVersionActionSelector.cs @@ -15,10 +15,10 @@ /// public partial class ApiVersionActionSelector : IHttpActionSelector { - private readonly object cacheKey = new object(); - private ActionSelectorCacheItem fastCache; + readonly object cacheKey = new object(); + ActionSelectorCacheItem fastCache; - private ActionSelectorCacheItem GetInternalSelector( HttpControllerDescriptor controllerDescriptor ) + ActionSelectorCacheItem GetInternalSelector( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); Contract.Ensures( Contract.Result() != null ); @@ -35,9 +35,7 @@ private ActionSelectorCacheItem GetInternalSelector( HttpControllerDescriptor co } else { - object cacheValue; - - if ( controllerDescriptor.Properties.TryGetValue( cacheKey, out cacheValue ) ) + if ( controllerDescriptor.Properties.TryGetValue( cacheKey, out var cacheValue ) ) { return (ActionSelectorCacheItem) cacheValue; } @@ -121,7 +119,7 @@ protected virtual HttpActionDescriptor SelectActionVersion( HttpControllerContex return null; } - private Exception CreateAmbiguousActionException( IEnumerable matches ) + Exception CreateAmbiguousActionException( IEnumerable matches ) { var ambiguityList = ActionSelectorCacheItem.CreateAmbiguousMatchList( matches ); return new InvalidOperationException( SR.ApiControllerActionSelector_AmbiguousMatch.FormatDefault( ambiguityList ) ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateActionWithParams.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateActionWithParams.cs index cc1716e5..27684979 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateActionWithParams.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateActionWithParams.cs @@ -1,7 +1,6 @@ namespace Microsoft.Web.Http.Controllers { using Routing; - using System; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -15,7 +14,7 @@ public partial class ApiVersionActionSelector { [DebuggerDisplay( "{DebuggerToString()}" )] - private sealed class CandidateActionWithParams + sealed class CandidateActionWithParams { internal CandidateActionWithParams( CandidateAction candidateAction, ISet parameters, IHttpRouteData routeDataSource ) { @@ -33,7 +32,7 @@ internal CandidateActionWithParams( CandidateAction candidateAction, ISet CandidateAction.ActionDescriptor; [SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called from DebuggerDisplay" )] - private string DebuggerToString() + string DebuggerToString() { var sb = new StringBuilder(); @@ -48,11 +47,12 @@ private string DebuggerToString() foreach ( var param in CombinedParameterNames ) { - sb.AppendFormat( " {0}", param ); + sb.Append( ' ' ); + sb.AppendFormat( param ); } return sb.ToString(); } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateHttpActionDescriptor.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateHttpActionDescriptor.cs index 32d5a84b..5b2cd919 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateHttpActionDescriptor.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/CandidateHttpActionDescriptor.cs @@ -16,7 +16,7 @@ /// public partial class ApiVersionActionSelector { - private sealed class CandidateHttpActionDescriptor : HttpActionDescriptor + sealed class CandidateHttpActionDescriptor : HttpActionDescriptor { internal CandidateHttpActionDescriptor( CandidateActionWithParams action ) { @@ -34,14 +34,8 @@ internal CandidateHttpActionDescriptor( CandidateActionWithParams action ) public override HttpActionBinding ActionBinding { - get - { - return Inner.ActionBinding; - } - set - { - Inner.ActionBinding = value; - } + get => Inner.ActionBinding; + set => Inner.ActionBinding = value; } public override string ActionName => Inner.ActionName; @@ -68,4 +62,4 @@ public override Task ExecuteAsync( HttpControllerContext controllerConte public override Collection SupportedHttpMethods => Inner.SupportedHttpMethods; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorComparer.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorComparer.cs index 2f9c6e8d..f7e138c4 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorComparer.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorComparer.cs @@ -1,20 +1,15 @@ namespace Microsoft.Web.Http.Controllers { - using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; using System.Web.Http.Controllers; - internal sealed class HttpControllerDescriptorComparer : IComparer + sealed class HttpControllerDescriptorComparer : IComparer { - private static readonly Lazy byVersion = new Lazy( () => new HttpControllerDescriptorComparer() ); + HttpControllerDescriptorComparer() { } - private HttpControllerDescriptorComparer() - { - } - - internal static IComparer ByVersion => byVersion.Value; + internal static IComparer ByVersion { get; } = new HttpControllerDescriptorComparer(); public int Compare( HttpControllerDescriptor x, HttpControllerDescriptor y ) { @@ -34,4 +29,4 @@ public int Compare( HttpControllerDescriptor x, HttpControllerDescriptor y ) return v1.CompareTo( v2 ); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorGroup.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorGroup.cs index 55b256b9..46301dc6 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorGroup.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/HttpControllerDescriptorGroup.cs @@ -17,8 +17,8 @@ [SuppressMessage( "Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Justification = "Although the type is a collection, the term 'group' is more meaningful in this context." )] public class HttpControllerDescriptorGroup : HttpControllerDescriptor, IReadOnlyList { - private readonly HttpControllerDescriptor firstDescriptor; - private readonly IReadOnlyList descriptors; + readonly HttpControllerDescriptor firstDescriptor; + readonly IReadOnlyList descriptors; /// /// Initializes a new instance of the class. @@ -181,4 +181,4 @@ public override Collection GetFilters() /// The total number of items in the group. public int Count => descriptors.Count; } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/StandardActionSelectionCache.cs b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/StandardActionSelectionCache.cs index 75189a9a..31240b1f 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Controllers/StandardActionSelectionCache.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Controllers/StandardActionSelectionCache.cs @@ -1,7 +1,6 @@ namespace Microsoft.Web.Http.Controllers { using Routing; - using System; using System.Linq; using System.Web.Http.Controllers; @@ -10,7 +9,7 @@ /// public partial class ApiVersionActionSelector { - private sealed class StandardActionSelectionCache + sealed class StandardActionSelectionCache { internal ILookup StandardActionNameMapping { get; set; } @@ -19,4 +18,4 @@ private sealed class StandardActionSelectionCache internal CandidateAction[][] CacheListVerbs { get; set; } } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerAggregator.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerAggregator.cs index fe24c2a5..234fb014 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerAggregator.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerAggregator.cs @@ -13,13 +13,13 @@ using System.Web.Http.Routing; using Versioning; - internal sealed class ApiVersionControllerAggregator + sealed class ApiVersionControllerAggregator { - private readonly Lazy controllerName; - private readonly Lazy> controllerInfoCache; - private readonly Lazy conventionRouteCandidates; - private readonly Lazy directRouteCandidates; - private readonly Lazy allVersions; + readonly Lazy controllerName; + readonly Lazy> controllerInfoCache; + readonly Lazy conventionRouteCandidates; + readonly Lazy directRouteCandidates; + readonly Lazy allVersions; internal ApiVersionControllerAggregator( HttpRequestMessage request, @@ -38,16 +38,14 @@ internal ApiVersionControllerAggregator( allVersions = new Lazy( AggregateAllCandiateVersions ); } - private HttpControllerDescriptorGroup GetConventionRouteCandidates() + HttpControllerDescriptorGroup GetConventionRouteCandidates() { - var candidates = default( HttpControllerDescriptorGroup ); - if ( string.IsNullOrEmpty( ControllerName ) ) { return null; } - if ( controllerInfoCache.Value.TryGetValue( ControllerName, out candidates ) ) + if ( controllerInfoCache.Value.TryGetValue( ControllerName, out var candidates ) ) { return candidates; } @@ -55,7 +53,7 @@ private HttpControllerDescriptorGroup GetConventionRouteCandidates() return null; } - private ApiVersionModel AggregateAllCandiateVersions() => + ApiVersionModel AggregateAllCandiateVersions() => ( ConventionRouteCandidates ?? Enumerable.Empty() ).Union( EnumerateDirectRoutes() ).AggregateVersions(); internal HttpRequestMessage Request { get; } @@ -76,7 +74,7 @@ private ApiVersionModel AggregateAllCandiateVersions() => internal ApiVersionModel AllVersions => allVersions.Value; - private IEnumerable EnumerateDirectRoutes() + IEnumerable EnumerateDirectRoutes() { Contract.Ensures( Contract.Result>() != null ); @@ -111,18 +109,14 @@ from controller in EnumerateControllersInDataTokens( route.DataTokens ) return controllers.Distinct(); } - private static IEnumerable EnumerateControllersInDataTokens( IDictionary dataTokens ) + static IEnumerable EnumerateControllersInDataTokens( IDictionary dataTokens ) { Contract.Requires( dataTokens != null ); Contract.Ensures( Contract.Result>() != null ); - var value = default( object ); - - if ( dataTokens.TryGetValue( RouteDataTokenKeys.Controller, out value ) ) + if ( dataTokens.TryGetValue( RouteDataTokenKeys.Controller, out var value ) ) { - var controllerDescriptor = value as HttpControllerDescriptor; - - if ( controllerDescriptor != null ) + if ( value is HttpControllerDescriptor controllerDescriptor ) { yield return controllerDescriptor; } @@ -132,16 +126,12 @@ private static IEnumerable EnumerateControllersInDataT if ( dataTokens.TryGetValue( RouteDataTokenKeys.Actions, out value ) ) { - var actionDescriptors = value as HttpActionDescriptor[]; - - if ( actionDescriptors == null ) - { - yield break; - } - - foreach ( var actionDescriptor in actionDescriptors ) + if ( value is HttpActionDescriptor[] actionDescriptors ) { - yield return actionDescriptor.ControllerDescriptor; + foreach ( var actionDescriptor in actionDescriptors ) + { + yield return actionDescriptor.ControllerDescriptor; + } } } } diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerSelector.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerSelector.cs index 18645ba2..37f0b848 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerSelector.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ApiVersionControllerSelector.cs @@ -20,10 +20,10 @@ /// public class ApiVersionControllerSelector : IHttpControllerSelector { - private readonly HttpConfiguration configuration; - private readonly ApiVersioningOptions options; - private readonly HttpControllerTypeCache controllerTypeCache; - private readonly Lazy> controllerInfoCache; + readonly HttpConfiguration configuration; + readonly ApiVersioningOptions options; + readonly HttpControllerTypeCache controllerTypeCache; + readonly Lazy> controllerInfoCache; /// /// Initializes a new instance of the class. @@ -121,13 +121,12 @@ public virtual string GetControllerName( HttpRequestMessage request ) return null; } - object controller; - routeData.Values.TryGetValue( RouteDataTokenKeys.Controller, out controller ); + routeData.Values.TryGetValue( RouteDataTokenKeys.Controller, out string controller ); - return (string) controller; + return controller; } - private ConcurrentDictionary InitializeControllerInfoCache() + ConcurrentDictionary InitializeControllerInfoCache() { var mapping = new ConcurrentDictionary( OrdinalIgnoreCase ); @@ -154,7 +153,7 @@ private ConcurrentDictionary InitializeCo return mapping; } - private static void EnsureRequestHasValidApiVersion( HttpRequestMessage request ) + static void EnsureRequestHasValidApiVersion( HttpRequestMessage request ) { Contract.Requires( request != null ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelectionResult.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelectionResult.cs index 64f9305d..ae5a3dd8 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelectionResult.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelectionResult.cs @@ -3,7 +3,7 @@ using System; using System.Web.Http.Controllers; - internal sealed class ControllerSelectionResult + sealed class ControllerSelectionResult { internal HttpControllerDescriptor Controller { get; set; } diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelector.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelector.cs index 8ad75e75..77beebea 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelector.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ControllerSelector.cs @@ -3,9 +3,9 @@ using System.Diagnostics.Contracts; using Versioning; - internal abstract class ControllerSelector + abstract class ControllerSelector { - private readonly ApiVersioningOptions options; + readonly ApiVersioningOptions options; protected ControllerSelector( ApiVersioningOptions options ) { @@ -19,4 +19,4 @@ protected ControllerSelector( ApiVersioningOptions options ) internal abstract ControllerSelectionResult SelectController( ApiVersionControllerAggregator aggregator ); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ConventionRouteControllerSelector.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ConventionRouteControllerSelector.cs index 9d065221..50d7be9d 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ConventionRouteControllerSelector.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/ConventionRouteControllerSelector.cs @@ -12,12 +12,11 @@ using Versioning; using static System.Environment; - internal sealed class ConventionRouteControllerSelector : ControllerSelector + sealed class ConventionRouteControllerSelector : ControllerSelector { - private readonly HttpControllerTypeCache controllerTypeCache; + readonly HttpControllerTypeCache controllerTypeCache; - internal ConventionRouteControllerSelector( ApiVersioningOptions options, HttpControllerTypeCache controllerTypeCache ) - : base( options ) + internal ConventionRouteControllerSelector( ApiVersioningOptions options, HttpControllerTypeCache controllerTypeCache ) : base( options ) { Contract.Requires( controllerTypeCache != null ); this.controllerTypeCache = controllerTypeCache; @@ -80,7 +79,7 @@ internal override ControllerSelectionResult SelectController( ApiVersionControll return result; } - private static HttpControllerDescriptor GetVersionNeutralController( IEnumerable candidates, Lazy ambiguousException ) + static HttpControllerDescriptor GetVersionNeutralController( IEnumerable candidates, Lazy ambiguousException ) { Contract.Requires( candidates != null ); Contract.Requires( ambiguousException != null ); @@ -110,7 +109,7 @@ private static HttpControllerDescriptor GetVersionNeutralController( IEnumerable return controllerDescriptor; } - private static HttpControllerDescriptor GetVersionedController( ApiVersionControllerAggregator aggregator, ApiVersion requestedVersion, Lazy ambiguousException ) + static HttpControllerDescriptor GetVersionedController( ApiVersionControllerAggregator aggregator, ApiVersion requestedVersion, Lazy ambiguousException ) { Contract.Requires( aggregator != null ); Contract.Requires( requestedVersion != null ); @@ -143,7 +142,7 @@ private static HttpControllerDescriptor GetVersionedController( ApiVersionContro return controller; } - private static HttpControllerDescriptor ResolveController( IEnumerable candidates, ApiVersion requestedVersion, Lazy ambiguousException ) + static HttpControllerDescriptor ResolveController( IEnumerable candidates, ApiVersion requestedVersion, Lazy ambiguousException ) { Contract.Requires( candidates != null ); Contract.Requires( requestedVersion != null ); @@ -173,7 +172,7 @@ private static HttpControllerDescriptor ResolveController( IEnumerable matchingTypes ) + static Exception CreateAmbiguousControllerException( IHttpRoute route, string controllerName, ICollection matchingTypes ) { Contract.Requires( route != null ); Contract.Requires( !string.IsNullOrEmpty( controllerName ) ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/DirectRouteControllerSelector.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/DirectRouteControllerSelector.cs index 0ea7e4bf..55592518 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/DirectRouteControllerSelector.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/DirectRouteControllerSelector.cs @@ -11,12 +11,9 @@ using Versioning; using static System.Environment; - internal sealed class DirectRouteControllerSelector : ControllerSelector + sealed class DirectRouteControllerSelector : ControllerSelector { - internal DirectRouteControllerSelector( ApiVersioningOptions options ) - : base( options ) - { - } + internal DirectRouteControllerSelector( ApiVersioningOptions options ) : base( options ) { } internal override ControllerSelectionResult SelectController( ApiVersionControllerAggregator aggregator ) { @@ -72,7 +69,7 @@ internal override ControllerSelectionResult SelectController( ApiVersionControll return result; } - private static HttpControllerDescriptor GetVersionNeutralController( CandidateAction[] directRouteCandidates ) + static HttpControllerDescriptor GetVersionNeutralController( CandidateAction[] directRouteCandidates ) { Contract.Requires( directRouteCandidates != null ); Contract.Requires( directRouteCandidates.Length > 0 ); @@ -102,7 +99,7 @@ private static HttpControllerDescriptor GetVersionNeutralController( CandidateAc return controllerDescriptor; } - private static HttpControllerDescriptor GetVersionedController( ApiVersionControllerAggregator aggregator, ApiVersion requestedVersion ) + static HttpControllerDescriptor GetVersionedController( ApiVersionControllerAggregator aggregator, ApiVersion requestedVersion ) { Contract.Requires( aggregator != null ); Contract.Requires( requestedVersion != null ); @@ -133,7 +130,7 @@ private static HttpControllerDescriptor GetVersionedController( ApiVersionContro return controller; } - private static HttpControllerDescriptor ResolveController( CandidateAction[] directRouteCandidates, ApiVersion requestedVersion ) + static HttpControllerDescriptor ResolveController( CandidateAction[] directRouteCandidates, ApiVersion requestedVersion ) { Contract.Requires( directRouteCandidates != null ); Contract.Requires( directRouteCandidates.Length > 0 ); @@ -166,10 +163,10 @@ where controller.GetDeclaredApiVersions().Contains( requestedVersion ) return controllerDescriptor; } - private static Exception CreateAmbiguousControllerException( CandidateAction[] candidates ) => + static Exception CreateAmbiguousControllerException( CandidateAction[] candidates ) => CreateAmbiguousControllerException( candidates.Select( c => c.ActionDescriptor.ControllerDescriptor ) ); - private static Exception CreateAmbiguousControllerException( IEnumerable candidates ) + static Exception CreateAmbiguousControllerException( IEnumerable candidates ) { Contract.Requires( candidates != null ); Contract.Ensures( Contract.Result() != null ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpControllerTypeCache.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpControllerTypeCache.cs index 49c0f0c5..7c80ad77 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpControllerTypeCache.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpControllerTypeCache.cs @@ -8,10 +8,10 @@ using System.Web.Http; using System.Web.Http.Dispatcher; - internal sealed class HttpControllerTypeCache + sealed class HttpControllerTypeCache { - private readonly HttpConfiguration configuration; - private readonly Lazy>> cache; + readonly HttpConfiguration configuration; + readonly Lazy>> cache; internal HttpControllerTypeCache( HttpConfiguration configuration ) { @@ -21,7 +21,7 @@ internal HttpControllerTypeCache( HttpConfiguration configuration ) cache = new Lazy>>( InitializeCache ); } - private static string GetControllerName( Type type ) + static string GetControllerName( Type type ) { Contract.Requires( type != null ); Contract.Ensures( !string.IsNullOrEmpty( Contract.Result() ) ); @@ -43,7 +43,7 @@ private static string GetControllerName( Type type ) return name.Substring( 0, name.Length - suffixLength ); } - private Dictionary> InitializeCache() + Dictionary> InitializeCache() { Contract.Ensures( Contract.Result>>() != null ); @@ -57,14 +57,7 @@ private Dictionary> InitializeCache() .ToDictionary( g => g.Key, g => g.ToLookup( t => t.Namespace ?? string.Empty, comparer ), comparer ); } - internal Dictionary> Cache - { - get - { - Contract.Ensures( Contract.Result>>() != null ); - return cache.Value; - } - } + internal Dictionary> Cache => cache.Value; internal ICollection GetControllerTypes( string controllerName ) { @@ -72,9 +65,8 @@ internal ICollection GetControllerTypes( string controllerName ) Contract.Ensures( Contract.Result>() != null ); var set = new HashSet(); - ILookup lookup; - if ( cache.Value.TryGetValue( controllerName, out lookup ) ) + if ( cache.Value.TryGetValue( controllerName, out var lookup ) ) { foreach ( var grouping in lookup ) { @@ -85,4 +77,4 @@ internal ICollection GetControllerTypes( string controllerName ) return set; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpResponseExceptionFactory.cs b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpResponseExceptionFactory.cs index 431a5d26..7ee5835d 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpResponseExceptionFactory.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Dispatcher/HttpResponseExceptionFactory.cs @@ -1,13 +1,11 @@ namespace Microsoft.Web.Http.Dispatcher { - using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Linq; using System.Net.Http; using System.Web.Http; - using System.Web.Http.Controllers; using System.Web.Http.Dispatcher; using System.Web.Http.Tracing; using Versioning; @@ -15,11 +13,11 @@ using static System.Net.HttpStatusCode; using static System.String; - internal sealed class HttpResponseExceptionFactory + sealed class HttpResponseExceptionFactory { const string Allow = nameof( Allow ); - private static readonly string ControllerSelectorCategory = typeof( IHttpControllerSelector ).FullName; - private readonly HttpRequestMessage request; + static readonly string ControllerSelectorCategory = typeof( IHttpControllerSelector ).FullName; + readonly HttpRequestMessage request; internal HttpResponseExceptionFactory( HttpRequestMessage request ) { @@ -27,9 +25,9 @@ internal HttpResponseExceptionFactory( HttpRequestMessage request ) this.request = request; } - private ITraceWriter TraceWriter => request.GetConfiguration().Services.GetTraceWriter() ?? NullTraceWriter.Instance; + ITraceWriter TraceWriter => request.GetConfiguration().Services.GetTraceWriter() ?? NullTraceWriter.Instance; - private ApiVersioningOptions Options => request.GetApiVersioningOptions(); + ApiVersioningOptions Options => request.GetApiVersioningOptions(); [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Created exception cannot be disposed. Handled by the caller." )] internal HttpResponseException NewNotFoundOrBadRequestException( ControllerSelectionResult conventionRouteResult, ControllerSelectionResult directRouteResult ) => @@ -44,7 +42,7 @@ internal HttpResponseMessage CreateBadRequestResponse( ApiVersion requestedVersi internal HttpResponseException CreateBadRequest( ApiVersion requestedVersion ) => new HttpResponseException( CreateBadRequestResponse( requestedVersion ) ); [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Created exception cannot be disposed. Handled by the caller." )] - private HttpResponseException CreateBadRequest( ControllerSelectionResult conventionRouteResult, ControllerSelectionResult directRouteResult ) + HttpResponseException CreateBadRequest( ControllerSelectionResult conventionRouteResult, ControllerSelectionResult directRouteResult ) { Contract.Requires( conventionRouteResult != null ); @@ -67,10 +65,9 @@ private HttpResponseException CreateBadRequest( ControllerSelectionResult conven } [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Created exception cannot be disposed. Handled by the caller." )] - private HttpResponseMessage CreateBadRequestForUnspecifiedApiVersionOrInvalidApiVersion( bool versionNeutral ) + HttpResponseMessage CreateBadRequestForUnspecifiedApiVersionOrInvalidApiVersion( bool versionNeutral ) { var requestedVersion = request.ApiVersionProperties().RawApiVersion; - var parsedVersion = default( ApiVersion ); var message = default( string ); var context = default( ErrorResponseContext ); @@ -86,7 +83,7 @@ private HttpResponseMessage CreateBadRequestForUnspecifiedApiVersionOrInvalidApi context = new ErrorResponseContext( request, "ApiVersionUnspecified", message, messageDetail: null ); return Options.ErrorResponses.BadRequest( context ); } - else if ( TryParse( requestedVersion, out parsedVersion ) ) + else if ( TryParse( requestedVersion, out var parsedVersion ) ) { return null; } @@ -101,7 +98,7 @@ private HttpResponseMessage CreateBadRequestForUnspecifiedApiVersionOrInvalidApi } [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Created exception cannot be disposed. Handled by the caller." )] - private HttpResponseMessage CreateBadRequestForUnsupportedApiVersion( ApiVersion requestedVersion ) + HttpResponseMessage CreateBadRequestForUnsupportedApiVersion( ApiVersion requestedVersion ) { Contract.Requires( requestedVersion != null ); Contract.Ensures( Contract.Result() != null ); @@ -170,7 +167,7 @@ internal HttpResponseException NewMethodNotAllowedException( bool versionNeutral new HttpResponseException( CreateMethodNotAllowedResponse( versionNeutral, allowedMethods ) ); [SuppressMessage( "Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Created exception cannot be disposed. Handled by the caller." )] - private HttpResponseException CreateNotFound( ControllerSelectionResult conventionRouteResult ) + HttpResponseException CreateNotFound( ControllerSelectionResult conventionRouteResult ) { Contract.Requires( conventionRouteResult != null ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.csproj b/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.csproj new file mode 100644 index 00000000..ded8458a --- /dev/null +++ b/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.csproj @@ -0,0 +1,44 @@ + + + + 2.0.3 + 2.0.3.0 + net45 + Microsoft.AspNet.WebApi.Versioning + Microsoft ASP.NET Web API Versioning + A service API versioning library for Microsoft ASP.NET Web API. + Microsoft.Web.Http + $(DefineConstants);WEBAPI + Microsoft;AspNet;AspNetWebAPI;Versioning + • Fixed responses when a version is unspecified (Issue #62) + + + + + + + + + + + + + + True + True + SR.resx + + + + + + ResXFileCodeGenerator + SR.Designer.cs + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.xproj b/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.xproj deleted file mode 100644 index 7a805e85..00000000 --- a/src/Microsoft.AspNet.WebApi.Versioning/Microsoft.AspNet.WebApi.Versioning.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 3bac97ed-1a8e-4f5a-a716-db5255f51c81 - Microsoft.Web.Http - .\obj - .\bin\ - v4.5 - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/NullTraceWriter.cs b/src/Microsoft.AspNet.WebApi.Versioning/NullTraceWriter.cs index 8217bed7..7fd0d632 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/NullTraceWriter.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/NullTraceWriter.cs @@ -4,16 +4,12 @@ using System.Net.Http; using System.Web.Http.Tracing; - internal sealed class NullTraceWriter : ITraceWriter + sealed class NullTraceWriter : ITraceWriter { - private NullTraceWriter() - { - } + NullTraceWriter() { } internal static ITraceWriter Instance { get; } = new NullTraceWriter(); - public void Trace( HttpRequestMessage request, string category, TraceLevel level, Action traceAction ) - { - } + public void Trace( HttpRequestMessage request, string category, TraceLevel level, Action traceAction ) { } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Properties/AssemblyInfo.cs b/src/Microsoft.AspNet.WebApi.Versioning/Properties/AssemblyInfo.cs deleted file mode 100644 index 94e5b94e..00000000 --- a/src/Microsoft.AspNet.WebApi.Versioning/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyProduct( "Microsoft.AspNet.WebApi.Versioning" )] \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/ReportApiVersionsAttribute.cs b/src/Microsoft.AspNet.WebApi.Versioning/ReportApiVersionsAttribute.cs index 50673b5c..b84d844b 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/ReportApiVersionsAttribute.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/ReportApiVersionsAttribute.cs @@ -44,7 +44,7 @@ public override void OnActionExecuted( HttpActionExecutedContext actionExecutedC AddApiVersionHeader( headers, ApiDeprecatedVersions, model.DeprecatedApiVersions ); } - private static void AddApiVersionHeader( HttpHeaders headers, string headerName, IReadOnlyList versions ) + static void AddApiVersionHeader( HttpHeaders headers, string headerName, IReadOnlyList versions ) { Contract.Requires( headers != null ); Contract.Requires( !IsNullOrEmpty( headerName ) ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Routing/ApiVersionRouteConstraint.cs b/src/Microsoft.AspNet.WebApi.Versioning/Routing/ApiVersionRouteConstraint.cs index 48ebe2b0..5cf5db1e 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Routing/ApiVersionRouteConstraint.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Routing/ApiVersionRouteConstraint.cs @@ -29,10 +29,9 @@ public bool Match( HttpRequestMessage request, IHttpRoute route, string paramete return false; } - var value = default( string ); var properties = request.ApiVersionProperties(); - if ( values.TryGetValue( parameterName, out value ) ) + if ( values.TryGetValue( parameterName, out string value ) ) { properties.RouteParameterName = parameterName; } @@ -46,9 +45,7 @@ public bool Match( HttpRequestMessage request, IHttpRoute route, string paramete return !IsNullOrEmpty( value ); } - var requestedVersion = default( ApiVersion ); - - if ( TryParse( value, out requestedVersion ) ) + if ( TryParse( value, out var requestedVersion ) ) { properties.ApiVersion = requestedVersion; return true; diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Routing/CandidateAction.cs b/src/Microsoft.AspNet.WebApi.Versioning/Routing/CandidateAction.cs index de98aea3..0811f09d 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Routing/CandidateAction.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Routing/CandidateAction.cs @@ -1,6 +1,5 @@ namespace Microsoft.Web.Http.Routing { - using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; @@ -9,14 +8,12 @@ using static System.StringComparison; [DebuggerDisplay( "{DebuggerToString()}" )] - internal class CandidateAction + sealed class CandidateAction { - private const string DebugFormat = "{0}, Order={1}, Prec={2}"; + const string DebugFormat = "{0}, Order={1}, Prec={2}"; internal CandidateAction( HttpActionDescriptor actionDescriptor ) - : this( actionDescriptor, default( int ), default( decimal ) ) - { - } + : this( actionDescriptor, default( int ), default( decimal ) ) { } internal CandidateAction( HttpActionDescriptor actionDescriptor, int order, decimal precedence ) { @@ -42,4 +39,4 @@ internal CandidateAction( HttpActionDescriptor actionDescriptor, int order, deci public decimal Precedence { get; set; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteDataTokenKeys.cs b/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteDataTokenKeys.cs index 9fad7c26..37b77b54 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteDataTokenKeys.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteDataTokenKeys.cs @@ -5,26 +5,26 @@ /// /// Provides keys for looking up route values and data tokens. /// - internal static class RouteDataTokenKeys + static class RouteDataTokenKeys { /// /// Used to provide the action descriptors to consider for attribute routing. /// - public const string Actions = "actions"; + internal const string Actions = "actions"; /// /// Used to indicate that a route is a controller-level attribute route. /// - public const string Controller = "controller"; + internal const string Controller = "controller"; /// /// Used to allow customer-provided disambiguation between multiple matching attribute routes /// - public const string Order = "order"; + internal const string Order = "order"; /// /// Used to allow URI constraint-based disambiguation between multiple matching attribute routes /// - public const string Precedence = "precedence"; + internal const string Precedence = "precedence"; } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteValueKeys.cs b/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteValueKeys.cs index ce3876e3..c96120b3 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteValueKeys.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Routing/RouteValueKeys.cs @@ -5,16 +5,16 @@ /// /// Provides keys for looking up route values. /// - internal static class RouteValueKeys + static class RouteValueKeys { /// /// Used to provide the action name. /// - public const string Action = "action"; + internal const string Action = "action"; /// /// Used to provide the controller name. /// - public const string Controller = "controller"; + internal const string Controller = "controller"; } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/SR.Designer.cs b/src/Microsoft.AspNet.WebApi.Versioning/SR.Designer.cs index da5863e7..b83859d5 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/SR.Designer.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/SR.Designer.cs @@ -10,16 +10,16 @@ namespace Microsoft.Web.Http { using System; - using System.Reflection; /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class SR { @@ -28,17 +28,18 @@ internal class SR { private static global::System.Globalization.CultureInfo resourceCulture; + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SR() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.WebApi.Versioning.SR", typeof(SR).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Web.Http.SR", typeof(SR).Assembly); resourceMan = temp; } return resourceMan; @@ -46,8 +47,8 @@ internal SR() { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -60,7 +61,7 @@ internal SR() { } /// - /// Looks up a localized string similar to {0} on type {1}. + /// Looks up a localized string similar to {0} on type {1}. /// internal static string ActionSelector_AmbiguousMatchType { get { @@ -69,7 +70,7 @@ internal static string ActionSelector_AmbiguousMatchType { } /// - /// Looks up a localized string similar to No action was found on the controller '{0}' that matches the name '{1}'.. + /// Looks up a localized string similar to No action was found on the controller '{0}' that matches the name '{1}'.. /// internal static string ApiControllerActionSelector_ActionNameNotFound { get { @@ -78,7 +79,7 @@ internal static string ApiControllerActionSelector_ActionNameNotFound { } /// - /// Looks up a localized string similar to No action was found on the controller '{0}' that matches the request.. + /// Looks up a localized string similar to No action was found on the controller '{0}' that matches the request.. /// internal static string ApiControllerActionSelector_ActionNotFound { get { @@ -87,7 +88,7 @@ internal static string ApiControllerActionSelector_ActionNotFound { } /// - /// Looks up a localized string similar to Multiple actions were found that match the request: {0}. + /// Looks up a localized string similar to Multiple actions were found that match the request: {0}. /// internal static string ApiControllerActionSelector_AmbiguousMatch { get { @@ -96,7 +97,7 @@ internal static string ApiControllerActionSelector_AmbiguousMatch { } /// - /// Looks up a localized string similar to The requested resource does not support HTTP method '{0}'.. + /// Looks up a localized string similar to The requested resource does not support HTTP method '{0}'.. /// internal static string ApiControllerActionSelector_HttpMethodNotSupported { get { @@ -105,7 +106,7 @@ internal static string ApiControllerActionSelector_HttpMethodNotSupported { } /// - /// Looks up a localized string similar to The specified API group version '{0}' is invalid.. + /// Looks up a localized string similar to The specified API group version '{0}' is invalid.. /// internal static string ApiVersionBadGroupVersion { get { @@ -114,7 +115,7 @@ internal static string ApiVersionBadGroupVersion { } /// - /// Looks up a localized string similar to The specified API version status '{0}' is invalid.. + /// Looks up a localized string similar to The specified API version status '{0}' is invalid.. /// internal static string ApiVersionBadStatus { get { @@ -123,7 +124,7 @@ internal static string ApiVersionBadStatus { } /// - /// Looks up a localized string similar to The specified API version is invalid.. + /// Looks up a localized string similar to The specified API version is invalid.. /// internal static string ApiVersionInvalidFormat { get { @@ -132,7 +133,7 @@ internal static string ApiVersionInvalidFormat { } /// - /// Looks up a localized string similar to The format '{0}' is invalid or not supported.. + /// Looks up a localized string similar to The format '{0}' is invalid or not supported.. /// internal static string ApiVersionInvalidFormatCode { get { @@ -141,7 +142,7 @@ internal static string ApiVersionInvalidFormatCode { } /// - /// Looks up a localized string similar to The requested API version '{0}' is not supported.. + /// Looks up a localized string similar to The requested API version '{0}' is not supported.. /// internal static string ApiVersionNotSupported { get { @@ -150,7 +151,7 @@ internal static string ApiVersionNotSupported { } /// - /// Looks up a localized string similar to An API version is required, but was not specified.. + /// Looks up a localized string similar to An API version is required, but was not specified.. /// internal static string ApiVersionUnspecified { get { @@ -159,7 +160,7 @@ internal static string ApiVersionUnspecified { } /// - /// Looks up a localized string similar to No route providing a controller name was found to match request URI '{0}'.. + /// Looks up a localized string similar to No route providing a controller name was found to match request URI '{0}'.. /// internal static string ControllerNameNotFound { get { @@ -168,7 +169,7 @@ internal static string ControllerNameNotFound { } /// - /// Looks up a localized string similar to Multiple types were found that match the controller named '{0}'. This can happen if the route that services this request ('{1}') found multiple controllers defined with the same name but differing namespaces, which is not supported.{3}{3}The request for '{0}' has found the following matching controllers:{2}. + /// Looks up a localized string similar to Multiple types were found that match the controller named '{0}'. This can happen if the route that services this request ('{1}') found multiple controllers defined with the same name but differing namespaces, which is not supported.{3}{3}The request for '{0}' has found the following matching controllers:{2}. /// internal static string DefaultControllerFactory_ControllerNameAmbiguous_WithRouteTemplate { get { @@ -177,7 +178,7 @@ internal static string DefaultControllerFactory_ControllerNameAmbiguous_WithRout } /// - /// Looks up a localized string similar to No type was found that matches the controller named '{0}'.. + /// Looks up a localized string similar to No type was found that matches the controller named '{0}'.. /// internal static string DefaultControllerFactory_ControllerNameNotFound { get { @@ -186,7 +187,7 @@ internal static string DefaultControllerFactory_ControllerNameNotFound { } /// - /// Looks up a localized string similar to Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL.{1}{1}The request has found the following matching controller types: {0}. + /// Looks up a localized string similar to Multiple controller types were found that match the URL. This can happen if attribute routes on multiple controllers match the requested URL.{1}{1}The request has found the following matching controller types: {0}. /// internal static string DirectRoute_AmbiguousController { get { @@ -195,7 +196,7 @@ internal static string DirectRoute_AmbiguousController { } /// - /// Looks up a localized string similar to The expression '{0}' must refer to a controller action method.. + /// Looks up a localized string similar to The expression '{0}' must refer to a controller action method.. /// internal static string InvalidActionMethodExpression { get { @@ -204,7 +205,7 @@ internal static string InvalidActionMethodExpression { } /// - /// Looks up a localized string similar to The following API versions were requested: {0}. At most, only a single API version may be specified. Please update the intended API version and retry the request.. + /// Looks up a localized string similar to The following API versions were requested: {0}. At most, only a single API version may be specified. Please update the intended API version and retry the request.. /// internal static string MultipleDifferentApiVersionsRequested { get { @@ -213,7 +214,7 @@ internal static string MultipleDifferentApiVersionsRequested { } /// - /// Looks up a localized string similar to No HTTP resource was found that matches the request URI '{0}'.. + /// Looks up a localized string similar to No HTTP resource was found that matches the request URI '{0}'.. /// internal static string ResourceNotFound { get { @@ -222,7 +223,7 @@ internal static string ResourceNotFound { } /// - /// Looks up a localized string similar to No route providing a controller name with API version '{2}' was found to match HTTP method '{1}' and request URI '{0}'.. + /// Looks up a localized string similar to No route providing a controller name with API version '{2}' was found to match HTTP method '{1}' and request URI '{0}'.. /// internal static string VersionedActionNameNotFound { get { @@ -231,7 +232,7 @@ internal static string VersionedActionNameNotFound { } /// - /// Looks up a localized string similar to No route providing a controller name with API version '{1}' was found to match request URI '{0}'.. + /// Looks up a localized string similar to No route providing a controller name with API version '{1}' was found to match request URI '{0}'.. /// internal static string VersionedControllerNameNotFound { get { @@ -240,7 +241,7 @@ internal static string VersionedControllerNameNotFound { } /// - /// Looks up a localized string similar to The requested resource with API version '{0}' does not support HTTP method '{1}'.. + /// Looks up a localized string similar to The requested resource with API version '{0}' does not support HTTP method '{1}'.. /// internal static string VersionedMethodNotSupported { get { @@ -249,7 +250,7 @@ internal static string VersionedMethodNotSupported { } /// - /// Looks up a localized string similar to The HTTP resource that matches the request URI '{0}' does not support the API version '{1}'.. + /// Looks up a localized string similar to The HTTP resource that matches the request URI '{0}' does not support the API version '{1}'.. /// internal static string VersionedResourceNotSupported { get { @@ -258,7 +259,7 @@ internal static string VersionedResourceNotSupported { } /// - /// Looks up a localized string similar to At least one IApiVersionReader must be specified.. + /// Looks up a localized string similar to At least one IApiVersionReader must be specified.. /// internal static string ZeroApiVersionReaders { get { diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpActionDescriptorExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpActionDescriptorExtensions.cs index 5d3af462..34cae3ec 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpActionDescriptorExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpActionDescriptorExtensions.cs @@ -13,15 +13,14 @@ /// public static class HttpActionDescriptorExtensions { - private const string AttributeRoutedPropertyKey = "MS_IsAttributeRouted"; - private const string ApiVersionInfoKey = "MS_ApiVersionInfo"; + const string AttributeRoutedPropertyKey = "MS_IsAttributeRouted"; + const string ApiVersionInfoKey = "MS_ApiVersionInfo"; internal static bool IsAttributeRouted( this HttpActionDescriptor actionDescriptor ) { Contract.Requires( actionDescriptor != null ); - var value = default( bool? ); - actionDescriptor.Properties.TryGetValue( AttributeRoutedPropertyKey, out value ); + actionDescriptor.Properties.TryGetValue( AttributeRoutedPropertyKey, out bool? value ); return value ?? false; } @@ -57,4 +56,4 @@ internal static void SetApiVersionModel( this HttpActionDescriptor actionDescrip /// declared by the action. public static IReadOnlyList GetApiVersions( this HttpActionDescriptor actionDescriptor ) => actionDescriptor.GetApiVersionModel().DeclaredApiVersions; } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpConfigurationExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpConfigurationExtensions.cs index 79b88d2d..a0e20df2 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpConfigurationExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpConfigurationExtensions.cs @@ -15,7 +15,7 @@ /// public static class HttpConfigurationExtensions { - private const string ApiVersioningOptionsKey = "MS_ApiVersioningOptions"; + const string ApiVersioningOptionsKey = "MS_ApiVersioningOptions"; /// /// Gets the current API versioning options. @@ -27,8 +27,7 @@ public static ApiVersioningOptions GetApiVersioningOptions( this HttpConfigurati Arg.NotNull( configuration, nameof( configuration ) ); Contract.Ensures( Contract.Result() != null ); - var options = default( ApiVersioningOptions ); - return configuration.Properties.TryGetValue( ApiVersioningOptionsKey, out options ) ? options : new ApiVersioningOptions(); + return configuration.Properties.TryGetValue( ApiVersioningOptionsKey, out ApiVersioningOptions options ) ? options : new ApiVersioningOptions(); } /// diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpControllerDescriptorExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpControllerDescriptorExtensions.cs index c6b3cb58..019b7ffe 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpControllerDescriptorExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpControllerDescriptorExtensions.cs @@ -14,10 +14,10 @@ /// public static class HttpControllerDescriptorExtensions { - private const string AttributeRoutedPropertyKey = "MS_IsAttributeRouted"; - private const string ApiVersionInfoKey = "MS_ApiVersionInfo"; - private const string ConventionsApiVersionInfoKey = "MS_ConventionsApiVersionInfo"; - private const string RelatedControllerCandidatesKey = "MS_RelatedControllerCandidates"; + const string AttributeRoutedPropertyKey = "MS_IsAttributeRouted"; + const string ApiVersionInfoKey = "MS_ApiVersionInfo"; + const string ConventionsApiVersionInfoKey = "MS_ConventionsApiVersionInfo"; + const string RelatedControllerCandidatesKey = "MS_RelatedControllerCandidates"; internal static bool IsAttributeRouted( this HttpControllerDescriptor controllerDescriptor ) { @@ -66,9 +66,8 @@ public static ApiVersionModel GetApiVersionModel( this HttpControllerDescriptor Contract.Ensures( Contract.Result() != null ); var properties = controllerDescriptor.Properties; - var versionInfo = default( ApiVersionModel ); - if ( properties.TryGetValue( ApiVersionInfoKey, out versionInfo ) ) + if ( properties.TryGetValue( ApiVersionInfoKey, out ApiVersionModel versionInfo ) ) { return versionInfo; } @@ -112,9 +111,7 @@ internal static void SetRelatedCandidates( this HttpControllerDescriptor control internal static IEnumerable AsEnumerable( this HttpControllerDescriptor controllerDescriptor ) { - IEnumerable relatedCandidates; - - if ( controllerDescriptor.Properties.TryGetValue( RelatedControllerCandidatesKey, out relatedCandidates ) ) + if ( controllerDescriptor.Properties.TryGetValue( RelatedControllerCandidatesKey, out IEnumerable relatedCandidates ) ) { using ( var relatedControllerDescriptors = relatedCandidates.GetEnumerator() ) { @@ -136,19 +133,17 @@ internal static IEnumerable AsEnumerable( this HttpCon } } - var groupedControllerDescriptors = controllerDescriptor as IEnumerable; - - if ( groupedControllerDescriptors == null ) - { - yield return controllerDescriptor; - } - else + if ( controllerDescriptor is IEnumerable groupedControllerDescriptors ) { foreach ( var groupedControllerDescriptor in groupedControllerDescriptors ) { yield return groupedControllerDescriptor; } } + else + { + yield return controllerDescriptor; + } } /// @@ -196,4 +191,4 @@ internal static IEnumerable AsEnumerable( this HttpCon /// controller would no longer indicate that it is an implemented version. public static IReadOnlyList GetDeprecatedApiVersions( this HttpControllerDescriptor controllerDescriptor ) => controllerDescriptor.GetApiVersionModel().DeprecatedApiVersions; } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpParameterBindingExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpParameterBindingExtensions.cs index b3961c58..90f7aa97 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpParameterBindingExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpParameterBindingExtensions.cs @@ -6,7 +6,7 @@ using ModelBinding; using ValueProviders; - internal static class HttpParameterBindingExtensions + static class HttpParameterBindingExtensions { internal static bool WillReadUri( this HttpParameterBinding parameterBinding ) { @@ -29,4 +29,4 @@ internal static bool WillReadUri( this HttpParameterBinding parameterBinding ) return false; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteDataExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteDataExtensions.cs index 6187d8a8..dbc159d8 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteDataExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteDataExtensions.cs @@ -5,7 +5,7 @@ using Microsoft.Web.Http.Routing; using Routing; - internal static class HttpRouteDataExtensions + static class HttpRouteDataExtensions { internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRouteData routeData ) { @@ -38,4 +38,4 @@ internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRouteData return list.ToArray(); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteExtensions.cs b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteExtensions.cs index 1f999397..54280664 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteExtensions.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/System.Web.Http/HttpRouteExtensions.cs @@ -7,7 +7,7 @@ using Microsoft.Web.Http.Routing; using Routing; - internal static class HttpRouteExtensions + static class HttpRouteExtensions { internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRoute route ) { @@ -22,9 +22,8 @@ internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRoute rout var candidates = new List(); var directRouteActions = default( HttpActionDescriptor[] ); - var possibleDirectRouteActions = default( HttpActionDescriptor[] ); - if ( dataTokens.TryGetValue( RouteDataTokenKeys.Actions, out possibleDirectRouteActions ) ) + if ( dataTokens.TryGetValue( RouteDataTokenKeys.Actions, out HttpActionDescriptor[] possibleDirectRouteActions ) ) { if ( possibleDirectRouteActions != null && possibleDirectRouteActions.Length > 0 ) { @@ -37,20 +36,14 @@ internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRoute rout return null; } - var order = 0; - var possibleOrder = 0; - - if ( dataTokens.TryGetValue( RouteDataTokenKeys.Order, out possibleOrder ) ) + if ( !dataTokens.TryGetValue( RouteDataTokenKeys.Order, out int order ) ) { - order = possibleOrder; + order = 0; } - var precedence = 0m; - var possiblePrecedence = 0m; - - if ( dataTokens.TryGetValue( RouteDataTokenKeys.Precedence, out possiblePrecedence ) ) + if ( !dataTokens.TryGetValue( RouteDataTokenKeys.Precedence, out decimal precedence ) ) { - precedence = possiblePrecedence; + precedence = 0m; } foreach ( var actionDescriptor in directRouteActions ) @@ -61,4 +54,4 @@ internal static CandidateAction[] GetDirectRouteCandidates( this IHttpRoute rout return candidates.ToArray(); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/ApiVersionModel.cs b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/ApiVersionModel.cs index 025dc6b9..59e522bd 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/ApiVersionModel.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/ApiVersionModel.cs @@ -12,7 +12,7 @@ /// public sealed partial class ApiVersionModel { - private ApiVersionModel() + ApiVersionModel() { declaredVersions = defaultVersions; implementedVersions = defaultVersions; @@ -89,7 +89,7 @@ public ApiVersionModel( HttpActionDescriptor actionDescriptor ) } } - private static IReadOnlyList GetDeclaredControllerApiVersions( HttpControllerDescriptor controllerDescriptor ) + static IReadOnlyList GetDeclaredControllerApiVersions( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); Contract.Ensures( Contract.Result>() != null ); @@ -104,7 +104,7 @@ private static IReadOnlyList GetDeclaredControllerApiVersions( HttpC return versions; } - private static IReadOnlyList GetSupportedControllerApiVersions( HttpControllerDescriptor controllerDescriptor ) + static IReadOnlyList GetSupportedControllerApiVersions( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); Contract.Ensures( Contract.Result>() != null ); diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs index 4a1ec66b..07880225 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ActionApiVersionConventionBuilderCollectionT.cs @@ -9,7 +9,7 @@ /// The type of controller. public partial class ActionApiVersionConventionBuilderCollection where T : IHttpController { - private sealed partial class ActionBuilderMapping where TModel : IHttpController + sealed partial class ActionBuilderMapping where TModel : IHttpController { } } diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs index 926c14c4..9b85a721 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs @@ -33,9 +33,8 @@ public virtual ControllerApiVersionConventionBuilder Controller>() != null ); var key = typeof( TController ); - var convention = default( IApiVersionConvention ); - if ( !ControllerConventions.TryGetValue( key, out convention ) ) + if ( !ControllerConventions.TryGetValue( key, out var convention ) ) { var typedConvention = new ControllerApiVersionConventionBuilder(); ControllerConventions[key] = typedConvention; @@ -57,9 +56,8 @@ public virtual bool ApplyTo( HttpControllerDescriptor controllerDescriptor ) Arg.NotNull( controllerDescriptor, nameof( controllerDescriptor ) ); var key = controllerDescriptor.ControllerType; - var convention = default( IApiVersionConvention ); - if ( ControllerConventions.TryGetValue( key, out convention ) ) + if ( ControllerConventions.TryGetValue( key, out var convention ) ) { convention.ApplyTo( controllerDescriptor ); return true; diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs index 1196fa2e..ec498fed 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs @@ -29,7 +29,7 @@ public void ApplyTo( HttpControllerDescriptor controllerDescriptor ) } } - private void ApplyControllerConventions( HttpControllerDescriptor controllerDescriptor ) + void ApplyControllerConventions( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); @@ -38,7 +38,7 @@ private void ApplyControllerConventions( HttpControllerDescriptor controllerDesc controllerDescriptor.SetConventionsApiVersionModel( model ); } - private void MergeAttributesWithConventions( HttpControllerDescriptor controllerDescriptor ) + void MergeAttributesWithConventions( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); @@ -75,7 +75,7 @@ from version in provider.Versions select version ); } - private void ApplyActionConventions( HttpControllerDescriptor controllerDescriptor ) + void ApplyActionConventions( HttpControllerDescriptor controllerDescriptor ) { Contract.Requires( controllerDescriptor != null ); @@ -85,9 +85,8 @@ private void ApplyActionConventions( HttpControllerDescriptor controllerDescript foreach ( var actionDescriptor in actionDescriptors ) { var key = actionDescriptor.MethodInfo; - var actionBuilder = default( ActionApiVersionConventionBuilder ); - if ( ActionBuilders.TryGetValue( key, out actionBuilder ) ) + if ( ActionBuilders.TryGetValue( key, out var actionBuilder ) ) { actionBuilder.ApplyTo( actionDescriptor ); } diff --git a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/MediaTypeApiVersionReader.cs b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/MediaTypeApiVersionReader.cs index c53f163e..7e07cdfa 100644 --- a/src/Microsoft.AspNet.WebApi.Versioning/Versioning/MediaTypeApiVersionReader.cs +++ b/src/Microsoft.AspNet.WebApi.Versioning/Versioning/MediaTypeApiVersionReader.cs @@ -1,10 +1,6 @@ namespace Microsoft.Web.Http.Versioning { - using System; - using System.Collections.Generic; - using System.Linq; using System.Net.Http; - using System.Net.Http.Headers; /// /// Provides the implementation for ASP.NET Web API. diff --git a/src/Microsoft.AspNet.WebApi.Versioning/project.json b/src/Microsoft.AspNet.WebApi.Versioning/project.json deleted file mode 100644 index d4696b3a..00000000 --- a/src/Microsoft.AspNet.WebApi.Versioning/project.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "version": "2.0.3-*", - "authors": [ "Microsoft" ], - "title": "Microsoft ASP.NET Web API Versioning", - "copyright": "Copyright \u00A9 2016. Microsoft Corporation. All rights reserved.", - "description": "A service API versioning library for Microsoft ASP.NET Web API.", - "language": "en", - - "dependencies": { - "Microsoft.AspNet.WebApi.Core": "5.2.3" - }, - - "frameworks": { - "net45": { - } - }, - - "buildOptions": { - "compile": [ "**/*.cs", "../shared/*.cs", "../common/**/*.cs" ], - "keyFile": "../../tools/key.snk", - "xmlDoc": true, - "define": [ "WEBAPI" ] - }, - - "packOptions": { - "summary": "Provides API versioning for RESTful services created using ASP.NET Web API", - "tags": [ "Microsoft", "AspNet", "AspNetWebAPI", "Versioning" ], - "owners": [ "Microsoft" ], - "releaseNotes": "• Fixed responses when a version is unspecified (Issue #62)", - "iconUrl": "http://go.microsoft.com/fwlink/?LinkID=288890", - "licenseUrl": "https://raw.githubusercontent.com/Microsoft/aspnet-api-versioning/master/LICENSE", - "requireLicenseAcceptance": true, - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/aspnet-api-versioning" - } - } -} diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Abstractions/ActionDescriptorExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Abstractions/ActionDescriptorExtensions.cs index d890e795..986f375b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Abstractions/ActionDescriptorExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Abstractions/ActionDescriptorExtensions.cs @@ -12,11 +12,11 @@ [CLSCompliant( false )] public static class ActionDescriptorExtensions { - private const string VersionsAggregated = "MS_" + nameof( HasAggregatedVersions ); + const string VersionsAggregated = "MS_" + nameof( HasAggregatedVersions ); - private static bool HasAggregatedVersions( this ActionDescriptor action ) => action.Properties.GetOrDefault( VersionsAggregated, false ); + static bool HasAggregatedVersions( this ActionDescriptor action ) => action.Properties.GetOrDefault( VersionsAggregated, false ); - private static void HasAggregatedVersions( this ActionDescriptor action, bool value ) => action.Properties[VersionsAggregated] = value; + static void HasAggregatedVersions( this ActionDescriptor action, bool value ) => action.Properties[VersionsAggregated] = value; internal static void AggregateAllVersions( this ActionDescriptor action, ActionSelectionContext context ) { diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/CollectionExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/CollectionExtensions.cs index cdc17154..e4883d9e 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/CollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/CollectionExtensions.cs @@ -4,20 +4,15 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; - internal static partial class CollectionExtensions + static partial class CollectionExtensions { - internal static TValue GetOrDefault( this IDictionary dictionary, TKey key, TValue defaultValue ) - { - TValue value; - return dictionary.TryGetValue( key, out value ) ? value : defaultValue; - } + internal static TValue GetOrDefault( this IDictionary dictionary, TKey key, TValue defaultValue ) => + dictionary.TryGetValue( key, out TValue value ) ? value : defaultValue; internal static TValue GetOrDefault( this IDictionary dictionary, TKey key, Func defaultValue ) { Contract.Requires( defaultValue != null ); - - TValue value; - return dictionary.TryGetValue( key, out value ) ? value : defaultValue(); + return dictionary.TryGetValue( key, out TValue value ) ? value : defaultValue(); } internal static void SetOrRemove( this IDictionary dictionary, TKey key, TValue value ) where TValue : class @@ -37,9 +32,9 @@ internal static void SetOrRemove( this IDictionary d internal static T AddAndReturn( this ICollection collection, T item ) { Contract.Requires( collection != null ); - Contract.Ensures( Contract.Result>() != null ); + Contract.Ensures( Contract.Result() != null ); collection.Add( item ); return item; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/ControllerNameAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/ControllerNameAttribute.cs index be579b2a..5060cb43 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/ControllerNameAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/ControllerNameAttribute.cs @@ -13,11 +13,10 @@ public sealed partial class ControllerNameAttribute : RouteValueAttribute /// Initializes a new instance of the class. /// /// The name of the controller. - public ControllerNameAttribute( string name ) - : base( "controller", name ) + public ControllerNameAttribute( string name ) : base( "controller", name ) { Arg.NotNullOrEmpty( name, nameof( name ) ); Name = name; } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/HttpContextExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/HttpContextExtensions.cs index 6bcb3dd9..c788974b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/HttpContextExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/HttpContextExtensions.cs @@ -23,9 +23,7 @@ public static ApiVersionRequestProperties ApiVersionProperties( this HttpContext Arg.NotNull( context, nameof( context ) ); Contract.Ensures( Contract.Result() != null ); - var properties = default( ApiVersionRequestProperties ); - - if ( !context.Items.TryGetValue( ApiVersionPropertiesKey, out properties ) ) + if ( !context.Items.TryGetValue( ApiVersionPropertiesKey, out ApiVersionRequestProperties properties ) ) { context.Items[ApiVersionPropertiesKey] = properties = new ApiVersionRequestProperties( context ); } diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/MapToApiVersionAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/MapToApiVersionAttribute.cs index 00fcfaa2..e99f78df 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/MapToApiVersionAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/MapToApiVersionAttribute.cs @@ -9,4 +9,4 @@ public partial class MapToApiVersionAttribute { } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.csproj b/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.csproj new file mode 100644 index 00000000..f02ab4e4 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.csproj @@ -0,0 +1,45 @@ + + + + 1.0.3 + 1.0.3.0 + net451;netstandard1.6 + 1.6.1 + $(PackageTargetFallback);dnxcore50 + Microsoft.AspNetCore.Mvc.Versioning + Microsoft ASP.NET Core API Versioning + A service API versioning library for Microsoft ASP.NET Core. + Microsoft.AspNetCore.Mvc + Microsoft;AspNet;AspNetCore;Versioning + • Fixed responses when a version is unspecified (Issue #62) + + + + + + + + + + + + + + True + True + SR.resx + + + + + + ResXFileCodeGenerator + SR.Designer.cs + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.xproj b/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.xproj deleted file mode 100644 index ca44212b..00000000 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Microsoft.AspNetCore.Mvc.Versioning.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - c39cccbc-6b04-406f-96be-ca796eff34c5 - Microsoft.AspNetCore.Mvc - .\obj - .\bin\ - v4.5 - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Properties/AssemblyInfo.cs deleted file mode 100644 index 92bfb78a..00000000 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyProduct( "Microsoft.AspNetCore.Mvc.Versioning" )] \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/ReportApiVersionsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/ReportApiVersionsAttribute.cs index 9a49c4c4..c0b91d59 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/ReportApiVersionsAttribute.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/ReportApiVersionsAttribute.cs @@ -45,7 +45,7 @@ public override void OnActionExecuted( ActionExecutedContext context ) AddApiVersionHeader( headers, ApiDeprecatedVersions, model.DeprecatedApiVersions ); } - private static void AddApiVersionHeader( IHeaderDictionary headers, string headerName, IReadOnlyList versions ) + static void AddApiVersionHeader( IHeaderDictionary headers, string headerName, IReadOnlyList versions ) { Contract.Requires( headers != null ); Contract.Requires( !IsNullOrEmpty( headerName ) ); diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Routing/ApiVersionRouteConstraint.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Routing/ApiVersionRouteConstraint.cs index b6074568..e351ca16 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Routing/ApiVersionRouteConstraint.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Routing/ApiVersionRouteConstraint.cs @@ -29,10 +29,9 @@ public bool Match( HttpContext httpContext, IRouter route, string routeKey, Rout return false; } - var value = default( string ); var properties = httpContext.ApiVersionProperties(); - if ( values.TryGetValue( routeKey, out value ) ) + if ( values.TryGetValue( routeKey, out string value ) ) { properties.RouteParameterName = routeKey; } @@ -46,9 +45,7 @@ public bool Match( HttpContext httpContext, IRouter route, string routeKey, Rout return !IsNullOrEmpty( value ); } - var requestedVersion = default( ApiVersion ); - - if ( TryParse( value, out requestedVersion ) ) + if ( TryParse( value, out var requestedVersion ) ) { properties.ApiVersion = requestedVersion; return true; diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/SR.Designer.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/SR.Designer.cs index 7a4f292b..09bcf1ff 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/SR.Designer.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/SR.Designer.cs @@ -11,15 +11,16 @@ namespace Microsoft.AspNetCore.Mvc { using System; using System.Reflection; - - + + /// - /// A strongly-typed resource class, for looking up localized strings, etc. + /// A strongly-typed resource class, for looking up localized strings, etc. /// // This class was auto-generated by the StronglyTypedResourceBuilder // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class SR { @@ -28,17 +29,18 @@ internal class SR { private static global::System.Globalization.CultureInfo resourceCulture; + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] internal SR() { } /// - /// Returns the cached ResourceManager instance used by this class. + /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Mvc.Versioning.SR", typeof(SR).GetTypeInfo().Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNetCore.Mvc.SR", typeof(SR).GetTypeInfo().Assembly); resourceMan = temp; } return resourceMan; @@ -46,8 +48,8 @@ internal SR() { } /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] internal static global::System.Globalization.CultureInfo Culture { @@ -60,7 +62,7 @@ internal SR() { } /// - /// Looks up a localized string similar to Multiple actions matched. The following actions matched route data and had all constraints satisfied:{0}{0}{1}. + /// Looks up a localized string similar to Multiple actions matched. The following actions matched route data and had all constraints satisfied:{0}{0}{1}. /// internal static string ActionSelector_AmbiguousActions { get { @@ -69,7 +71,7 @@ internal static string ActionSelector_AmbiguousActions { } /// - /// Looks up a localized string similar to The specified API group version '{0}' is invalid.. + /// Looks up a localized string similar to The specified API group version '{0}' is invalid.. /// internal static string ApiVersionBadGroupVersion { get { @@ -78,7 +80,7 @@ internal static string ApiVersionBadGroupVersion { } /// - /// Looks up a localized string similar to The specified API version status '{0}' is invalid.. + /// Looks up a localized string similar to The specified API version status '{0}' is invalid.. /// internal static string ApiVersionBadStatus { get { @@ -87,7 +89,7 @@ internal static string ApiVersionBadStatus { } /// - /// Looks up a localized string similar to The specified API version is invalid.. + /// Looks up a localized string similar to The specified API version is invalid.. /// internal static string ApiVersionInvalidFormat { get { @@ -96,7 +98,7 @@ internal static string ApiVersionInvalidFormat { } /// - /// Looks up a localized string similar to The format '{0}' is invalid or not supported.. + /// Looks up a localized string similar to The format '{0}' is invalid or not supported.. /// internal static string ApiVersionInvalidFormatCode { get { @@ -105,7 +107,7 @@ internal static string ApiVersionInvalidFormatCode { } /// - /// Looks up a localized string similar to The requested API version '{0}' is not supported.. + /// Looks up a localized string similar to The requested API version '{0}' is not supported.. /// internal static string ApiVersionNotSupported { get { @@ -114,7 +116,7 @@ internal static string ApiVersionNotSupported { } /// - /// Looks up a localized string similar to An API version is required, but was not specified.. + /// Looks up a localized string similar to An API version is required, but was not specified.. /// internal static string ApiVersionUnspecified { get { @@ -123,7 +125,7 @@ internal static string ApiVersionUnspecified { } /// - /// Looks up a localized string similar to The expression '{0}' must refer to a controller action method.. + /// Looks up a localized string similar to The expression '{0}' must refer to a controller action method.. /// internal static string InvalidActionMethodExpression { get { @@ -132,7 +134,7 @@ internal static string InvalidActionMethodExpression { } /// - /// Looks up a localized string similar to The following API versions were requested: {0}. At most, only a single API version may be specified. Please update the intended API version and retry the request.. + /// Looks up a localized string similar to The following API versions were requested: {0}. At most, only a single API version may be specified. Please update the intended API version and retry the request.. /// internal static string MultipleDifferentApiVersionsRequested { get { @@ -141,7 +143,7 @@ internal static string MultipleDifferentApiVersionsRequested { } /// - /// Looks up a localized string similar to The HTTP resource that matches the request URI '{0}' does not support the API version '{1}'.. + /// Looks up a localized string similar to The HTTP resource that matches the request URI '{0}' does not support the API version '{1}'.. /// internal static string VersionedResourceNotSupported { get { @@ -150,7 +152,7 @@ internal static string VersionedResourceNotSupported { } /// - /// Looks up a localized string similar to At least one IApiVersionReader must be specified.. + /// Looks up a localized string similar to At least one IApiVersionReader must be specified.. /// internal static string ZeroApiVersionReaders { get { diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/TypeExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/TypeExtensions.cs index 0a38b089..f5c4cd29 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/TypeExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/TypeExtensions.cs @@ -1,9 +1,8 @@ namespace Microsoft.AspNetCore.Mvc { - using System; - internal static partial class TypeExtensions + static partial class TypeExtensions { internal static bool IsPrimitive( this Type type ) { @@ -27,4 +26,4 @@ internal static bool IsPrimitive( this Type type ) return type == typeof( IntPtr ) || type == typeof( UIntPtr ); } } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ActionSelectionContext.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ActionSelectionContext.cs index 5f96f9af..c929e64d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ActionSelectionContext.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ActionSelectionContext.cs @@ -12,7 +12,7 @@ [CLSCompliant( false )] public class ActionSelectionContext { - private readonly Lazy allVersions; + readonly Lazy allVersions; /// /// Initializes a new instance of the class. @@ -57,6 +57,6 @@ public ActionSelectionContext( HttpContext httpContext, IReadOnlyList public ApiVersion RequestedVersion { get; set; } - private ApiVersionModel CreateAggregatedModel() => MatchingActions.Select( action => action.GetProperty() ).Where( model => model != null ).Aggregate(); + ApiVersionModel CreateAggregatedModel() => MatchingActions.Select( action => action.GetProperty() ).Where( model => model != null ).Aggregate(); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionActionSelector.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionActionSelector.cs index 5aebfd3d..a562a50f 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionActionSelector.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionActionSelector.cs @@ -23,11 +23,11 @@ [CLSCompliant( false )] public class ApiVersionActionSelector : IActionSelector { - private static readonly IReadOnlyList NoMatches = new ActionDescriptor[0]; - private readonly IActionSelectorDecisionTreeProvider decisionTreeProvider; - private readonly ActionConstraintCache actionConstraintCache; - private readonly IOptions options; - private readonly ILogger logger; + static readonly IReadOnlyList NoMatches = new ActionDescriptor[0]; + readonly IActionSelectorDecisionTreeProvider decisionTreeProvider; + readonly ActionConstraintCache actionConstraintCache; + readonly IOptions options; + readonly ILogger logger; /// /// Initializes a new instance of the class. @@ -86,10 +86,9 @@ public virtual ActionDescriptor SelectBestCandidate( RouteContext context, IRead Arg.NotNull( candidates, nameof( candidates ) ); var httpContext = context.HttpContext; - var apiVersion = default( ApiVersion ); var invalidRequestHandler = default( RequestHandler ); - if ( ( invalidRequestHandler = VerifyRequestedApiVersionIsNotAmbiguous( httpContext, out apiVersion ) ) != null ) + if ( ( invalidRequestHandler = VerifyRequestedApiVersionIsNotAmbiguous( httpContext, out var apiVersion ) ) != null ) { context.Handler = invalidRequestHandler; return null; @@ -181,7 +180,7 @@ where ActionIsSatisfiedBy( action, model, context.RequestedVersion, implicitMatc return bestMatches; } - private RequestHandler VerifyRequestedApiVersionIsNotAmbiguous( HttpContext httpContext, out ApiVersion apiVersion ) + RequestHandler VerifyRequestedApiVersionIsNotAmbiguous( HttpContext httpContext, out ApiVersion apiVersion ) { Contract.Requires( httpContext != null ); @@ -199,7 +198,7 @@ private RequestHandler VerifyRequestedApiVersionIsNotAmbiguous( HttpContext http return null; } - private RequestHandler IsValidRequest( ActionSelectionContext context, IReadOnlyList candidates ) + RequestHandler IsValidRequest( ActionSelectionContext context, IReadOnlyList candidates ) { Contract.Requires( context != null ); Contract.Requires( candidates != null ); @@ -270,13 +269,13 @@ private RequestHandler IsValidRequest( ActionSelectionContext context, IReadOnly return newRequestHandler( Options, code, message ); } - private static IEnumerable MatchVersionNeutralActions( ActionSelectionContext context ) => + static IEnumerable MatchVersionNeutralActions( ActionSelectionContext context ) => from action in context.MatchingActions let model = action.GetProperty() where model?.IsApiVersionNeutral ?? false select action; - private static bool ActionIsSatisfiedBy( ActionDescriptor action, ApiVersionModel model, ApiVersion version, ICollection implicitMatches ) + static bool ActionIsSatisfiedBy( ActionDescriptor action, ApiVersionModel model, ApiVersion version, ICollection implicitMatches ) { Contract.Requires( action != null ); Contract.Requires( implicitMatches != null ); @@ -299,7 +298,7 @@ private static bool ActionIsSatisfiedBy( ActionDescriptor action, ApiVersionMode return false; } - private IReadOnlyList EvaluateActionConstraints( RouteContext context, IReadOnlyList actions ) + IReadOnlyList EvaluateActionConstraints( RouteContext context, IReadOnlyList actions ) { Contract.Requires( context != null ); Contract.Requires( actions != null ); @@ -324,7 +323,7 @@ private IReadOnlyList EvaluateActionConstraints( RouteContext return matches.Select( candidate => candidate.Action ).ToArray(); } - private IReadOnlyList EvaluateActionConstraintsCore( RouteContext context, IReadOnlyList candidates, int? startingOrder ) + IReadOnlyList EvaluateActionConstraintsCore( RouteContext context, IReadOnlyList candidates, int? startingOrder ) { var order = default( int? ); @@ -355,10 +354,11 @@ private IReadOnlyList EvaluateActionConstraintsCore( Ro var actionsWithConstraint = new List(); var actionsWithoutConstraint = new List(); - var constraintContext = new ActionConstraintContext(); - - constraintContext.Candidates = candidates; - constraintContext.RouteContext = context; + var constraintContext = new ActionConstraintContext() + { + Candidates = candidates, + RouteContext = context + }; for ( var i = 0; i < candidates.Count; i++ ) { diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionConvention.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionConvention.cs index dee86be2..4711f8aa 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionConvention.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ApiVersionConvention.cs @@ -12,8 +12,8 @@ [CLSCompliant( false )] public class ApiVersionConvention : IApplicationModelConvention { - private readonly ApiVersionConventionBuilder conventionBuilder; - private readonly ApiVersionModel implicitVersionModel; + readonly ApiVersionConventionBuilder conventionBuilder; + readonly ApiVersionModel implicitVersionModel; /// /// Initializes a new instance of the class. @@ -78,7 +78,7 @@ public void Apply( ApplicationModel application ) } } - private static bool IsDecoratedWithAttributes( ControllerModel controller ) + static bool IsDecoratedWithAttributes( ControllerModel controller ) { Contract.Requires( controller != null ); @@ -93,7 +93,7 @@ private static bool IsDecoratedWithAttributes( ControllerModel controller ) return false; } - private void ApplyImplicitConventions( ControllerModel controller ) + void ApplyImplicitConventions( ControllerModel controller ) { Contract.Requires( controller != null ); @@ -105,7 +105,7 @@ private void ApplyImplicitConventions( ControllerModel controller ) } } - private void ApplyAttributeOrImplicitConventions( ControllerModel controller ) + void ApplyAttributeOrImplicitConventions( ControllerModel controller ) { Contract.Requires( controller != null ); diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/BadRequestHandler.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/BadRequestHandler.cs index 470778b2..b93ae476 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/BadRequestHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/BadRequestHandler.cs @@ -2,7 +2,7 @@ { using Http; - internal sealed class BadRequestHandler : RequestHandler + sealed class BadRequestHandler : RequestHandler { internal BadRequestHandler( ApiVersioningOptions options, string code, string message ) : base( options, code, message ) { } diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs index e2e5b31e..153ee094 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ApiVersionConventionBuilder.cs @@ -35,9 +35,8 @@ public virtual ControllerApiVersionConventionBuilder Controller>() != null ); var key = typeof( TController ).GetTypeInfo(); - var convention = default( IApiVersionConvention ); - if ( !ControllerConventions.TryGetValue( key, out convention ) ) + if ( !ControllerConventions.TryGetValue( key, out var convention ) ) { var typedConvention = new ControllerApiVersionConventionBuilder(); ControllerConventions[key] = typedConvention; @@ -59,9 +58,8 @@ public virtual bool ApplyTo( ControllerModel controllerModel ) Arg.NotNull( controllerModel, nameof( controllerModel ) ); var key = controllerModel.ControllerType; - var convention = default( IApiVersionConvention ); - if ( ControllerConventions.TryGetValue( key, out convention ) ) + if ( ControllerConventions.TryGetValue( key, out var convention ) ) { convention.ApplyTo( controllerModel ); return true; diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs index 5262d119..26509e6d 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/Conventions/ControllerApiVersionConventionBuilderT.cs @@ -26,7 +26,7 @@ public void ApplyTo( ControllerModel controllerModel ) ApplyActionConventions( controllerModel, ApplyControllerConventions( controllerModel ) ); } - private ControllerVersionInfo ApplyControllerConventions( ControllerModel controllerModel ) + ControllerVersionInfo ApplyControllerConventions( ControllerModel controllerModel ) { Contract.Requires( controllerModel != null ); Contract.Ensures( Contract.Result() != null ); @@ -45,7 +45,7 @@ private ControllerVersionInfo ApplyControllerConventions( ControllerModel contro return new ControllerVersionInfo( supportedVersions, deprecatedVersions, advertisedVersions, deprecatedAdvertisedVersions ); } - private void MergeControllerAttributesWithConventions( ControllerModel controllerModel ) + void MergeControllerAttributesWithConventions( ControllerModel controllerModel ) { Contract.Requires( controllerModel != null ); @@ -82,7 +82,7 @@ from version in provider.Versions select version ); } - private void ApplyActionConventions( ControllerModel controller, ControllerVersionInfo controllerVersionInfo ) + void ApplyActionConventions( ControllerModel controller, ControllerVersionInfo controllerVersionInfo ) { Contract.Requires( controller != null ); Contract.Requires( controllerVersionInfo != null ); @@ -97,7 +97,7 @@ private void ApplyActionConventions( ControllerModel controller, ControllerVersi } } - private void ApplyNeutralModelToActions( ControllerModel controller ) + void ApplyNeutralModelToActions( ControllerModel controller ) { Contract.Requires( controller != null ); @@ -108,7 +108,7 @@ private void ApplyNeutralModelToActions( ControllerModel controller ) } } - private void MergeActionAttributesWithConventions( ControllerModel controller, ControllerVersionInfo controllerVersionInfo ) + void MergeActionAttributesWithConventions( ControllerModel controller, ControllerVersionInfo controllerVersionInfo ) { Contract.Requires( controller != null ); Contract.Requires( controllerVersionInfo != null ); @@ -116,11 +116,10 @@ private void MergeActionAttributesWithConventions( ControllerModel controller, C foreach ( var action in controller.Actions ) { var key = action.ActionMethod; - var actionBuilder = default( ActionApiVersionConventionBuilder ); action.SetProperty( controller ); - if ( ActionBuilders.TryGetValue( key, out actionBuilder ) ) + if ( ActionBuilders.TryGetValue( key, out var actionBuilder ) ) { action.SetProperty( controllerVersionInfo ); actionBuilder.ApplyTo( action ); diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/HeaderApiVersionReader.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/HeaderApiVersionReader.cs index aa6513fb..5f5ec1ee 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/HeaderApiVersionReader.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/HeaderApiVersionReader.cs @@ -1,6 +1,5 @@ namespace Microsoft.AspNetCore.Mvc.Versioning { - using Extensions.Primitives; using Http; using System; using System.Collections.Generic; @@ -28,9 +27,7 @@ public virtual string Read( HttpRequest request ) foreach ( var name in HeaderNames ) { - var values = default( StringValues ); - - if ( headers.TryGetValue( name, out values ) ) + if ( headers.TryGetValue( name, out var values ) ) { versions.AddRange( values.Where( v => !IsNullOrEmpty( v ) ) ); } diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ILoggerExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ILoggerExtensions.cs index 1207863e..c99b0ae7 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ILoggerExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/ILoggerExtensions.cs @@ -6,24 +6,24 @@ using static Extensions.Logging.LoggerMessage; using static Extensions.Logging.LogLevel; - internal static class ILoggerExtensions + static class ILoggerExtensions { - private static readonly Action ambiguousActions = + static readonly Action ambiguousActions = Define( Error, 1, "Request matched multiple actions resulting in ambiguity. Matching actions: {AmbiguousActions}" ); - private static readonly Action constraintMismatch = + static readonly Action constraintMismatch = Define( Debug, 2, "Action '{ActionName}' with id '{ActionId}' did not match the constraint '{ActionConstraint}'" ); - private static readonly Action apiVersionUnspecified = + static readonly Action apiVersionUnspecified = Define( Information, 3, "Request did not specify a service API version, but multiple candidate actions were found. Candidate actions: {CandidateActions}" ); - private static readonly Action apiVersionUnspecifiedWithDefaultVersion = + static readonly Action apiVersionUnspecifiedWithDefaultVersion = Define( Information, 4, "Request did not specify a service API version, but multiple candidate actions were found; however, none matched the selected default API version '{ApiVersion}'. Candidate actions: {CandidateActions}" ); - private static readonly Action apiVersionUnmatched = + static readonly Action apiVersionUnmatched = Define( Information, 5, "Multiple candidate actions were found, but none matched the requested service API version '{ApiVersion}'. Candidate actions: {CandidateActions}" ); - private static readonly Action apiVersionInvalid = + static readonly Action apiVersionInvalid = Define( Information, 6, "Request contained the service API version '{ApiVersion}', which is not valid" ); internal static void AmbiguousActions( this ILogger logger, string actionNames ) => ambiguousActions( logger, actionNames, null ); @@ -39,4 +39,4 @@ internal static void ConstraintMismatch( this ILogger logger, string actionName, internal static void ApiVersionInvalid( this ILogger logger, string apiVersion ) => apiVersionInvalid( logger, apiVersion, null ); } -} +} \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MediaTypeApiVersionReader.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MediaTypeApiVersionReader.cs index c9330562..b4e46392 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MediaTypeApiVersionReader.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MediaTypeApiVersionReader.cs @@ -1,10 +1,7 @@ namespace Microsoft.AspNetCore.Mvc.Versioning { using Http; - using Net.Http.Headers; using System; - using System.Collections.Generic; - using System.Linq; /// /// Provides the implementation for ASP.NET Core. diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MethodNotAllowedHandler.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MethodNotAllowedHandler.cs index 8a5d239e..dd2ae58a 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MethodNotAllowedHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/MethodNotAllowedHandler.cs @@ -6,7 +6,7 @@ using System.Diagnostics.Contracts; using System.Threading.Tasks; - internal sealed class MethodNotAllowedHandler : RequestHandler + sealed class MethodNotAllowedHandler : RequestHandler { readonly string[] allowedMethods; diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/RequestHandler.cs b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/RequestHandler.cs index 90d77414..879e9a81 100644 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/RequestHandler.cs +++ b/src/Microsoft.AspNetCore.Mvc.Versioning/Versioning/RequestHandler.cs @@ -6,7 +6,7 @@ using System.Diagnostics.Contracts; using System.Threading.Tasks; - internal abstract class RequestHandler + abstract class RequestHandler { protected RequestHandler( ApiVersioningOptions options, string code, string message ) { diff --git a/src/Microsoft.AspNetCore.Mvc.Versioning/project.json b/src/Microsoft.AspNetCore.Mvc.Versioning/project.json deleted file mode 100644 index 6595ab62..00000000 --- a/src/Microsoft.AspNetCore.Mvc.Versioning/project.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": "1.0.3-*", - "authors": [ "Microsoft" ], - "title": "Microsoft ASP.NET Core API Versioning", - "copyright": "Copyright \u00A9 2015. Microsoft Corporation. All rights reserved.", - "description": "A service API versioning library for Microsoft ASP.NET Core.", - "language": "en", - - "dependencies": { - "NETStandard.Library": "1.6.1", - "Microsoft.AspNetCore.Mvc.Core": "1.1.1" - }, - - "frameworks": { - "net451": { - }, - "netstandard1.6": { - "imports": "dnxcore50" - } - }, - - "buildOptions": { - "compile": [ "**/*.cs", "../shared/*.cs", "../common/**/*.cs" ], - "keyFile": "../../tools/key.snk", - "xmlDoc": true - }, - - "packOptions": { - "summary": "Provides API versioning for RESTful services created using ASP.NET Core", - "tags": [ "Microsoft", "AspNet", "AspNetCore", "Versioning" ], - "owners": [ "Microsoft" ], - "releaseNotes": "\u2022 Fixed responses when a version is unspecified (Issue #62)", - "iconUrl": "http://go.microsoft.com/fwlink/?LinkID=288890", - "licenseUrl": "https://raw.githubusercontent.com/Microsoft/aspnet-api-versioning/master/LICENSE", - "requireLicenseAcceptance": true, - "repository": { - "type": "git", - "url": "https://github.com/Microsoft/aspnet-api-versioning" - } - } -} diff --git a/src/Shared/Arg.cs b/src/Shared/Arg.cs index e87e0d88..126a3cf6 100644 --- a/src/Shared/Arg.cs +++ b/src/Shared/Arg.cs @@ -5,7 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; - internal static class Arg + static class Arg { [DebuggerStepThrough] [ContractArgumentValidator] diff --git a/src/Shared/Shared.projitems b/src/Shared/Shared.projitems new file mode 100644 index 00000000..1e03d8c1 --- /dev/null +++ b/src/Shared/Shared.projitems @@ -0,0 +1,16 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + b7897873-6757-4684-83c0-39575821ae14 + + + Microsoft + + + + + + + \ No newline at end of file diff --git a/src/Shared/Shared.shproj b/src/Shared/Shared.shproj new file mode 100644 index 00000000..c4bff7a7 --- /dev/null +++ b/src/Shared/Shared.shproj @@ -0,0 +1,13 @@ + + + + b7897873-6757-4684-83c0-39575821ae14 + 14.0 + + + + + + + + diff --git a/src/Shared/SharedAssemblyInfo.cs b/src/Shared/SharedAssemblyInfo.cs index a109d750..2d9a2a9c 100644 --- a/src/Shared/SharedAssemblyInfo.cs +++ b/src/Shared/SharedAssemblyInfo.cs @@ -1,16 +1,8 @@ using System; using System.Reflection; -using System.Resources; using System.Runtime.InteropServices; -#if DEBUG -[assembly: AssemblyConfiguration( "Debug" )] -#else -[assembly: AssemblyConfiguration( "Release" )] -#endif -[assembly: AssemblyCompany( "Microsoft Corporation" )] [assembly: AssemblyTrademark( "" )] [assembly: AssemblyCulture( "" )] [assembly: ComVisible( false )] -[assembly: CLSCompliant( true )] -[assembly: NeutralResourcesLanguage( "en" )] \ No newline at end of file +[assembly: CLSCompliant( true )] \ No newline at end of file diff --git a/src/Shared/StringExtensions.cs b/src/Shared/StringExtensions.cs index abfa19fe..192c0307 100644 --- a/src/Shared/StringExtensions.cs +++ b/src/Shared/StringExtensions.cs @@ -1,11 +1,10 @@ namespace Microsoft { - using System; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using static System.Globalization.CultureInfo; - internal static class StringExtensions + static class StringExtensions { [Pure] [SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Shared source, but not libraries. May not be used in call links." )] @@ -13,6 +12,6 @@ internal static class StringExtensions [Pure] [SuppressMessage( "Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Shared source, but not libraries. May not be used in call links." )] - public static string FormatDefault( this string format, params object[] args ) => string.Format( CurrentCulture, format, args ); + internal static string FormatDefault( this string format, params object[] args ) => string.Format( CurrentCulture, format, args ); } -} +} \ No newline at end of file diff --git a/test/.editorconfig b/test/.editorconfig new file mode 100644 index 00000000..b6fd83b0 --- /dev/null +++ b/test/.editorconfig @@ -0,0 +1,10 @@ +# EditorConfig is awesome +# * http://EditorConfig.org +# * https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference + +# TODO: enable relevant naming rules once they are supported +# REF: https://github.com/dotnet/roslyn/pull/15065 + +# relax rules for test class and methods names +#[*.cs] +#dotnet_naming_style.first_word_upper_case_style.capitalization = first_word_upper \ No newline at end of file diff --git a/test/Acceptance.Test.Shared/Acceptance.Test.Shared.projitems b/test/Acceptance.Test.Shared/Acceptance.Test.Shared.projitems new file mode 100644 index 00000000..c97bcb25 --- /dev/null +++ b/test/Acceptance.Test.Shared/Acceptance.Test.Shared.projitems @@ -0,0 +1,19 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + 6cdfb878-2642-4f98-ae35-621bac581181 + + + Microsoft + + + + + + + + + + \ No newline at end of file diff --git a/test/Acceptance.Test.Shared/Acceptance.Test.Shared.shproj b/test/Acceptance.Test.Shared/Acceptance.Test.Shared.shproj new file mode 100644 index 00000000..ca87a759 --- /dev/null +++ b/test/Acceptance.Test.Shared/Acceptance.Test.Shared.shproj @@ -0,0 +1,13 @@ + + + + 6cdfb878-2642-4f98-ae35-621bac581181 + 14.0 + + + + + + + + diff --git a/test/Acceptance.Test.Shared/AcceptanceTest.cs b/test/Acceptance.Test.Shared/AcceptanceTest.cs new file mode 100644 index 00000000..fa7ec983 --- /dev/null +++ b/test/Acceptance.Test.Shared/AcceptanceTest.cs @@ -0,0 +1,71 @@ +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif +{ + using System; + using System.Net.Http; + using System.Net.Http.Formatting; + using System.Net.Http.Headers; + using System.Threading.Tasks; + using Xunit; + using static System.Net.Http.HttpMethod; + + [Trait( "Kind", "Acceptance" )] + public abstract partial class AcceptanceTest : IDisposable + { + const string JsonMediaType = "application/json"; + static readonly HttpMethod Patch = new HttpMethod( "PATCH" ); + readonly FilteredControllerTypes filteredControllerTypes = new FilteredControllerTypes(); + bool disposed; + + ~AcceptanceTest() => Dispose( false ); + + public void Dispose() + { + Dispose( true ); + GC.SuppressFinalize( this ); + } + + HttpRequestMessage CreateRequest( string requestUri, TEntity entity, HttpMethod method ) + { + var request = new HttpRequestMessage( method, requestUri ); + + if ( !Equals( entity, default( TEntity ) ) ) + { + var formatter = new JsonMediaTypeFormatter(); + request.Content = new ObjectContent( entity, formatter, JsonMediaType ); + } + + Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); + + return request; + } + + HttpRequestMessage CreateRequest( string requestUri, HttpContent content, HttpMethod method ) + { + var request = new HttpRequestMessage( method, requestUri ) { Content = content }; + + Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); + + return request; + } + + protected virtual Task GetAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Get ) ); + + protected virtual Task PostAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Post ) ); + + protected virtual Task PostAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Post ) ); + + protected virtual Task PutAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Put ) ); + + protected virtual Task PutAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Put ) ); + + protected virtual Task PatchAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Patch ) ); + + protected virtual Task PatchAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Patch ) ); + + protected virtual Task DeleteAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Delete ) ); + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpContentExtensions.cs b/test/Acceptance.Test.Shared/HttpContentExtensions.cs similarity index 63% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpContentExtensions.cs rename to test/Acceptance.Test.Shared/HttpContentExtensions.cs index fde39c9c..5b0eb796 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpContentExtensions.cs +++ b/test/Acceptance.Test.Shared/HttpContentExtensions.cs @@ -1,11 +1,15 @@ -namespace Microsoft.Web +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif { using System; using System.Net.Http; using System.Threading.Tasks; - internal static class HttpContentExtensions + static class HttpContentExtensions { internal static Task ReadAsExampleAsync( this HttpContent content, T example ) => content.ReadAsAsync(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiError.cs b/test/Acceptance.Test.Shared/OneApiError.cs similarity index 70% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiError.cs rename to test/Acceptance.Test.Shared/OneApiError.cs index be7bcd26..83c5fede 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiError.cs +++ b/test/Acceptance.Test.Shared/OneApiError.cs @@ -1,4 +1,8 @@ -namespace Microsoft.Web +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif { using System; diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiErrorResponse.cs b/test/Acceptance.Test.Shared/OneApiErrorResponse.cs similarity index 57% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiErrorResponse.cs rename to test/Acceptance.Test.Shared/OneApiErrorResponse.cs index b16e5583..a85ee280 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiErrorResponse.cs +++ b/test/Acceptance.Test.Shared/OneApiErrorResponse.cs @@ -1,4 +1,8 @@ -namespace Microsoft.AspNetCore.Mvc +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif { using System; @@ -6,4 +10,4 @@ public class OneApiErrorResponse { public OneApiError Error { get; set; } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiInnerError.cs b/test/Acceptance.Test.Shared/OneApiInnerError.cs similarity index 64% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiInnerError.cs rename to test/Acceptance.Test.Shared/OneApiInnerError.cs index 2a9aa00a..e05063e4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiInnerError.cs +++ b/test/Acceptance.Test.Shared/OneApiInnerError.cs @@ -1,4 +1,8 @@ -namespace Microsoft.AspNetCore.Mvc +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif { using System; diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/TaskExtensions.cs b/test/Acceptance.Test.Shared/TaskExtensions.cs similarity index 74% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/TaskExtensions.cs rename to test/Acceptance.Test.Shared/TaskExtensions.cs index 3d5f6ce8..74036f00 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/TaskExtensions.cs +++ b/test/Acceptance.Test.Shared/TaskExtensions.cs @@ -1,10 +1,14 @@ -namespace Microsoft.AspNetCore.Mvc +#if WEBAPI +namespace Microsoft.Web +#else +namespace Microsoft.AspNetCore.Mvc +#endif { using System; using System.Net.Http; using System.Threading.Tasks; - internal static class TaskExtensions + static class TaskExtensions { internal static async Task EnsureSuccessStatusCode( this Task task ) { diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.csproj b/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.csproj new file mode 100644 index 00000000..f846c3f4 --- /dev/null +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.csproj @@ -0,0 +1,26 @@ + + + + net452 + Microsoft.AspNet.OData.Versioning.Tests + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.xproj b/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.xproj deleted file mode 100644 index 62c217f4..00000000 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Microsoft.AspNet.OData.Versioning.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - d87e54cc-c2d6-4ae5-806d-ae825b051c66 - Microsoft - .\obj - .\bin\ - v4.5 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/OData.Edm/ApiVersionAnnotationTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/OData.Edm/ApiVersionAnnotationTest.cs index 33b03ea5..10a8cc99 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/OData.Edm/ApiVersionAnnotationTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/OData.Edm/ApiVersionAnnotationTest.cs @@ -21,4 +21,4 @@ public void new_api_version_annotation_should_set_expected_version() apiVersion.Should().Be( annotatedApiVersion ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 440bc107..00000000 --- a/test/Microsoft.AspNet.OData.Versioning.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("WebApi.OData.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("d87e54cc-c2d6-4ae5-806d-ae825b051c66")] diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/System.Web.OData/HttpConfigurationExtensionsTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/System.Web.OData/HttpConfigurationExtensionsTest.cs index f3aa330a..c0b84d62 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/System.Web.OData/HttpConfigurationExtensionsTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/System.Web.OData/HttpConfigurationExtensionsTest.cs @@ -18,16 +18,12 @@ public class HttpConfigurationExtensionsTest { [ApiVersion( "1.0" )] - private sealed class ControllerV1 : ODataController - { - } + sealed class ControllerV1 : ODataController { } [ApiVersion( "2.0" )] - private sealed class ControllerV2 : ODataController - { - } + sealed class ControllerV2 : ODataController { } - private static IEnumerable CreateModels( HttpConfiguration configuration ) + static IEnumerable CreateModels( HttpConfiguration configuration ) { var controllerTypeResolver = new Mock(); var controllerTypes = new List() { typeof( ControllerV1 ), typeof( ControllerV2 ) }; diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Builder/VersionedODataModelBuilderTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Builder/VersionedODataModelBuilderTest.cs index 314ea7ca..b749ad6d 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Builder/VersionedODataModelBuilderTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Builder/VersionedODataModelBuilderTest.cs @@ -16,9 +16,7 @@ public class VersionedODataModelBuilderTest { [ApiVersion( "1.0" )] - private sealed class ControllerV1 : ODataController - { - } + sealed class ControllerV1 : ODataController { } [Fact] public void get_edm_models_should_return_expected_results() @@ -49,4 +47,4 @@ public void get_edm_models_should_return_expected_results() modelCreated.Verify( f => f( It.IsAny(), model ), Times.Once() ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Controllers/VersionedMetadataControllerTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Controllers/VersionedMetadataControllerTest.cs index bc546819..aadab33e 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Controllers/VersionedMetadataControllerTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Controllers/VersionedMetadataControllerTest.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Linq; using System.Net.Http; - using System.Threading; using System.Threading.Tasks; using System.Web.Http; using System.Web.Http.Dispatcher; @@ -19,16 +18,12 @@ public class VersionedMetadataControllerTest { [ApiVersion( "1.0" )] [ApiVersion( "2.0" )] - private sealed class Controller1 : ODataController - { - } + sealed class Controller1 : ODataController { } [ApiVersion( "2.0", Deprecated = true )] [ApiVersion( "3.0-Beta", Deprecated = true )] [ApiVersion( "3.0" )] - private sealed class Controller2 : ODataController - { - } + sealed class Controller2 : ODataController { } [Fact] public async Task options_should_return_expected_headers() @@ -64,4 +59,4 @@ public async Task options_should_return_expected_headers() response.Content.Headers.Allow.Should().BeEquivalentTo( "GET", "OPTIONS" ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedAttributeRoutingConventionTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedAttributeRoutingConventionTest.cs index 03be3299..846188e0 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedAttributeRoutingConventionTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedAttributeRoutingConventionTest.cs @@ -18,16 +18,12 @@ public class VersionedAttributeRoutingConventionTest { [ApiVersionNeutral] - private sealed class NeutralController : ODataController - { - } + sealed class NeutralController : ODataController { } [ApiVersion( "1.0" )] - private sealed class ControllerV1 : ODataController - { - } + sealed class ControllerV1 : ODataController { } - private static IEdmModel CreateModel( HttpConfiguration configuration, Type controllerType ) + static IEdmModel CreateModel( HttpConfiguration configuration, Type controllerType ) { var controllerTypeResolver = new Mock(); var controllerTypes = new List() { controllerType }; diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedMetadataRoutingConventionTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedMetadataRoutingConventionTest.cs index c7050ace..917d1b7b 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedMetadataRoutingConventionTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedMetadataRoutingConventionTest.cs @@ -66,4 +66,4 @@ public void select_action_should_return_expected_name( ODataPath odataPath, stri actionName.Should().Be( expected ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedODataPathRouteConstraintTest.cs b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedODataPathRouteConstraintTest.cs index f75ea1a3..bc8f1ac6 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedODataPathRouteConstraintTest.cs +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/Web.OData/Routing/VersionedODataPathRouteConstraintTest.cs @@ -26,9 +26,9 @@ public class Test public int Id { get; set; } } - private static IEdmModel EmptyModel => new ODataModelBuilder().GetEdmModel(); + static IEdmModel EmptyModel => new ODataModelBuilder().GetEdmModel(); - private static IEdmModel TestModel + static IEdmModel TestModel { get { @@ -39,7 +39,7 @@ private static IEdmModel TestModel } } - private static VersionedODataPathRouteConstraint NewVersionedODataPathRouteConstraint( HttpRequestMessage request, IEdmModel model, ApiVersion apiVersion, string routePrefix = null ) + static VersionedODataPathRouteConstraint NewVersionedODataPathRouteConstraint( HttpRequestMessage request, IEdmModel model, ApiVersion apiVersion, string routePrefix = null ) { var pathHandler = new DefaultODataPathHandler(); var conventions = ODataRoutingConventions.CreateDefault(); @@ -156,4 +156,4 @@ public void match_should_return_400_when_requested_api_version_is_ambiguous() match.ShouldThrow().And.Response.StatusCode.Should().Be( BadRequest ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/app.config b/test/Microsoft.AspNet.OData.Versioning.Tests/app.config index b2f955b0..95c4541a 100644 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/app.config +++ b/test/Microsoft.AspNet.OData.Versioning.Tests/app.config @@ -1,6 +1,21 @@  - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.OData.Versioning.Tests/project.json b/test/Microsoft.AspNet.OData.Versioning.Tests/project.json deleted file mode 100644 index cebbbfb7..00000000 --- a/test/Microsoft.AspNet.OData.Versioning.Tests/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.AspNet.OData": "5.9.1", - "FluentAssertions": "4.19.0", - "more.xunit": "2.1.0", - "xunit.runner.visualstudio": "2.1.0", - "Moq": "4.7.0", - "Microsoft.AspNet.WebApi.Core": "5.2.3", - "Microsoft.AspNet.OData.Versioning": { - "target": "project", - "version": "" - } - }, - - "frameworks": { - "net45": { - "dependencies": { - "System.Runtime": "4.0.0", - "System.Threading.Tasks": "4.0.0" - } - } - } -} diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/AcceptanceTest.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/AcceptanceTest.cs index ad6b60a2..3563b167 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/AcceptanceTest.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/AcceptanceTest.cs @@ -3,35 +3,16 @@ using System; using System.Collections.Generic; using System.Net.Http; - using System.Net.Http.Formatting; using System.Net.Http.Headers; - using System.Threading.Tasks; using System.Web.Http; using System.Web.Http.Dispatcher; using Xunit; - using static System.Net.Http.HttpMethod; using static System.String; using static System.Web.Http.IncludeErrorDetailPolicy; - [Trait( "Kind", "Acceptance" )] [Trait( "Framework", "Web API" )] - public abstract class AcceptanceTest : IDisposable + public abstract partial class AcceptanceTest : IDisposable { - sealed class FilteredControllerTypeResolver : List, IHttpControllerTypeResolver - { - public ICollection GetControllerTypes( IAssembliesResolver assembliesResolver ) => this; - } - - const string JsonMediaType = "application/json"; - static readonly HttpMethod Patch = new HttpMethod( "PATCH" ); - readonly FilteredControllerTypeResolver filteredControllerTypes = new FilteredControllerTypeResolver(); - bool disposed; - - ~AcceptanceTest() - { - Dispose( false ); - } - protected AcceptanceTest() { Configuration.IncludeErrorDetailPolicy = Always; @@ -74,36 +55,6 @@ protected virtual void Dispose( bool disposing ) Configuration.Dispose(); } - public void Dispose() - { - Dispose( true ); - GC.SuppressFinalize( this ); - } - - HttpRequestMessage CreateRequest( string requestUri, TEntity entity, HttpMethod method ) - { - var request = new HttpRequestMessage( method, requestUri ); - - if ( !Equals( entity, default( TEntity ) ) ) - { - var formatter = new JsonMediaTypeFormatter(); - request.Content = new ObjectContent( entity, formatter, JsonMediaType ); - } - - Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); - - return request; - } - - HttpRequestMessage CreateRequest( string requestUri, HttpContent content, HttpMethod method ) - { - var request = new HttpRequestMessage( method, requestUri ) { Content = content }; - - Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); - - return request; - } - protected void Accept( string metadata = null ) { var mediaType = new MediaTypeWithQualityHeaderValue( JsonMediaType ); @@ -134,21 +85,5 @@ protected void Accept( string metadata = null ) } protected void PreferNoReturn() => Client.DefaultRequestHeaders.Add( "Prefer", "return=representation" ); - - protected virtual Task GetAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Get ) ); - - protected virtual Task PostAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Post ) ); - - protected virtual Task PostAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Post ) ); - - protected virtual Task PutAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Put ) ); - - protected virtual Task PutAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Put ) ); - - protected virtual Task PatchAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Patch ) ); - - protected virtual Task PatchAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Patch ) ); - - protected virtual Task DeleteAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Delete ) ); } } \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/FilteredControllerTypes.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/FilteredControllerTypes.cs new file mode 100644 index 00000000..ec405e32 --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/FilteredControllerTypes.cs @@ -0,0 +1,11 @@ +namespace Microsoft.Web +{ + using System; + using System.Collections.Generic; + using System.Web.Http.Dispatcher; + + sealed class FilteredControllerTypes : List, IHttpControllerTypeResolver + { + public ICollection GetControllerTypes( IAssembliesResolver assembliesResolver ) => this; + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_query_string_versioned_ApiController_split_into_two_types.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a query string and split into two types.cs similarity index 82% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_query_string_versioned_ApiController_split_into_two_types.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a query string and split into two types.cs index cfc058c4..b9cd3d81 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_query_string_versioned_ApiController_split_into_two_types.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController { using FluentAssertions; using Microsoft.Web; @@ -11,12 +11,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ApiController_split_into_two_types : BasicAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : BasicAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange @@ -36,7 +36,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -51,7 +51,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_url_versioned_ApiController.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a url segment.cs similarity index 85% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_url_versioned_ApiController.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a url segment.cs index 629fab2a..13be8aab 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given/a_url_versioned_ApiController.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Basic/given a versioned ApiController/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController { using FluentAssertions; using Microsoft.Web; @@ -12,12 +12,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ApiController : BasicAcceptanceTest + public class when_using_a_url_segment : BasicAcceptanceTest { [Theory] [InlineData( "api/v1/helloworld", null )] [InlineData( "api/v1/helloworld/42", "42" )] - public async Task _get_should_return_200( string requestUrl, string id ) + public async Task then_get_should_return_200( string requestUrl, string id ) { // arrange var body = new Dictionary() @@ -41,7 +41,7 @@ public async Task _get_should_return_200( string requestUrl, string id ) } [Fact] - public async Task _post_should_return_201() + public async Task then_post_should_return_201() { // arrange var entity = default( object ); @@ -54,7 +54,7 @@ public async Task _post_should_return_201() } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/ByNamespaceAcceptanceTest.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/ByNamespaceAcceptanceTest.cs index 531869af..120880bd 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/ByNamespaceAcceptanceTest.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/ByNamespaceAcceptanceTest.cs @@ -29,7 +29,7 @@ protected ByNamespaceAcceptanceTest( SetupKind kind ) Configuration.EnsureInitialized(); } - private void ConfigureAgreements() + void ConfigureAgreements() { FilteredControllerTypes.Add( typeof( Controllers.V1.AgreementsController ) ); FilteredControllerTypes.Add( typeof( Controllers.V2.AgreementsController ) ); @@ -50,7 +50,7 @@ private void ConfigureAgreements() } - private void ConfigureHelloWorld() + void ConfigureHelloWorld() { FilteredControllerTypes.Add( typeof( Controllers.V1.HelloWorldController ) ); FilteredControllerTypes.Add( typeof( Controllers.V2.HelloWorldController ) ); diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_query_string_versioned_ApiController_per_namespace.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a query string.cs similarity index 80% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_query_string_versioned_ApiController_per_namespace.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a query string.cs index e3cd9fff..b11dc959 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_query_string_versioned_ApiController_per_namespace.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a query string.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_per_namespace { using FluentAssertions; using Microsoft.Web; @@ -9,15 +9,15 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ApiController_per_namespace : ByNamespaceAcceptanceTest + public class when_using_a_query_string : ByNamespaceAcceptanceTest { - public _a_query_string_versioned_ApiController_per_namespace() : base( SetupKind.Agreements ) { } + public when_using_a_query_string() : base( SetupKind.Agreements ) { } [Theory] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V1.AgreementsController", "1.0" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V2.AgreementsController", "2.0" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V3.AgreementsController", "3.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { Controller = "", ApiVersion = "", AccountId = "" }; @@ -32,7 +32,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -47,7 +47,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_and_attribute-routed_ApiController_per_namespace.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and attribute-based routing.cs similarity index 71% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_and_attribute-routed_ApiController_per_namespace.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and attribute-based routing.cs index 576aa9ec..67e16af0 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_and_attribute-routed_ApiController_per_namespace.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and attribute-based routing.cs @@ -1,16 +1,16 @@ -namespace given +namespace given_a_versioned_ApiController_per_namespace { using FluentAssertions; using Microsoft.Web.Http.ByNamespace; using System.Threading.Tasks; using Xunit; - public class _a_url_versioned_and_attributeX2Drouted_ApiController_per_namespace : ByNamespaceAcceptanceTest + public class when_using_a_url_segment_and_attributeX2Dbased_routing : ByNamespaceAcceptanceTest { - public _a_url_versioned_and_attributeX2Drouted_ApiController_per_namespace() : base( SetupKind.HelloWorld ) { } + public when_using_a_url_segment_and_attributeX2Dbased_routing() : base( SetupKind.HelloWorld ) { } [Fact] - public async Task _then_get_should_should_return_200_when_a_version_is_unspecified() + public async Task then_get_should_should_return_200_for_an_unspecified_version() { // arrange @@ -27,7 +27,7 @@ public async Task _then_get_should_should_return_200_when_a_version_is_unspecifi [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V1.HelloWorldController", "1" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V2.HelloWorldController", "2" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V3.HelloWorldController", "3" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var expected = $"\"V{apiVersion}\""; diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_ApiController_per_namespace.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and convention-based routing.cs similarity index 77% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_ApiController_per_namespace.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and convention-based routing.cs index bd549672..cd51bcb4 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given/a_url_versioned_ApiController_per_namespace.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/ByNamespace/given a versioned ApiController per namespace/when using a url segment and convention-based routing.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_per_namespace { using FluentAssertions; using Microsoft.Web; @@ -9,15 +9,15 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ApiController_per_namespace : ByNamespaceAcceptanceTest + public class when_using_a_url_segment_and_conventionX2Dbased_routing : ByNamespaceAcceptanceTest { - public _a_url_versioned_ApiController_per_namespace() : base( SetupKind.Agreements ) { } + public when_using_a_url_segment_and_conventionX2Dbased_routing() : base( SetupKind.Agreements ) { } [Theory] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V1.AgreementsController", "1" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V2.AgreementsController", "2" )] [InlineData( "Microsoft.Web.Http.ByNamespace.Controllers.V3.AgreementsController", "3" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { Controller = "", ApiVersion = "", AccountId = "" }; @@ -32,7 +32,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_query_string_versioned_ApiController_split_into_two_types_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a query string and split into two types.cs similarity index 82% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_query_string_versioned_ApiController_split_into_two_types_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a query string and split into two types.cs index 275e6151..2c212cf1 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_query_string_versioned_ApiController_split_into_two_types_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -11,13 +11,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ApiController_split_into_two_types_using_conventions : ConventionsAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : ConventionsAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] [InlineData( nameof( Values2Controller ), "3.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange @@ -37,7 +37,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -52,7 +52,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_url_versioned_ApiController_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a url segment.cs similarity index 84% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_url_versioned_ApiController_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a url segment.cs index 6ddb09f1..c2b3cbc6 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given/a_url_versioned_ApiController_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/Conventions/given a versioned ApiController using conventions/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -11,13 +11,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ApiController_using_conventions : ConventionsAcceptanceTest + public class when_using_a_url_segment : ConventionsAcceptanceTest { [Theory] [InlineData( "api/v1/helloworld", nameof( HelloWorldController ), "1" )] [InlineData( "api/v2/helloworld", nameof( HelloWorld2Controller ), "2" )] [InlineData( "api/v3/helloworld", nameof( HelloWorld2Controller ), "3" )] - public async Task _get_should_return_200( string requestUrl, string controllerName, string apiVersion ) + public async Task then_get_should_return_200( string requestUrl, string controllerName, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -36,7 +36,7 @@ public async Task _get_should_return_200( string requestUrl, string controllerNa [InlineData( "api/v1/helloworld/42", nameof( HelloWorldController ), "1" )] [InlineData( "api/v2/helloworld/42", nameof( HelloWorld2Controller ), "2" )] [InlineData( "api/v3/helloworld/42", nameof( HelloWorld2Controller ), "3" )] - public async Task _get_with_id_should_return_200( string requestUrl, string controllerName, string apiVersion ) + public async Task then_get_with_id_should_return_200( string requestUrl, string controllerName, string apiVersion ) { // arrange var example = new { controller = "", version = "", id = "" }; @@ -52,7 +52,7 @@ public async Task _get_with_id_should_return_200( string requestUrl, string cont } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given/an_ApiController_versioned_by_media_type_negotiation.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given a versioned ApiController/when using media type negotiation.cs similarity index 84% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given/an_ApiController_versioned_by_media_type_negotiation.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given a versioned ApiController/when using media type negotiation.cs index 387c96e1..df532263 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given/an_ApiController_versioned_by_media_type_negotiation.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Http/MediaTypeNegotiation/given a versioned ApiController/when using media type negotiation.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController { using FluentAssertions; using Microsoft.Web; @@ -13,12 +13,12 @@ using static System.Net.Http.Headers.MediaTypeWithQualityHeaderValue; using static System.Net.HttpStatusCode; - public class _an_ApiController_versioned_by_media_type_negotiation : MediaTypeNegotiationAcceptanceTest + public class when_using_media_type_negotiation : MediaTypeNegotiationAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -32,11 +32,10 @@ public async Task _get_should_return_200( string controller, string apiVersion ) // assert response.Headers.GetValues( "api-supported-versions" ).Single().Should().Be( "1.0, 2.0" ); content.ShouldBeEquivalentTo( new { controller = controller, version = apiVersion } ); - } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange Client.DefaultRequestHeaders.Accept.Add( Parse( "application/json;v=3.0" ) ); @@ -53,7 +52,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() [Theory] [InlineData( "api/values", nameof( Values2Controller ), "2.0" )] [InlineData( "api/helloworld", nameof( HelloWorldController ), "1.0" )] - public async Task _get_should_return_current_version_when_version_is_unspecified( string requestUrl, string controller, string apiVersion ) + public async Task then_get_should_allow_an_unspecified_version( string requestUrl, string controller, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -67,7 +66,7 @@ public async Task _get_should_return_current_version_when_version_is_unspecified } [Fact] - public async Task _post_should_return_201() + public async Task then_post_should_return_201() { // arrange var entity = new { text = "Test" }; diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpSimulatorHandler.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpSimulatorHandler.cs index c9027d86..1b6d63d3 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpSimulatorHandler.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/HttpSimulatorHandler.cs @@ -7,12 +7,9 @@ using System.Threading; using System.Threading.Tasks; - internal sealed class HttpSimulatorHandler : DelegatingHandler + sealed class HttpSimulatorHandler : DelegatingHandler { - internal HttpSimulatorHandler( HttpMessageHandler innerHandler ) - : base( innerHandler ) - { - } + internal HttpSimulatorHandler( HttpMessageHandler innerHandler ) : base( innerHandler ) { } protected override async Task SendAsync( HttpRequestMessage request, CancellationToken cancellationToken ) { @@ -21,7 +18,7 @@ protected override async Task SendAsync( HttpRequestMessage return await SimulateResponseOverTheWireAsync( response, cancellationToken ); } - private async Task SimulateRequestOverTheWireAsync( HttpRequestMessage request, CancellationToken cancellationToken ) + async Task SimulateRequestOverTheWireAsync( HttpRequestMessage request, CancellationToken cancellationToken ) { Contract.Requires( request != null ); Contract.Requires( Contract.Result>() != null ); @@ -39,7 +36,7 @@ private async Task SimulateRequestOverTheWireAsync( HttpRequ return await content.ReadAsHttpRequestMessageAsync( cancellationToken ); } - private async Task SimulateResponseOverTheWireAsync( HttpResponseMessage response, CancellationToken cancellationToken ) + async Task SimulateResponseOverTheWireAsync( HttpResponseMessage response, CancellationToken cancellationToken ) { Contract.Requires( response != null ); Contract.Requires( Contract.Result>() != null ); @@ -57,7 +54,7 @@ private async Task SimulateResponseOverTheWireAsync( HttpRe return await content.ReadAsHttpResponseMessageAsync( cancellationToken ); } - private static void SetMediaType( HttpContent content, string messageType ) + static void SetMediaType( HttpContent content, string messageType ) { Contract.Requires( content != null ); Contract.Requires( !string.IsNullOrEmpty( messageType ) ); diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.csproj b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.csproj new file mode 100644 index 00000000..8000adf5 --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.csproj @@ -0,0 +1,32 @@ + + + + net452 + $(DefineConstants);WEBAPI + Microsoft.AspNet.WebApi.Acceptance.Tests + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.xproj b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.xproj deleted file mode 100644 index 36934656..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Microsoft.AspNet.WebApi.Acceptance.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 5c31964d-ea8b-420b-9297-5adfefe54962 - Microsoft.Web - .\obj - .\bin\ - v4.5 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v1_orders_ApiController_using_convention_routing.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v1.cs similarity index 80% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v1_orders_ApiController_using_convention_routing.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v1.cs index 590e673d..5c7830f2 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v1_orders_ApiController_using_convention_routing.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v1.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_mixed_with_OData_controllers { using FluentAssertions; using Microsoft.Web; @@ -7,10 +7,10 @@ using System.Threading.Tasks; using Xunit; - public class _a_v1_orders_ApiController_using_convention_routing : AdvancedAcceptanceTest + public class when_orders_is_v1 : AdvancedAcceptanceTest { [Fact] - public async Task _get_should_return_200_without_version() + public async Task then_get_should_return_200_for_an_unspecified_version() { // arrange @@ -24,7 +24,7 @@ public async Task _get_should_return_200_without_version() } [Fact] - public async Task _get_should_return_200() + public async Task then_get_should_return_200() { // arrange @@ -38,7 +38,7 @@ public async Task _get_should_return_200() } [Fact] - public async Task _get_with_key_should_return_200_without_version() + public async Task then_get_with_key_should_return_200_for_an_unspecified_version() { // arrange @@ -52,7 +52,7 @@ public async Task _get_with_key_should_return_200_without_version() } [Fact] - public async Task _get_with_key_should_return_200() + public async Task then_get_with_key_should_return_200() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v3_orders_ApiController_using_attribute_routing.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v3.cs similarity index 77% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v3_orders_ApiController_using_attribute_routing.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v3.cs index fd5603a3..dcd62e4b 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v3_orders_ApiController_using_attribute_routing.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ApiController mixed with OData controllers/when orders is v3.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ApiController_mixed_with_OData_controllers { using FluentAssertions; using Microsoft.Web; @@ -7,10 +7,10 @@ using System.Threading.Tasks; using Xunit; - public class _a_v3_orders_ApiController_using_attribute_routing : AdvancedAcceptanceTest + public class when_orders_is_v3 : AdvancedAcceptanceTest { [Fact] - public async Task _get_should_return_200() + public async Task then_get_should_return_200() { // arrange @@ -24,7 +24,7 @@ public async Task _get_should_return_200() } [Fact] - public async Task _get_with_key_should_return_200_without_version() + public async Task then_get_with_key_should_return_200_for_an_unspecified_version() { // arrange @@ -37,4 +37,4 @@ public async Task _get_with_key_should_return_200_without_version() order.ShouldBeEquivalentTo( new { Id = 42, Customer = "Customer v3.0" } ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v2_orders_ODataController.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when orders is v2.cs similarity index 80% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v2_orders_ODataController.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when orders is v2.cs index 257ec780..0e4dae74 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_v2_orders_ODataController.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when orders is v2.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController_mixed_Web_API_controllers { using FluentAssertions; using Microsoft.Web; @@ -7,10 +7,10 @@ using System.Threading.Tasks; using Xunit; - public class _a_v2_orders_ODataController : AdvancedAcceptanceTest + public class when_using_OData_for_orders_in_v2 : AdvancedAcceptanceTest { [Fact] - public async Task _get_should_return_200() + public async Task then_get_should_return_200() { // arrange @@ -24,7 +24,7 @@ public async Task _get_should_return_200() } [Fact] - public async Task _get_with_key_should_return_200() + public async Task then_get_with_key_should_return_200() { // arrange @@ -37,4 +37,4 @@ public async Task _get_with_key_should_return_200() order.ShouldBeEquivalentTo( new { id = 42, customer = "Customer v2.0" }, options => options.ExcludingMissingMembers() ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is any version.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is any version.cs new file mode 100644 index 00000000..aea110db --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is any version.cs @@ -0,0 +1,29 @@ +namespace given_a_versioned_ODataController_mixed_Web_API_controllers +{ + using FluentAssertions; + using Microsoft.Web; + using Microsoft.Web.OData.Advanced; + using System; + using System.Net.Http; + using System.Threading.Tasks; + using Xunit; + using static System.Net.HttpStatusCode; + + public class when_people_is_any_version : AdvancedAcceptanceTest + { + [Fact] + public async Task then_patch_should_return_400_for_an_unsupported_version() + { + // arrange + var person = new { lastName = "Me" }; + + // act + var response = await PatchAsync( $"api/people(42)?api-version=4.0", person ); + var content = await response.Content.ReadAsAsync(); + + // assert + response.StatusCode.Should().Be( BadRequest ); + content.Error.Code.Should().Be( "UnsupportedApiVersion" ); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v1.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v1.cs new file mode 100644 index 00000000..028413fa --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v1.cs @@ -0,0 +1,65 @@ +namespace given_a_versioned_ODataController_mixed_Web_API_controllers +{ + using FluentAssertions; + using Microsoft.Web; + using Microsoft.Web.OData.Advanced; + using System; + using System.Net.Http; + using System.Threading.Tasks; + using Xunit; + using static System.Net.HttpStatusCode; + + public class when_people_is_v1 : AdvancedAcceptanceTest + { + [Theory] + [InlineData( "api/people" )] + [InlineData( "api/people?api-version=1.0" )] + public async Task then_get_should_return_200( string requestUrl ) + { + // arrange + var example = new { value = new[] { new { id = 0, firstName = "", lastName = "" } } }; + + // act + var response = await Client.GetAsync( requestUrl ); + var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + people.value.ShouldBeEquivalentTo( + new[] { new { id = 1, firstName = "Bill", lastName = "Mei" } }, + options => options.ExcludingMissingMembers() ); + } + + [Theory] + [InlineData( "api/people(42)" )] + [InlineData( "api/people(42)?api-version=1.0" )] + public async Task then_get_with_key_should_return_200( string requestUrl ) + { + // arrange + var example = new { id = 0, firstName = "", lastName = "" }; + + // act + var response = await Client.GetAsync( requestUrl ); + var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + order.ShouldBeEquivalentTo( + new { id = 42, firstName = "Bill", lastName = "Mei" }, + options => options.ExcludingMissingMembers() ); + } + + [Fact] + public async Task then_patch_should_return_405_if_supported_in_any_version() + { + // arrange + var person = new { lastName = "Me" }; + + // act + var response = await PatchAsync( $"api/people(42)?api-version=1.0", person ); + var content = await response.Content.ReadAsAsync(); + + // assert + response.StatusCode.Should().Be( MethodNotAllowed ); + content.Error.Code.Should().Be( "UnsupportedApiVersion" ); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v2.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v2.cs new file mode 100644 index 00000000..36ecc148 --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v2.cs @@ -0,0 +1,72 @@ +namespace given_a_versioned_ODataController_mixed_Web_API_controllers +{ + using FluentAssertions; + using Microsoft.Web; + using Microsoft.Web.OData.Advanced; + using System; + using System.Net.Http; + using System.Threading.Tasks; + using Xunit; + using static System.Net.HttpStatusCode; + + public class when_people_is_v2 : AdvancedAcceptanceTest + { + [Fact] + public async Task then_get_should_return_200() + { + // arrange + var example = new { value = new[] { new { id = 0, firstName = "", lastName = "", email = "" } } }; + + // act + var response = await Client.GetAsync( "api/people?api-version=2.0" ); + var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + people.value.ShouldBeEquivalentTo( + new[] { new { id = 1, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com" } }, + options => options.ExcludingMissingMembers() ); + } + + [Fact] + public async Task then_get_with_key_should_return_200() + { + // arrange + var example = new { id = 0, firstName = "", lastName = "", email = "" }; + + // act + var response = await Client.GetAsync( "api/people(42)?api-version=2.0" ); + var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + order.ShouldBeEquivalentTo( + new { id = 42, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com" }, + options => options.ExcludingMissingMembers() ); + } + + [Fact] + public async Task then_patch_should_return_204() + { + // arrange + var person = new { email = "bmei@somewhere.com" }; + + // act + var response = await PatchAsync( "api/people(42)?api-version=2.0", person ); + + // assert + response.StatusCode.Should().Be( NoContent ); + } + + [Fact] + public async Task then_patch_should_return_400_while_updating_member_that_does_not_exist_in_version() + { + // arrange + var person = new { phone = "bmei@somewhere.com" }; + + // act + var response = await PatchAsync( "api/people(42)?api-version=2.0", person ); + + // assert + response.StatusCode.Should().Be( BadRequest ); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v3.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v3.cs new file mode 100644 index 00000000..fc86689f --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given a versioned ODataController mixed Web API controllers/when people is v3.cs @@ -0,0 +1,61 @@ +namespace given_a_versioned_ODataController_mixed_Web_API_controllers +{ + using FluentAssertions; + using Microsoft.Web; + using Microsoft.Web.OData.Advanced; + using System; + using System.Net.Http; + using System.Threading.Tasks; + using Xunit; + using static System.Net.HttpStatusCode; + + public class when_people_is_v3 : AdvancedAcceptanceTest + { + [Fact] + public async Task then_get_should_return_200() + { + // arrange + var example = new { value = new[] { new { id = 0, firstName = "", lastName = "", email = "", phone = "" } } }; + + // act + var response = await Client.GetAsync( "api/people?api-version=3.0" ); + var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + people.value.ShouldBeEquivalentTo( + new[] { new { id = 1, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com", phone = "555-555-5555" } }, + options => options.ExcludingMissingMembers() ); + } + + [Fact] + public async Task then_get_with_key_should_return_200() + { + // arrange + var example = new { id = 0, firstName = "", lastName = "", email = "", phone = "" }; + + // act + var response = await Client.GetAsync( "api/people(42)?api-version=3.0" ); + var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); + + // assert + order.ShouldBeEquivalentTo( + new { id = 42, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com", phone = "555-555-5555" }, + options => options.ExcludingMissingMembers() ); + } + + [Fact] + public async Task then_patch_should_return_405_if_supported_in_any_version() + { + // arrange + var person = new { lastName = "Me" }; + + // act + var response = await PatchAsync( $"api/people(42)?api-version=3.0", person ); + var content = await response.Content.ReadAsAsync(); + + // assert + response.StatusCode.Should().Be( MethodNotAllowed ); + content.Error.Code.Should().Be( "UnsupportedApiVersion" ); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_mix-in_people_ODataController_split_into_two_types.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_mix-in_people_ODataController_split_into_two_types.cs deleted file mode 100644 index 7801a491..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Advanced/given/a_mix-in_people_ODataController_split_into_two_types.cs +++ /dev/null @@ -1,172 +0,0 @@ -namespace given -{ - using FluentAssertions; - using Microsoft.Web; - using Microsoft.Web.OData.Advanced; - using System; - using System.Net.Http; - using System.Threading.Tasks; - using Xunit; - using static System.Net.HttpStatusCode; - - public class _a_mixX2Din_people_ODataController_split_into_two_types : AdvancedAcceptanceTest - { - [Theory] - [InlineData( "api/people" )] - [InlineData( "api/people?api-version=1.0" )] - public async Task _get_should_return_200_for_v1( string requestUrl ) - { - // arrange - var example = new { value = new[] { new { id = 0, firstName = "", lastName = "" } } }; - - // act - var response = await Client.GetAsync( requestUrl ); - var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - people.value.ShouldBeEquivalentTo( - new[] { new { id = 1, firstName = "Bill", lastName = "Mei" } }, - options => options.ExcludingMissingMembers() ); - } - - [Theory] - [InlineData( "api/people(42)" )] - [InlineData( "api/people(42)?api-version=1.0" )] - public async Task _get_with_key_should_return_200_for_v1( string requestUrl ) - { - // arrange - var example = new { id = 0, firstName = "", lastName = "" }; - - // act - var response = await Client.GetAsync( requestUrl ); - var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - order.ShouldBeEquivalentTo( - new { id = 42, firstName = "Bill", lastName = "Mei" }, - options => options.ExcludingMissingMembers() ); - } - - [Fact] - public async Task _get_should_return_200_for_v2() - { - // arrange - var example = new { value = new[] { new { id = 0, firstName = "", lastName = "", email = "" } } }; - - // act - var response = await Client.GetAsync( "api/people?api-version=2.0" ); - var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - people.value.ShouldBeEquivalentTo( - new[] { new { id = 1, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com" } }, - options => options.ExcludingMissingMembers() ); - } - - [Fact] - public async Task _get_with_key_should_return_200_for_v2() - { - // arrange - var example = new { id = 0, firstName = "", lastName = "", email = "" }; - - // act - var response = await Client.GetAsync( "api/people(42)?api-version=2.0" ); - var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - order.ShouldBeEquivalentTo( - new { id = 42, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com" }, - options => options.ExcludingMissingMembers() ); - } - - [Fact] - public async Task _get_should_return_200_for_v3() - { - // arrange - var example = new { value = new[] { new { id = 0, firstName = "", lastName = "", email = "", phone = "" } } }; - - // act - var response = await Client.GetAsync( "api/people?api-version=3.0" ); - var people = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - people.value.ShouldBeEquivalentTo( - new[] { new { id = 1, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com", phone = "555-555-5555" } }, - options => options.ExcludingMissingMembers() ); - } - - [Fact] - public async Task _get_with_key_should_return_200_for_v3() - { - // arrange - var example = new { id = 0, firstName = "", lastName = "", email = "", phone = "" }; - - // act - var response = await Client.GetAsync( "api/people(42)?api-version=3.0" ); - var order = await response.EnsureSuccessStatusCode().Content.ReadAsExampleAsync( example ); - - // assert - order.ShouldBeEquivalentTo( - new { id = 42, firstName = "Bill", lastName = "Mei", email = "bill.mei@somewhere.com", phone = "555-555-5555" }, - options => options.ExcludingMissingMembers() ); - } - - [Fact] - public async Task _patch_should_return_204() - { - // arrange - var person = new { email = "bmei@somewhere.com" }; - - // act - var response = await PatchAsync( "api/people(42)?api-version=2.0", person ); - - // assert - response.StatusCode.Should().Be( NoContent ); - } - - [Fact] - public async Task _patch_should_return_400_when_updating_member_that_does_not_exist_in_api_version() - { - // arrange - var person = new { phone = "bmei@somewhere.com" }; - - // act - var response = await PatchAsync( "api/people(42)?api-version=2.0", person ); - - // assert - response.StatusCode.Should().Be( BadRequest ); - } - - [Theory] - [InlineData( "1.0" )] - [InlineData( "3.0" )] - public async Task _patch_should_return_405_when_version_could_be_supported( string apiVersion ) - { - // arrange - var person = new { lastName = "Me" }; - - // act - var response = await PatchAsync( $"api/people(42)?api-version={apiVersion}", person ); - var content = await response.Content.ReadAsAsync(); - - // assert - response.StatusCode.Should().Be( MethodNotAllowed ); - content.Error.Code.Should().Be( "UnsupportedApiVersion" ); - } - - [Fact] - public async Task _patch_should_return_400_when_version_is_unsupported() - { - // arrange - var person = new { lastName = "Me" }; - - // act - var response = await PatchAsync( $"api/people(42)?api-version=4.0", person ); - var content = await response.Content.ReadAsAsync(); - - // assert - response.StatusCode.Should().Be( BadRequest ); - content.Error.Code.Should().Be( "UnsupportedApiVersion" ); - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/BasicAcceptanceTest.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/BasicAcceptanceTest.cs index 01d1fd94..020cfaa4 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/BasicAcceptanceTest.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/BasicAcceptanceTest.cs @@ -38,7 +38,7 @@ protected BasicAcceptanceTest() } [Fact] - public async Task _service_document_should_return_400_for_unsupported_url_api_version() + public async Task service_document_should_return_400_for_unsupported_url_api_version() { // arrange var requestUrl = $"v4"; @@ -53,7 +53,7 @@ public async Task _service_document_should_return_400_for_unsupported_url_api_ve } [Fact] - public async Task _metadata_should_return_400_for_unsupported_url_api_version() + public async Task metadata_should_return_400_for_unsupported_url_api_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController_split_into_two_types.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string and split into two types.cs similarity index 83% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController_split_into_two_types.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string and split into two types.cs index d70ebcbf..365a1f08 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController_split_into_two_types.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController { using FluentAssertions; using Microsoft.Web; @@ -9,7 +9,7 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ODataController_split_into_two_types : BasicAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : BasicAcceptanceTest { [Theory] [InlineData( "api/people?api-version=1.0" )] @@ -18,7 +18,7 @@ public class _a_query_string_versioned_ODataController_split_into_two_types : Ba [InlineData( "api/people(42)?api-version=2.0" )] [InlineData( "api/people?api-version=3.0" )] [InlineData( "api/people(42)?api-version=3.0" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -31,7 +31,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -46,7 +46,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _patch_should_return_204() + public async Task then_patch_should_return_204() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -61,7 +61,7 @@ public async Task _patch_should_return_204() [Theory] [InlineData( "api/people(42)?api-version=1.0" )] [InlineData( "api/people(42)?api-version=3.0" )] - public async Task _patch_should_return_405_when_version_could_be_supported( string requestUrl ) + public async Task then_patch_should_return_405_if_supported_in_any_version( string requestUrl ) { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -76,7 +76,7 @@ public async Task _patch_should_return_405_when_version_could_be_supported( stri } [Fact] - public async Task _patch_should_return_400_when_version_is_unsupported() + public async Task then_patch_should_return_400_for_an_unsupported_version() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -91,7 +91,7 @@ public async Task _patch_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string.cs similarity index 80% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string.cs index c74117f0..a5274020 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_query_string_versioned_ODataController.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController { using FluentAssertions; using Microsoft.Web; @@ -9,12 +9,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ODataController : BasicAcceptanceTest + public class when_using_a_query_string : BasicAcceptanceTest { [Theory] [InlineData( "api/orders?api-version=1.0" )] [InlineData( "api/orders(42)?api-version=1.0" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -27,7 +27,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -42,7 +42,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController_split_into_two_types.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment and split into two types.cs similarity index 82% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController_split_into_two_types.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment and split into two types.cs index f8a39efd..d26e7d80 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController_split_into_two_types.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController { using FluentAssertions; using Microsoft.Web; @@ -9,7 +9,7 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ODataController_split_into_two_types : BasicAcceptanceTest + public class when_using_a_url_segment_and_split_into_two_types : BasicAcceptanceTest { [Theory] [InlineData( "v1/people" )] @@ -18,7 +18,7 @@ public class _a_url_versioned_ODataController_split_into_two_types : BasicAccept [InlineData( "v2/people(42)" )] [InlineData( "v3/people" )] [InlineData( "v3/people(42)" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -31,7 +31,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _patch_should_return_204() + public async Task then_patch_should_return_204() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -46,7 +46,7 @@ public async Task _patch_should_return_204() [Theory] [InlineData( "v1/people(42)" )] [InlineData( "v3/people(42)" )] - public async Task _patch_should_return_405_when_version_could_be_supported( string requestUrl ) + public async Task then_patch_should_return_405_if_supported_in_any_version( string requestUrl ) { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -61,7 +61,7 @@ public async Task _patch_should_return_405_when_version_could_be_supported( stri } [Fact] - public async Task _patch_should_return_400_when_version_is_unsupported() + public async Task then_patch_should_return_400_for_an_unsupported_version() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment.cs similarity index 78% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment.cs index ed7f5754..5f28ab5b 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given/a_url_versioned_ODataController.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController { using FluentAssertions; using Microsoft.Web; @@ -9,12 +9,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ODataController : BasicAcceptanceTest + public class when_using_a_url_segment : BasicAcceptanceTest { [Theory] [InlineData( "v1/orders" )] [InlineData( "v1/orders(42)" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -27,7 +27,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/OrderModelConfiguration.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/OrderModelConfiguration.cs index a9d1be97..cda5bc2e 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/OrderModelConfiguration.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/OrderModelConfiguration.cs @@ -7,24 +7,17 @@ public class OrderModelConfiguration : IModelConfiguration { - private static readonly ApiVersion V1 = new ApiVersion( 1, 0 ); - private readonly ApiVersion supportedApiVersion; + static readonly ApiVersion V1 = new ApiVersion( 1, 0 ); + readonly ApiVersion supportedApiVersion; - public OrderModelConfiguration() : this( V1 ) - { - } + public OrderModelConfiguration() : this( V1 ) { } - public OrderModelConfiguration( ApiVersion supportedApiVersion ) - { - this.supportedApiVersion = supportedApiVersion; - } + public OrderModelConfiguration( ApiVersion supportedApiVersion ) => this.supportedApiVersion = supportedApiVersion; - private EntityTypeConfiguration ConfigureCurrent( ODataModelBuilder builder ) + EntityTypeConfiguration ConfigureCurrent( ODataModelBuilder builder ) { var order = builder.EntitySet( "Orders" ).EntityType; - order.HasKey( p => p.Id ); - return order; } diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/PersonModelConfiguration.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/PersonModelConfiguration.cs index a4a70ec0..45db2f24 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/PersonModelConfiguration.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Configuration/PersonModelConfiguration.cs @@ -7,21 +7,19 @@ public class PersonModelConfiguration : IModelConfiguration { - private void ConfigureV1( ODataModelBuilder builder ) + void ConfigureV1( ODataModelBuilder builder ) { var person = ConfigureCurrent( builder ); person.Ignore( p => p.Email ); person.Ignore( p => p.Phone ); } - private void ConfigureV2( ODataModelBuilder builder ) => ConfigureCurrent( builder ).Ignore( p => p.Phone ); + void ConfigureV2( ODataModelBuilder builder ) => ConfigureCurrent( builder ).Ignore( p => p.Phone ); - private EntityTypeConfiguration ConfigureCurrent( ODataModelBuilder builder ) + EntityTypeConfiguration ConfigureCurrent( ODataModelBuilder builder ) { var person = builder.EntitySet( "People" ).EntityType; - person.HasKey( p => p.Id ); - return person; } diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_split_into_two_types_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string and split into two types.cs similarity index 83% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_split_into_two_types_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string and split into two types.cs index 7e8f1f19..1b16d0be 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_split_into_two_types_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -9,7 +9,7 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ODataController_split_into_two_types_using_conventions : ConventionsAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : ConventionsAcceptanceTest { [Theory] [InlineData( "api/people?api-version=1.0" )] @@ -18,7 +18,7 @@ public class _a_query_string_versioned_ODataController_split_into_two_types_usin [InlineData( "api/people(42)?api-version=2.0" )] [InlineData( "api/people?api-version=3.0" )] [InlineData( "api/people(42)?api-version=3.0" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -31,7 +31,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -46,7 +46,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _patch_should_return_204() + public async Task then_patch_should_return_204() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -61,7 +61,7 @@ public async Task _patch_should_return_204() [Theory] [InlineData( "api/people(42)?api-version=1.0" )] [InlineData( "api/people(42)?api-version=3.0" )] - public async Task _patch_should_return_405_when_version_could_be_supported( string requestUrl ) + public async Task then_patch_should_return_405_if_supported_in_any_version( string requestUrl ) { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -76,7 +76,7 @@ public async Task _patch_should_return_405_when_version_could_be_supported( stri } [Fact] - public async Task _patch_should_return_400_when_version_is_unsupported() + public async Task then_patch_should_return_400_for_an_unsupported_version() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -91,7 +91,7 @@ public async Task _patch_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string.cs similarity index 79% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string.cs index 74de6067..d9f589ce 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_query_string_versioned_ODataController_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a query string.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -9,12 +9,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_ODataController_using_conventions : ConventionsAcceptanceTest + public class when_using_a_query_string : ConventionsAcceptanceTest { [Theory] [InlineData( "api/orders?api-version=1.0" )] [InlineData( "api/orders(42)?api-version=1.0" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -27,7 +27,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -42,7 +42,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_split_into_two_types_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment and split into two types.cs similarity index 82% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_split_into_two_types_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment and split into two types.cs index 1a0e6f73..f2860ac9 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_split_into_two_types_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -9,7 +9,7 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ODataController_split_into_two_types_using_conventions : ConventionsAcceptanceTest + public class when_using_a_url_segment_and_split_into_two_types : ConventionsAcceptanceTest { [Theory] [InlineData( "v1/people" )] @@ -18,7 +18,7 @@ public class _a_url_versioned_ODataController_split_into_two_types_using_convent [InlineData( "v2/people(42)" )] [InlineData( "v3/people" )] [InlineData( "v3/people(42)" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -31,7 +31,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _patch_should_return_204() + public async Task then_patch_should_return_204() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -46,7 +46,7 @@ public async Task _patch_should_return_204() [Theory] [InlineData( "v1/people(42)" )] [InlineData( "v3/people(42)" )] - public async Task _patch_should_return_405_when_version_could_be_supported( string requestUrl ) + public async Task then_patch_should_return_405_if_supported_in_any_version( string requestUrl ) { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; @@ -61,7 +61,7 @@ public async Task _patch_should_return_405_when_version_could_be_supported( stri } [Fact] - public async Task _patch_should_return_400_when_version_is_unsupported() + public async Task then_patch_should_return_400_for_an_unsupported_version() { // arrange var person = new { id = 42, firstName = "John", lastName = "Doe", email = "john.doe@somewhere.com" }; diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_using_conventions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment.cs similarity index 77% rename from test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_using_conventions.cs rename to test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment.cs index c6fde96e..18290136 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given/a_url_versioned_ODataController_using_conventions.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Conventions/given a versioned ODataController using conventions/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_ODataController_using_conventions { using FluentAssertions; using Microsoft.Web; @@ -9,12 +9,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_ODataController_using_conventions : ConventionsAcceptanceTest + public class when_using_a_url_segment : ConventionsAcceptanceTest { [Theory] [InlineData( "v1/orders" )] [InlineData( "v1/orders(42)" )] - public async Task _get_should_return_200( string requestUrl ) + public async Task then_get_should_return_200( string requestUrl ) { // arrange @@ -27,7 +27,7 @@ public async Task _get_should_return_200( string requestUrl ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/ODataAcceptanceTest.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/ODataAcceptanceTest.cs index 45bf3b55..8c0c8220 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/ODataAcceptanceTest.cs +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/ODataAcceptanceTest.cs @@ -19,7 +19,7 @@ protected ODataAcceptanceTest() } [Fact] - public async Task _service_document_should_return_result_without_api_version() + public async Task then_the_service_document_should_allow_an_unspecified_version() { // arrange @@ -35,7 +35,7 @@ public async Task _service_document_should_return_result_without_api_version() [InlineData( "1.0" )] [InlineData( "2.0" )] [InlineData( "3.0" )] - public async Task _service_document_should_return_api_version_specific_result( string apiVersion ) + public async Task then_the_service_document_should_be_versionX2Dspecific( string apiVersion ) { // arrange var requestUrl = $"api?api-version={apiVersion}"; @@ -48,7 +48,7 @@ public async Task _service_document_should_return_api_version_specific_result( s } [Fact] - public async Task _service_document_should_return_400_for_unsupported_query_string_api_version() + public async Task then_the_service_document_should_return_400_for_an_unsupported_version() { // arrange @@ -63,7 +63,7 @@ public async Task _service_document_should_return_400_for_unsupported_query_stri } [Fact] - public async Task _metadata_should_return_result_without_api_version() + public async Task then_X24metadata_should_allow_an_unspecified_version() { // arrange @@ -79,7 +79,7 @@ public async Task _metadata_should_return_result_without_api_version() [InlineData( "1.0" )] [InlineData( "2.0" )] [InlineData( "3.0" )] - public async Task _metadata_should_return_api_version_specific_result( string apiVersion ) + public async Task then_X24metadata_should_be_versionX2Dspecific( string apiVersion ) { // arrange var requestUrl = $"api/$metadata?api-version={apiVersion}"; @@ -92,7 +92,7 @@ public async Task _metadata_should_return_api_version_specific_result( string ap } [Fact] - public async Task _metadata_should_return_400_for_unsupported_query_string_api_version() + public async Task then_X24metadata_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiErrorResponse.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiErrorResponse.cs deleted file mode 100644 index 02086950..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiErrorResponse.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Microsoft.Web -{ - using System; - - public class OneApiErrorResponse - { - public OneApiError Error { get; set; } - } -} diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiInnerError.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiInnerError.cs deleted file mode 100644 index b56dddd3..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/OneApiInnerError.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Microsoft.Web -{ - using System; - - public class OneApiInnerError - { - public string Code { get; set; } - - public string Message { get; set; } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 777decd8..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.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("Microsoft.AspNet.WebApi.Acceptance.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("5c31964d-ea8b-420b-9297-5adfefe54962")] diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/TaskExtensions.cs b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/TaskExtensions.cs deleted file mode 100644 index f3d07f69..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/TaskExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Microsoft.Web -{ - using System; - using System.Net.Http; - using System.Threading.Tasks; - - internal static class TaskExtensions - { - internal static async Task EnsureSuccessStatusCode( this Task task ) - { - var response = await task; - response.EnsureSuccessStatusCode(); - return response; - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/app.config b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/app.config index c286bd1b..4d288072 100644 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/app.config +++ b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/app.config @@ -1,6 +1,21 @@  - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/project.json b/test/Microsoft.AspNet.WebApi.Acceptance.Tests/project.json deleted file mode 100644 index 144e7724..00000000 --- a/test/Microsoft.AspNet.WebApi.Acceptance.Tests/project.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.AspNet.OData": "5.9.1", - "FluentAssertions": "4.19.0", - "more.xunit": "2.1.0", - "xunit.runner.visualstudio": "2.1.0", - "Moq": "4.7.0", - "Microsoft.AspNet.WebApi.Core": "5.2.3", - "Microsoft.AspNet.WebApi.Versioning": { - "target": "project", - "version": "" - }, - "Microsoft.AspNet.OData.Versioning": { - "target": "project", - "version": "" - } - }, - - "frameworks": { - "net45": { - "dependencies": { - "System.Runtime": "4.0.0", - "System.Threading.Tasks": "4.0.0" - }, - "frameworkAssemblies": { - "System.ComponentModel.DataAnnotations": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionAttributeTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionAttributeTest.cs index 303e0145..e5a2efed 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionAttributeTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionAttributeTest.cs @@ -23,4 +23,4 @@ public void api_versions_attribute_should_sort_specified_versions() versions.Should().BeEquivalentTo( expected ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionTest.cs index 60ac69f4..e9642909 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ApiVersionTest.cs @@ -697,4 +697,4 @@ public void api_version_1_ge_api_version_2_should_return_expected_result( string result.Should().Be( expected ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ControllerNameAttributeTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ControllerNameAttributeTest.cs index 06f35908..19512a2c 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ControllerNameAttributeTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ControllerNameAttributeTest.cs @@ -22,4 +22,4 @@ public void new_controller_name_attribute_should_set_name() attribute.Name.Should().Be( expected ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Controllers/ApiVersionActionSelectorTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Controllers/ApiVersionActionSelectorTest.cs index 0b4b2e86..bda0c3e8 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Controllers/ApiVersionActionSelectorTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Controllers/ApiVersionActionSelectorTest.cs @@ -13,13 +13,13 @@ public class ApiVersionActionSelectorTest { - private sealed class TestApiVersionActionSelector : ApiVersionActionSelector + sealed class TestApiVersionActionSelector : ApiVersionActionSelector { internal HttpActionDescriptor InvokeSelectActionVersion( HttpControllerContext controllerContext, IReadOnlyList candidateActions ) => SelectActionVersion( controllerContext, candidateActions ); } - private static HttpActionDescriptor CreateActionDescriptor( string version ) + static HttpActionDescriptor CreateActionDescriptor( string version ) { var configuration = new HttpConfiguration(); var controllerType = typeof( IHttpController ); @@ -76,4 +76,4 @@ public void select_action_version_should_return_expected_result( IReadOnlyList Get() => Task.FromResult( "Test" ); @@ -16,7 +16,7 @@ private sealed class Ambiguous1Controller : ApiController [ApiVersion( "1.0" )] [RoutePrefix( "api/test" )] - private sealed class Ambiguous2Controller : ApiController + sealed class Ambiguous2Controller : ApiController { [Route] public Task Get() => Task.FromResult( "Test" ); @@ -24,14 +24,14 @@ private sealed class Ambiguous2Controller : ApiController [ApiVersion( "1.0" )] [ControllerName( "Ambiguous" )] - private sealed class Ambiguous3Controller : ApiController + sealed class Ambiguous3Controller : ApiController { [Route] public Task Get() => Task.FromResult( "Test" ); } [ApiVersion( "1.0" )] - private sealed class AmbiguousController : ApiController + sealed class AmbiguousController : ApiController { [Route] public Task Get() => Task.FromResult( "Test" ); @@ -40,10 +40,10 @@ private sealed class AmbiguousController : ApiController [ApiVersionNeutral] [ControllerName( "Ambiguous" )] [RoutePrefix( "api/test" )] - private sealed class AmbiguousNeutralController : ApiController + sealed class AmbiguousNeutralController : ApiController { [Route] public Task Get() => Task.FromResult( "Test" ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Dispatcher/ApiVersionControllerSelectorTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Dispatcher/ApiVersionControllerSelectorTest.cs index c1c805a2..a3595fc7 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Dispatcher/ApiVersionControllerSelectorTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Dispatcher/ApiVersionControllerSelectorTest.cs @@ -25,7 +25,7 @@ public partial class ApiVersionControllerSelectorTest { - private HttpConfiguration AttributeRoutingEnabledConfiguration + HttpConfiguration AttributeRoutingEnabledConfiguration { get { @@ -51,7 +51,7 @@ public static IEnumerable ControllerNameData } } - private static Task ReadAsErrorByExampleAsync( HttpContent content, T example ) => content.ReadAsAsync(); + static Task ReadAsErrorByExampleAsync( HttpContent content, T example ) => content.ReadAsAsync(); [Theory] [MemberData( nameof( ControllerNameData ) )] diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.csproj b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.csproj new file mode 100644 index 00000000..74b926e9 --- /dev/null +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.csproj @@ -0,0 +1,29 @@ + + + + net452 + $(DefineConstants);WEBAPI + Microsoft.AspNet.WebApi.Versioning.Tests + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.xproj b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.xproj deleted file mode 100644 index e2facff1..00000000 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Microsoft.AspNet.WebApi.Versioning.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - aeb074e1-e57a-4dd3-a972-3625b367ce5d - Microsoft.Web.Http - .\obj - .\bin\ - v4.5 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index c586f928..00000000 --- a/test/Microsoft.AspNet.WebApi.Versioning.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("WebApi.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("aeb074e1-e57a-4dd3-a972-3625b367ce5d")] diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ReportApiVersionsAttributeTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ReportApiVersionsAttributeTest.cs index 10c0929b..267bde95 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/ReportApiVersionsAttributeTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/ReportApiVersionsAttributeTest.cs @@ -72,4 +72,4 @@ public void on_action_executing_should_not_add_headers_for_versionX2Dneutral_con context.Response.Headers.Contains( "api-deprecated-versions" ).Should().BeFalse(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AdminController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AdminController.cs index 0264f77a..6a00403d 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AdminController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AdminController.cs @@ -20,4 +20,4 @@ public class AdminController : ApiController [Route( "admin/inject" )] public IHttpActionResult Inject() => Ok(); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs index 5459e35c..b1557afa 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs @@ -14,4 +14,4 @@ public sealed class ApiVersionedRoute2Controller : ApiController public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRouteController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRouteController.cs index 42ed9c96..0c1ed8a3 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRouteController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/ApiVersionedRouteController.cs @@ -12,4 +12,4 @@ public sealed class ApiVersionedRouteController : ApiController { public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs index 63834e48..5136e5d5 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs @@ -17,4 +17,4 @@ public sealed class AttributeRoutedTest2Controller : ApiController [MapToApiVersion( "3.0" )] public Task GetV3() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs index 052496b7..e0324e50 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs @@ -13,4 +13,4 @@ public sealed class AttributeRoutedTest4Controller : ApiController [Route] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTestController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTestController.cs index ddc5210c..b838a0c3 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTestController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/AttributeRoutedTestController.cs @@ -13,4 +13,4 @@ public sealed class AttributeRoutedTestController : ApiController [Route( "{id}" )] public Task Get( string id ) => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/Conventions2Controller.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/Conventions2Controller.cs index 1150aad1..3234a4d0 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/Conventions2Controller.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/Conventions2Controller.cs @@ -17,4 +17,4 @@ public sealed class Conventions2Controller : ApiController [Route( "{id:int}" )] public Task Get( int id ) => Task.FromResult( Ok( $"Test {id} ({Request.GetRequestedApiVersion()})" ) ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/NeutralController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/NeutralController.cs index 965bb1a5..57bfae35 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/NeutralController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/NeutralController.cs @@ -9,11 +9,8 @@ [ApiVersionNeutral] public sealed class NeutralController : IHttpController { - public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) - { - throw new NotImplementedException(); - } + public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/OrdersController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/OrdersController.cs index 3a6c1dd5..e9c68d0c 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/OrdersController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/OrdersController.cs @@ -15,4 +15,4 @@ public class OrdersController : ApiController [MapToApiVersion( "2016-06-06" )] public Task Get_2016_06_06() => Task.FromResult( Ok( "Version 2016-06-06" ) ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestController.cs index 11ab0f84..5d37a603 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestController.cs @@ -8,11 +8,8 @@ public sealed class TestController : IHttpController { - public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) - { - throw new NotImplementedException(); - } + public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersion2Controller.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersion2Controller.cs index e1ee50f6..875596c6 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersion2Controller.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersion2Controller.cs @@ -13,10 +13,7 @@ [ApiVersion( "1.9", Deprecated = true )] public sealed class TestVersion2Controller : IHttpController { - public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) - { - throw new NotImplementedException(); - } + public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); public Task Get() => Task.FromResult( "Test" ); @@ -24,4 +21,4 @@ public Task ExecuteAsync( HttpControllerContext controllerC [MapToApiVersion( "3.0" )] public Task Get3() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersionNeutralController.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersionNeutralController.cs index bc393209..65f9b844 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersionNeutralController.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Simulators/TestVersionNeutralController.cs @@ -11,12 +11,9 @@ [RoutePrefix( "api/neutral" )] public sealed class TestVersionNeutralController : IHttpController { - public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) - { - throw new NotImplementedException(); - } + public Task ExecuteAsync( HttpControllerContext controllerContext, CancellationToken cancellationToken ) => throw new NotImplementedException(); [Route] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpActionDescriptorExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpActionDescriptorExtensionsTest.cs index 5c622824..337bc04f 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpActionDescriptorExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpActionDescriptorExtensionsTest.cs @@ -12,7 +12,7 @@ public class HttpActionDescriptorExtensionsTest { - private static IEnumerable CreateActionDescriptorData( Tuple[] runs ) + static IEnumerable CreateActionDescriptorData( Tuple[] runs ) { foreach ( var run in runs ) { @@ -117,4 +117,4 @@ public void get_api_versions_should_return_expected_action_descriptor_results( H declaredVersions.Should().BeEquivalentTo( expectedVersions ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpConfigurationExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpConfigurationExtensionsTest.cs index a543717b..520acbbe 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpConfigurationExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpConfigurationExtensionsTest.cs @@ -40,4 +40,4 @@ public void add_api_versioning_should_report_api_versions_when_option_is_enabled configuration.Filters.Single().Instance.Should().BeOfType(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpControllerDescriptorExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpControllerDescriptorExtensionsTest.cs index c06f2e27..f1c281b1 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpControllerDescriptorExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpControllerDescriptorExtensionsTest.cs @@ -213,4 +213,4 @@ public void get_deprecated_api_versions_should_return_expected_controller_descri deprecatedVersions.Should().BeEquivalentTo( expectedVersions ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpRequestMessageExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpRequestMessageExtensionsTest.cs index 6f024656..63acbbf2 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpRequestMessageExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/System.Web.Http/HttpRequestMessageExtensionsTest.cs @@ -100,4 +100,4 @@ public void get_requested_api_version_should_return_expected_value_from_header( request.ApiVersionProperties().ApiVersion.Should().Be( requestedVersion ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs index ce7921dc..8f506b9d 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs @@ -22,4 +22,4 @@ public void select_version_should_return_constant_value() selectedVersion.Should().Be( version ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionApiVersionConventionBuilderExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionApiVersionConventionBuilderExtensionsTest.cs index 682ae635..3735cfb5 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionApiVersionConventionBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionApiVersionConventionBuilderExtensionsTest.cs @@ -9,12 +9,9 @@ public class ActionApiVersionConventionBuilderExtensionsTest { - private sealed class TestActionApiVersionConventionBuilder : ActionApiVersionConventionBuilder + sealed class TestActionApiVersionConventionBuilder : ActionApiVersionConventionBuilder { - internal TestActionApiVersionConventionBuilder() - : base( new ControllerApiVersionConventionBuilder() ) - { - } + internal TestActionApiVersionConventionBuilder() : base( new ControllerApiVersionConventionBuilder() ) { } internal ICollection ProtectedMappedVersions => MappedVersions; } diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionConventionBuilderExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionConventionBuilderExtensionsTest.cs index f3afc1b5..14f67ca7 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionConventionBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ActionConventionBuilderExtensionsTest.cs @@ -60,4 +60,4 @@ public void action_should_throw_exception_when_func_delegate_expression_is_not_a .Message.Should().Be( "The expression 'c => c.Timeout' must refer to a controller action method." ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs index 604ccac3..089251f1 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs @@ -9,12 +9,12 @@ public class ApiVersionConventionBuilderTest { - private sealed class TestApiVersionConventionBuilder : ApiVersionConventionBuilder + sealed class TestApiVersionConventionBuilder : ApiVersionConventionBuilder { internal IDictionary> ProtectedControllerConventions => ControllerConventions; } - private sealed class StubController : ApiController + sealed class StubController : ApiController { public IHttpActionResult Get() => Ok(); } @@ -55,4 +55,4 @@ public void controller_should_return_existing_controller_builder_conventions() } ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderExtensionsTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderExtensionsTest.cs index af83483a..a6d716e8 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderExtensionsTest.cs @@ -9,7 +9,7 @@ public class ControllerApiVersionConventionBuilderExtensionsTest { - private sealed class TestControllerApiVersionConventionBuilder : ControllerApiVersionConventionBuilder + sealed class TestControllerApiVersionConventionBuilder : ControllerApiVersionConventionBuilder { internal ICollection ProtectedSupportedVersions => SupportedVersions; diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs index dbe2bf55..5699f796 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs @@ -2,7 +2,6 @@ { using FluentAssertions; using Moq; - using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reflection; @@ -12,14 +11,14 @@ public class ControllerApiVersionConventionBuilderTTest { - private sealed class TestControllerApiVersionConventionBuilder : ControllerApiVersionConventionBuilder + sealed class TestControllerApiVersionConventionBuilder : ControllerApiVersionConventionBuilder { internal bool ProtectedVersionNeutral => VersionNeutral; internal ActionApiVersionConventionBuilderCollection ProtectedActionBuilders => ActionBuilders; } - private sealed class UndecoratedController : ApiController + sealed class UndecoratedController : ApiController { public IHttpActionResult Get() => Ok(); } @@ -28,7 +27,7 @@ private sealed class UndecoratedController : ApiController [ApiVersion( "0.9", Deprecated = true )] [AdvertiseApiVersions( "3.0" )] [AdvertiseApiVersions( "3.0-Beta", Deprecated = true )] - private sealed class DecoratedController : ApiController + sealed class DecoratedController : ApiController { public IHttpActionResult Get() => Ok(); } diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs index d21526b6..bc0d1517 100644 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs +++ b/test/Microsoft.AspNet.WebApi.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs @@ -25,4 +25,4 @@ public void select_version_should_return_max_api_version( IEnumerable - - - - + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNet.WebApi.Versioning.Tests/project.json b/test/Microsoft.AspNet.WebApi.Versioning.Tests/project.json deleted file mode 100644 index b588bbd2..00000000 --- a/test/Microsoft.AspNet.WebApi.Versioning.Tests/project.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.AspNet.WebApi.Core": "5.2.3", - "FluentAssertions": "4.19.0", - "more.xunit": "2.1.0", - "xunit.runner.visualstudio": "2.1.0", - "Moq": "4.7.0", - "Microsoft.AspNet.WebApi.Versioning": { - "target": "project", - "version": "" - } - }, - - "frameworks": { - "net45": { - "dependencies": { - "System.Runtime": "4.0.0", - "System.Threading.Tasks": "4.0.0" - } - } - }, - - "buildOptions": { - "compile": [ "**/*.cs", "../common/**/*.cs" ], - "define": [ "WEBAPI" ] - } -} diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/AcceptanceTest.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/AcceptanceTest.cs index 925e808c..051e02ab 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/AcceptanceTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/AcceptanceTest.cs @@ -8,31 +8,17 @@ using System; using System.Collections.Generic; using System.Net.Http; - using System.Net.Http.Formatting; - using System.Net.Http.Headers; using System.Reflection; - using System.Threading.Tasks; using TestHost; using Versioning; using Xunit; using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor; - using static System.Net.Http.HttpMethod; - [Trait( "Kind", "Acceptance" )] [Trait( "Framework", "ASP.NET Core" )] - public abstract class AcceptanceTest : IDisposable + public abstract partial class AcceptanceTest : IDisposable { - const string JsonMediaType = "application/json"; - static readonly HttpMethod Patch = new HttpMethod( "PATCH" ); readonly Lazy server; readonly Lazy client; - readonly FilteredControllerFeatureProvider filteredControllerTypes = new FilteredControllerFeatureProvider(); - bool disposed; - - ~AcceptanceTest() - { - Dispose( false ); - } protected AcceptanceTest() { @@ -71,12 +57,6 @@ protected virtual void Dispose( bool disposing ) } } - public void Dispose() - { - Dispose( true ); - GC.SuppressFinalize( this ); - } - TestServer CreateServer() { var builder = new WebHostBuilder() @@ -106,48 +86,6 @@ void OnConfigureServices( IServiceCollection services ) protected abstract void OnAddApiVersioning( ApiVersioningOptions options ); - protected virtual void OnConfigureRoutes( IRouteBuilder routeBuilder ) - { - } - - HttpRequestMessage CreateRequest( string requestUri, TEntity entity, HttpMethod method ) - { - var request = new HttpRequestMessage( method, requestUri ); - - if ( !Equals( entity, default( TEntity ) ) ) - { - var formatter = new JsonMediaTypeFormatter(); - request.Content = new ObjectContent( entity, formatter, JsonMediaType ); - } - - Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); - - return request; - } - - HttpRequestMessage CreateRequest( string requestUri, HttpContent content, HttpMethod method ) - { - var request = new HttpRequestMessage( method, requestUri ) { Content = content }; - - Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue( JsonMediaType ) ); - - return request; - } - - protected virtual Task GetAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Get ) ); - - protected virtual Task PostAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Post ) ); - - protected virtual Task PostAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Post ) ); - - protected virtual Task PutAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Put ) ); - - protected virtual Task PutAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Put ) ); - - protected virtual Task PatchAsync( string requestUri, TEntity entity ) => Client.SendAsync( CreateRequest( requestUri, entity, Patch ) ); - - protected virtual Task PatchAsync( string requestUri, HttpContent content ) => Client.SendAsync( CreateRequest( requestUri, content, Patch ) ); - - protected virtual Task DeleteAsync( string requestUri ) => Client.SendAsync( CreateRequest( requestUri, default( object ), Delete ) ); + protected virtual void OnConfigureRoutes( IRouteBuilder routeBuilder ) { } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/Values2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/Values2Controller.cs index a58b27fb..8c316256 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/Values2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/Values2Controller.cs @@ -10,4 +10,4 @@ public class Values2Controller : Controller [HttpGet] public IActionResult Get() => Ok( new { Controller = nameof( Values2Controller ), Version = HttpContext.GetRequestedApiVersion().ToString() } ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_query_string_versioned_Controller_split_into_two_types.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a query string and split into two types.cs similarity index 82% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_query_string_versioned_Controller_split_into_two_types.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a query string and split into two types.cs index d8a58617..342d9ca6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_query_string_versioned_Controller_split_into_two_types.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -11,12 +11,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_Controller_split_into_two_types : BasicAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : BasicAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange @@ -36,7 +36,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -51,7 +51,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_url_versioned_Controller.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a url segment.cs similarity index 85% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_url_versioned_Controller.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a url segment.cs index 3e6a2759..587534b3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given/a_url_versioned_Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/given a versioned Controller/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -12,12 +12,12 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_Controller : BasicAcceptanceTest + public class when_using_a_url_segment : BasicAcceptanceTest { [Theory] [InlineData( "api/v1/helloworld", null )] [InlineData( "api/v1/helloworld/42", "42" )] - public async Task _get_should_return_200( string requestUrl, string id ) + public async Task then_get_should_return_200( string requestUrl, string id ) { // arrange var body = new Dictionary() @@ -41,7 +41,7 @@ public async Task _get_should_return_200( string requestUrl, string id ) } [Fact] - public async Task _post_should_return_201() + public async Task then_post_should_return_201() { // arrange var entity = default( object ); @@ -54,7 +54,7 @@ public async Task _post_should_return_201() } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_query_string_versioned_Controller_per_namespace.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a query string.cs similarity index 83% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_query_string_versioned_Controller_per_namespace.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a query string.cs index 085b9b0c..7719523c 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_query_string_versioned_Controller_per_namespace.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a query string.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller_per_namespace { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -9,13 +9,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_Controller_per_namespace : ByNamespaceAcceptanceTest + public class when_using_a_query_string : ByNamespaceAcceptanceTest { [Theory] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController", "1.0" )] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V2.AgreementsController", "2.0" )] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V3.AgreementsController", "3.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { controller = "", apiVersion = "", accountId = "" }; @@ -30,7 +30,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -45,7 +45,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_url_versioned_Controller_per_namespace.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a url segment.cs similarity index 83% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_url_versioned_Controller_per_namespace.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a url segment.cs index 090406c9..51b38df5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given/a_url_versioned_Controller_per_namespace.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/ByNamespace/given a versioned Controller per namespace/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller_per_namespace { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -9,13 +9,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_Controller_per_namespace : ByNamespaceAcceptanceTest + public class when_using_a_url_segment : ByNamespaceAcceptanceTest { [Theory] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V1.AgreementsController", "1" )] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V2.AgreementsController", "2" )] [InlineData( "Microsoft.AspNetCore.Mvc.ByNamespace.Controllers.V3.AgreementsController", "3" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { controller = "", apiVersion = "", accountId = "" }; @@ -30,7 +30,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/Controllers/Values2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/Controllers/Values2Controller.cs index 14b52ed3..ef82b8e1 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/Controllers/Values2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/Controllers/Values2Controller.cs @@ -18,4 +18,4 @@ public class Values2Controller : Controller [HttpGet( "{id:int}" )] public IActionResult GetV3( int id ) => Ok( new { Controller = nameof( Values2Controller ), Id = id, Version = HttpContext.GetRequestedApiVersion().ToString() } ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_query_string_versioned_Controller_split_into_two_types_using_conventions.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a query string and split into two types.cs similarity index 81% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_query_string_versioned_Controller_split_into_two_types_using_conventions.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a query string and split into two types.cs index 47d4e4a3..692236ee 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_query_string_versioned_Controller_split_into_two_types_using_conventions.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a query string and split into two types.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller_using_conventions { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -10,13 +10,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_query_string_versioned_Controller_split_into_two_types_using_conventions : ConventionsAcceptanceTest + public class when_using_a_query_string_and_split_into_two_types : ConventionsAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] [InlineData( nameof( Values2Controller ), "3.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -31,7 +31,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange @@ -46,7 +46,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() } [Fact] - public async Task _get_should_return_400_when_version_is_unspecified() + public async Task then_get_should_return_400_for_an_unspecified_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_url_versioned_Controller_using_conventions.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a url segment.cs similarity index 84% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_url_versioned_Controller_using_conventions.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a url segment.cs index a5d7d42d..48dd3862 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given/a_url_versioned_Controller_using_conventions.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Conventions/given a versioned Controller using conventions/when using a url segment.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller_using_conventions { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -11,13 +11,13 @@ using Xunit; using static System.Net.HttpStatusCode; - public class _a_url_versioned_Controller_using_conventions : ConventionsAcceptanceTest + public class when_using_a_url_segment : ConventionsAcceptanceTest { [Theory] [InlineData( "api/v1/helloworld", nameof( HelloWorldController ), "1" )] [InlineData( "api/v2/helloworld", nameof( HelloWorld2Controller ), "2" )] [InlineData( "api/v3/helloworld", nameof( HelloWorld2Controller ), "3" )] - public async Task _get_should_return_200( string requestUrl, string controllerName, string apiVersion ) + public async Task then_get_should_return_200( string requestUrl, string controllerName, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -36,7 +36,7 @@ public async Task _get_should_return_200( string requestUrl, string controllerNa [InlineData( "api/v1/helloworld/42", nameof( HelloWorldController ), "1" )] [InlineData( "api/v2/helloworld/42", nameof( HelloWorld2Controller ), "2" )] [InlineData( "api/v3/helloworld/42", nameof( HelloWorld2Controller ), "3" )] - public async Task _get_with_id_should_return_200( string requestUrl, string controllerName, string apiVersion ) + public async Task then_get_with_id_should_return_200( string requestUrl, string controllerName, string apiVersion ) { // act var example = new { controller = "", version = "", id = "" }; @@ -52,7 +52,7 @@ public async Task _get_with_id_should_return_200( string requestUrl, string cont } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerFeatureProvider.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerTypes.cs similarity index 83% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerFeatureProvider.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerTypes.cs index 0b425bcb..52a2c76d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerFeatureProvider.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/FilteredControllerTypes.cs @@ -5,9 +5,9 @@ using System.Collections.Generic; using System.Reflection; - internal sealed class FilteredControllerFeatureProvider : ControllerFeatureProvider, ICollection + sealed class FilteredControllerTypes : ControllerFeatureProvider, ICollection { - private readonly HashSet controllerTypes = new HashSet(); + readonly HashSet controllerTypes = new HashSet(); protected override bool IsController( TypeInfo typeInfo ) => base.IsController( typeInfo ) && controllerTypes.Contains( typeInfo ); diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/HttpContentExtensions.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/HttpContentExtensions.cs deleted file mode 100644 index a7d916a1..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/HttpContentExtensions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Microsoft.AspNetCore.Mvc -{ - using System; - using System.Net.Http; - using System.Threading.Tasks; - - internal static class HttpContentExtensions - { - internal static Task ReadAsExampleAsync( this HttpContent content, T example ) => content.ReadAsAsync(); - } -} diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given/a_Controller_versioned_by_media_type_negotiation.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given a versioned Controller/when using media type negotiation.cs similarity index 84% rename from test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given/a_Controller_versioned_by_media_type_negotiation.cs rename to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given a versioned Controller/when using media type negotiation.cs index f588b29b..ebb1ebea 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given/a_Controller_versioned_by_media_type_negotiation.cs +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/MediaTypeNegotiation/given a versioned Controller/when using media type negotiation.cs @@ -1,4 +1,4 @@ -namespace given +namespace given_a_versioned_Controller { using FluentAssertions; using Microsoft.AspNetCore.Mvc; @@ -13,12 +13,12 @@ using static System.Net.HttpStatusCode; using static System.Text.Encoding; - public class a_Controller_versioned_by_media_type_negotiation : MediaTypeNegotiationAcceptanceTest + public class when_using_media_type_negotiation : MediaTypeNegotiationAcceptanceTest { [Theory] [InlineData( nameof( ValuesController ), "1.0" )] [InlineData( nameof( Values2Controller ), "2.0" )] - public async Task _get_should_return_200( string controller, string apiVersion ) + public async Task then_get_should_return_200( string controller, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -36,7 +36,7 @@ public async Task _get_should_return_200( string controller, string apiVersion ) } [Fact] - public async Task _get_should_return_400_when_version_is_unsupported() + public async Task then_get_should_return_400_for_an_unsupported_version() { // arrange Client.DefaultRequestHeaders.Accept.Add( Parse( "application/json;v=3.0" ) ); @@ -53,7 +53,7 @@ public async Task _get_should_return_400_when_version_is_unsupported() [Theory] [InlineData( "api/values", nameof( Values2Controller ), "2.0" )] [InlineData( "api/helloworld", nameof( HelloWorldController ), "1.0" )] - public async Task _get_should_return_current_version_when_version_is_unspecified( string requestUrl, string controller, string apiVersion ) + public async Task then_get_should_return_current_version_for_an_unspecified_version( string requestUrl, string controller, string apiVersion ) { // arrange var example = new { controller = "", version = "" }; @@ -67,7 +67,7 @@ public async Task _get_should_return_current_version_when_version_is_unspecified } [Fact] - public async Task _post_should_return_201() + public async Task then_post_should_return_201() { // arrange var content = new StringContent( "{\"text\":\"Test\"}", UTF8 ); diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj new file mode 100644 index 00000000..a1fe1f40 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj @@ -0,0 +1,37 @@ + + + + netcoreapp1.1 + Microsoft.AspNetCore.Mvc.Acceptance.Tests + $(PackageTargetFallback);dnxcore50;portable-net451+win8 + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj deleted file mode 100644 index 54f6a178..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 4eed304c-d1a6-4866-8d7f-450d084fd25d - Microsoft.AspNetCore.Mvc - .\obj - .\bin\ - v4.5 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiError.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiError.cs deleted file mode 100644 index a0ae0e34..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/OneApiError.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Microsoft.AspNetCore.Mvc -{ - using System; - - public class OneApiError - { - public string Code { get; set; } - - public string Message { get; set; } - - public OneApiInnerError InnerError { get; set; } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index abf073a8..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.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("Microsoft.AspNetCore.Mvc.Acceptance.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("4eed304c-d1a6-4866-8d7f-450d084fd25d")] diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/project.json b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/project.json deleted file mode 100644 index 88ada322..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "1.0.0-*", - "testRunner": "xunit", - - "dependencies": { - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "Microsoft.DotNet.InternalAbstractions": "1.0.1-beta-003206", - "Microsoft.AspNetCore.Mvc": "1.1.1", - "Microsoft.AspNetCore.TestHost": "1.0.0", - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - }, - "FluentAssertions": "4.12.0", - "Moq": "4.7.0", - "Newtonsoft.Json": "9.0.1", - "System.Diagnostics.TraceSource": "4.0.0", - "System.Net.Http": "4.3.0", - "Microsoft.AspNetCore.Mvc.Versioning": { - "target": "project", - "version": "" - }, - "more.xunit": "2.2.0-beta2-build3300", - "Microsoft.AspNet.WebApi.Client": "5.2.3", - "System.Runtime.Serialization.Xml": "4.1.1" - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ "dnxcore50", "portable-net451+win8" ] - } - }, - - "buildOptions": { - "copyToOutput": { - "include": [ "xunit.runner.json" ] - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/xunit.runner.json b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/xunit.runner.json index bb4656dc..115ce820 100644 --- a/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/xunit.runner.json +++ b/test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/xunit.runner.json @@ -1,3 +1,4 @@ { - "methodDisplay": "31" -} + "methodDisplay": "classAndMethod", + "methodDisplayOptions": "all" +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ApplicationModels/ModelExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ApplicationModels/ModelExtensionsTest.cs index 2461be04..d9489bb2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ApplicationModels/ModelExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ApplicationModels/ModelExtensionsTest.cs @@ -7,7 +7,7 @@ public class ModelExtensionsTest { - private sealed class TestPropertyValue { } + sealed class TestPropertyValue { } [Fact] public void set_property_should_update_controller_model_properties() @@ -39,4 +39,4 @@ public void set_property_should_update_action_model_properties() action.GetProperty().Should().BeSameAs( value ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/HttpContextExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/HttpContextExtensionsTest.cs index 3f9e07f8..84dfd667 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/HttpContextExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/HttpContextExtensionsTest.cs @@ -103,4 +103,4 @@ public void http_context_should_return_null_api_version_when_the_value_is_invali result.Should().BeNull(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj new file mode 100644 index 00000000..f93ac733 --- /dev/null +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.csproj @@ -0,0 +1,35 @@ + + + + netcoreapp1.1 + Microsoft.AspNetCore.Mvc.Versioning.Tests + $(PackageTargetFallback);dnxcore50;portable-net451+win8 + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj deleted file mode 100644 index 3efa81d4..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Microsoft.AspNetCore.Mvc.Versioning.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 69c59656-53d1-4acb-92b5-8b34c8e62175 - Microsoft.AspNetCore.Mvc - .\obj - .\bin\ - v4.5 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Properties/AssemblyInfo.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index d6ab4162..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.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("Core.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("69c59656-53d1-4acb-92b5-8b34c8e62175")] diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ReportApiVersionsAttributeTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ReportApiVersionsAttributeTest.cs index ff97166c..ed27f6ee 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ReportApiVersionsAttributeTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/ReportApiVersionsAttributeTest.cs @@ -12,7 +12,7 @@ public class ReportApiVersionsAttributeTest { - private static ActionExecutedContext CreateContext( ApiVersionModel model ) + static ActionExecutedContext CreateContext( ApiVersionModel model ) { var headers = new HeaderDictionary(); var response = new Mock(); @@ -61,4 +61,4 @@ public void on_action_executing_should_not_add_headers_for_versionX2Dneutral_con context.HttpContext.Response.Headers.ContainsKey( "api-deprecated-versions" ).Should().BeFalse(); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousController.cs index b843145a..4a49cbed 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousController.cs @@ -9,4 +9,4 @@ public sealed class AmbiguousController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousNeutralController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousNeutralController.cs index 63dfc95c..faebf0d5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousNeutralController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousNeutralController.cs @@ -10,4 +10,4 @@ public sealed class AmbiguousNeutralController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousToo2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousToo2Controller.cs index 981b5f12..c9cef013 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousToo2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousToo2Controller.cs @@ -10,4 +10,4 @@ public sealed class AmbiguousToo2Controller : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousTooController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousTooController.cs index 51a9d9a4..74590aeb 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousTooController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AmbiguousTooController.cs @@ -9,4 +9,4 @@ public sealed class AmbiguousTooController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs index ec507429..24ed1dfd 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRoute2Controller.cs @@ -15,4 +15,4 @@ public sealed class ApiVersionedRoute2Controller : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRouteController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRouteController.cs index 7d620075..fbbfe429 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRouteController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ApiVersionedRouteController.cs @@ -12,4 +12,4 @@ public sealed class ApiVersionedRouteController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous2Controller.cs index 62122041..a38405df 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous2Controller.cs @@ -10,4 +10,4 @@ public sealed class AttributeRoutedAmbiguous2Controller : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous3Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous3Controller.cs index a851cd76..5dcffbe4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous3Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguous3Controller.cs @@ -10,4 +10,4 @@ public sealed class AttributeRoutedAmbiguous3Controller : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguousController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguousController.cs index 6783dbea..8760003f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguousController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedAmbiguousController.cs @@ -10,4 +10,4 @@ public sealed class AttributeRoutedAmbiguousController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs index f6a8db6f..367a06a5 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest2Controller.cs @@ -16,4 +16,4 @@ public sealed class AttributeRoutedTest2Controller : Controller [MapToApiVersion( "3.0" )] public Task GetV3() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs index 28ddfd08..594b22c4 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTest4Controller.cs @@ -12,4 +12,4 @@ public sealed class AttributeRoutedTest4Controller : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTestController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTestController.cs index a19458ee..4ea81719 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTestController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedTestController.cs @@ -9,4 +9,4 @@ public sealed class AttributeRoutedTestController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedVersionNeutralController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedVersionNeutralController.cs index fc393292..fb557361 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedVersionNeutralController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/AttributeRoutedVersionNeutralController.cs @@ -10,4 +10,4 @@ public sealed class AttributeRoutedVersionNeutralController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ConventionsController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ConventionsController.cs index f47280d6..b23cc9a3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ConventionsController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/ConventionsController.cs @@ -18,4 +18,4 @@ public sealed class ConventionsController : Controller [HttpGet( "{id:int}" )] public string GetV2( int id ) => $"Test {id} (2.0)"; } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/NeutralController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/NeutralController.cs index 7fcc287d..77c8799e 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/NeutralController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/NeutralController.cs @@ -9,4 +9,4 @@ public sealed class NeutralController : Controller [HttpGet] public Task Get() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/OrdersController.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/OrdersController.cs index 7898fb57..faaed31f 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/OrdersController.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/OrdersController.cs @@ -15,4 +15,4 @@ public class OrdersController : Controller [MapToApiVersion( "2016-06-06" )] public Task Get_2016_06_06() => Task.FromResult( Ok( "Version 2016-06-06" ) ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/TestVersion2Controller.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/TestVersion2Controller.cs index 41aa0506..4533f59b 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/TestVersion2Controller.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Simulators/TestVersion2Controller.cs @@ -18,4 +18,4 @@ public sealed class TestVersion2Controller : Controller [MapToApiVersion( "3.0" )] public Task Get3() => Task.FromResult( "Test" ); } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs index f79e4fc1..5050495d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/ConstantApiVersionSelectorTest.cs @@ -23,4 +23,4 @@ public void select_version_should_return_constant_value() selectedVersion.Should().Be( version ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs index b5edfd8e..23f32df3 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ApiVersionConventionBuilderTest.cs @@ -8,12 +8,12 @@ public class ApiVersionConventionBuilderTest { - private sealed class TestApiVersionConventionBuilder : ApiVersionConventionBuilder + sealed class TestApiVersionConventionBuilder : ApiVersionConventionBuilder { internal IDictionary> ProtectedControllerConventions => ControllerConventions; } - private sealed class StubController : Controller + sealed class StubController : Controller { public IActionResult Get() => Ok(); } diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs index 3f2cb94d..47f144f2 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/Conventions/ControllerApiVersionConventionBuilderTTest.cs @@ -8,7 +8,7 @@ public class ControllerApiVersionConventionBuilderTTest { - private sealed class UndecoratedController : Controller + sealed class UndecoratedController : Controller { public IActionResult Get() => Ok(); } @@ -17,7 +17,7 @@ private sealed class UndecoratedController : Controller [ApiVersion( "0.9", Deprecated = true )] [AdvertiseApiVersions( "3.0" )] [AdvertiseApiVersions( "3.0-Beta", Deprecated = true )] - private sealed class DecoratedController : Controller + sealed class DecoratedController : Controller { public IActionResult Get() => Ok(); } @@ -103,4 +103,4 @@ public void apply_to_should_assign_model_to_controller_from_conventions_and_attr } ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs index 2df4d6e4..df3b99f6 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/Versioning/CurrentImplementationApiVersionSelectorTest.cs @@ -26,4 +26,4 @@ public void select_version_should_return_max_api_version( IEnumerable Dispose( false ); public WebServer( Action setupApiVersioning = null, Action setupRoutes = null ) { @@ -52,7 +49,7 @@ public WebServer( Action setupApiVersioning = null, Action public IServiceProvider Services => server.Host.Services; - private void Dispose( bool disposing ) + void Dispose( bool disposing ) { if ( disposed ) { @@ -76,4 +73,4 @@ public void Dispose() GC.SuppressFinalize( this ); } } -} +} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/project.json b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/project.json deleted file mode 100644 index c4527390..00000000 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version": "1.0.0-*", - "testRunner": "xunit", - - "dependencies": { - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "Microsoft.DotNet.InternalAbstractions": "1.0.1-beta-003206", - "Microsoft.AspNetCore.Mvc": "1.1.1", - "Microsoft.AspNetCore.TestHost": "1.0.0", - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - - }, - "FluentAssertions": "4.12.0", - "Moq": "4.7.0", - "Newtonsoft.Json": "9.0.1", - "System.Diagnostics.TraceSource": "4.0.0", - "System.Net.Http": "4.3.0", - "Microsoft.AspNetCore.Mvc.Versioning": { - "target": "project", - "version": "" - }, - "more.xunit": "2.2.0-beta2-build3300" - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ "dnxcore50", "portable-net451+win8" ] - } - }, - - "buildOptions": { - "compile": [ "**/*.cs", "../common/**/*.cs" ], - "copyToOutput": { - "include": [ "xunit.runner.json" ] - } - } -} diff --git a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/xunit.runner.json b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/xunit.runner.json index d5b1216c..0d69ec47 100644 --- a/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/xunit.runner.json +++ b/test/Microsoft.AspNetCore.Mvc.Versioning.Tests/xunit.runner.json @@ -1,3 +1,4 @@ { - "methodDisplay": "30" -} + "methodDisplay": "method", + "methodDisplayOptions": "all" +} \ No newline at end of file diff --git a/test/Test.Common/Test.Common.projitems b/test/Test.Common/Test.Common.projitems new file mode 100644 index 00000000..c01d02f4 --- /dev/null +++ b/test/Test.Common/Test.Common.projitems @@ -0,0 +1,17 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + f9297626-c37c-402b-afd6-712f3e5e4d7c + + + Microsoft + + + + + + + + \ No newline at end of file diff --git a/test/Test.Common/Test.Common.shproj b/test/Test.Common/Test.Common.shproj new file mode 100644 index 00000000..b01bdbc5 --- /dev/null +++ b/test/Test.Common/Test.Common.shproj @@ -0,0 +1,13 @@ + + + + f9297626-c37c-402b-afd6-712f3e5e4d7c + 14.0 + + + + + + + + diff --git a/test/Common/Versioning/ApiVersionModelExtensionsTest.cs b/test/Test.Common/Versioning/ApiVersionModelExtensionsTest.cs similarity index 99% rename from test/Common/Versioning/ApiVersionModelExtensionsTest.cs rename to test/Test.Common/Versioning/ApiVersionModelExtensionsTest.cs index 91fe737f..9a406bcb 100644 --- a/test/Common/Versioning/ApiVersionModelExtensionsTest.cs +++ b/test/Test.Common/Versioning/ApiVersionModelExtensionsTest.cs @@ -62,4 +62,4 @@ public void aggregate_should_merge_api_version_info_sequence() } ); } } -} +} \ No newline at end of file diff --git a/test/Common/Versioning/MaxSelectVersionData.cs b/test/Test.Common/Versioning/MaxSelectVersionData.cs similarity index 99% rename from test/Common/Versioning/MaxSelectVersionData.cs rename to test/Test.Common/Versioning/MaxSelectVersionData.cs index 3f6fba13..fc148234 100644 --- a/test/Common/Versioning/MaxSelectVersionData.cs +++ b/test/Test.Common/Versioning/MaxSelectVersionData.cs @@ -61,4 +61,4 @@ public override IEnumerator GetEnumerator() }; } } -} +} \ No newline at end of file diff --git a/test/Common/Versioning/MinSelectVersionData.cs b/test/Test.Common/Versioning/MinSelectVersionData.cs similarity index 99% rename from test/Common/Versioning/MinSelectVersionData.cs rename to test/Test.Common/Versioning/MinSelectVersionData.cs index da0a7ce7..978c7d38 100644 --- a/test/Common/Versioning/MinSelectVersionData.cs +++ b/test/Test.Common/Versioning/MinSelectVersionData.cs @@ -61,4 +61,4 @@ public override IEnumerator GetEnumerator() }; } } -} +} \ No newline at end of file diff --git a/test/Common/Versioning/SelectVersionData.cs b/test/Test.Common/Versioning/SelectVersionData.cs similarity index 99% rename from test/Common/Versioning/SelectVersionData.cs rename to test/Test.Common/Versioning/SelectVersionData.cs index d712bac9..1ff85a3f 100644 --- a/test/Common/Versioning/SelectVersionData.cs +++ b/test/Test.Common/Versioning/SelectVersionData.cs @@ -21,4 +21,4 @@ public abstract class SelectVersionData : IEnumerable protected static ApiVersion Expected( ApiVersion version ) => version; } -} +} \ No newline at end of file