Skip to content

Commit 4f924cf

Browse files
committed
Add Nuget packaging for AspNetCore.
Enable CodeAnalysis for AspNetCore + fix errors. Enable documentation for AspNetCore + documentation comment fixes. Update Nuget packaging for AspNet to include all source code. Remove custom Fxcop project. Modify product code projects to run Fxcop and StyleCop when building in VS. Add -Q option for quick (Compile + UnitTest) builds.
1 parent f801f39 commit 4f924cf

File tree

57 files changed

+204
-745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+204
-745
lines changed

Microsoft.AspNet.OData.PublicApi.out

Whitespace-only changes.

WebApiOData.E2E.msbuild

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,7 @@
3838

3939
</Target>
4040

41-
<Target Name="BuildTools">
42-
<PropertyGroup>
43-
<FxCopProjectLocation>$(MsBuildThisFileDirectory)tools\src\Microsoft.Web.FxCop\</FxCopProjectLocation>
44-
<CustomFxCopRulesPath>$(MsBuildThisFileDirectory)sln\packages\CustomFxCopRules</CustomFxCopRulesPath>
45-
</PropertyGroup>
46-
<MsBuild
47-
Condition=" '$(CodeAnalysis)' == 'true' "
48-
Projects="$(FxCopProjectLocation)\Microsoft.Web.FxCop.csproj"
49-
Properties="Configuration=Release;OutputPath=$(CustomFxCopRulesPath)" />
50-
</Target>
51-
52-
<Target Name="Build" DependsOnTargets="RestorePackages;BuildTools">
41+
<Target Name="Build" DependsOnTargets="RestorePackages">
5342
<PropertyGroup>
5443
<RunCodeAnalysis>false</RunCodeAnalysis>
5544
</PropertyGroup>

WebApiOData.Performance.msbuild

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,7 @@
6565
<!-- Pick the right Microsoft.Web.FxCop package to use and copy it to a standard location. -->
6666
</Target>
6767

68-
<Target Name="BuildTools">
69-
<PropertyGroup>
70-
<FxCopProjectLocation>$(MsBuildThisFileDirectory)tools\src\Microsoft.Web.FxCop\</FxCopProjectLocation>
71-
<CustomFxCopRulesPath>$(MsBuildThisFileDirectory)sln\packages\CustomFxCopRules</CustomFxCopRulesPath>
72-
</PropertyGroup>
73-
<MsBuild
74-
Condition=" '$(CodeAnalysis)' == 'true' "
75-
Projects="$(FxCopProjectLocation)\Microsoft.Web.FxCop.csproj"
76-
Properties="Configuration=Release;OutputPath=$(CustomFxCopRulesPath)" />
77-
</Target>
78-
79-
<Target Name="Build" DependsOnTargets="RestorePackages;BuildTools">
68+
<Target Name="Build" DependsOnTargets="RestorePackages">
8069
<!-- we need to batch the solution files since they both build Microsoft.TestCommon -->
8170
<Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' " Text="Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage attributes (so code analysis would always fail with the errors that are normally suppressed)." />
8271
<MakeDir Directories="bin\$(Configuration)" />

WebApiOData.msbuild

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,7 @@
6565
<!-- Pick the right Microsoft.Web.FxCop package to use and copy it to a standard location. -->
6666
</Target>
6767

68-
<Target Name="BuildTools">
69-
<PropertyGroup>
70-
<FxCopProjectLocation>$(MsBuildThisFileDirectory)tools\src\Microsoft.Web.FxCop\</FxCopProjectLocation>
71-
<CustomFxCopRulesPath>$(MsBuildThisFileDirectory)sln\packages\CustomFxCopRules</CustomFxCopRulesPath>
72-
</PropertyGroup>
73-
<MsBuild
74-
Condition=" '$(CodeAnalysis)' == 'true' "
75-
Projects="$(FxCopProjectLocation)\Microsoft.Web.FxCop.csproj"
76-
Properties="Configuration=Release;OutputPath=$(CustomFxCopRulesPath)" />
77-
</Target>
78-
79-
<Target Name="Build" DependsOnTargets="RestorePackages;BuildTools">
68+
<Target Name="Build" DependsOnTargets="RestorePackages">
8069
<!-- we need to batch the solution files since they both build Microsoft.TestCommon -->
8170
<Error Condition=" '$(CodeAnalysis)' == 'true' and '$(Configuration)' == 'Release' " Text="Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage attributes (so code analysis would always fail with the errors that are normally suppressed)." />
8271
<MakeDir Directories="bin\$(Configuration)" />

build.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ if /I "%1" == "QUICK" (
2525
set FullBuild=0
2626
goto BuildDefaults
2727
)
28+
if /I "%1" == "-Q" (
29+
set FullBuild=0
30+
goto BuildDefaults
31+
)
2832

2933
REM Continue to suport original switches for those
3034
REM who might have scripts setup to use them.

src/Microsoft.AspNet.OData.Shared/Common/TaskHelpers.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.AspNet.OData.Common
1111
/// </summary>
1212
internal static class TaskHelpers
1313
{
14+
#if NETFX
1415
private static readonly Task _defaultCompleted = Task.FromResult<AsyncVoid>(default(AsyncVoid));
1516

1617
private static readonly Task<object> _completedTaskReturningNull = Task.FromResult<object>(null);
@@ -22,29 +23,30 @@ internal static Task Canceled()
2223
{
2324
return CancelCache<AsyncVoid>.Canceled;
2425
}
25-
26-
/// <summary>
27-
/// Returns a canceled Task of the given type. The task is completed, IsCanceled = True, IsFaulted = False.
28-
/// </summary>
29-
internal static Task<TResult> Canceled<TResult>()
30-
{
31-
return CancelCache<TResult>.Canceled;
32-
}
26+
#endif
3327

3428
/// <summary>
3529
/// Returns a completed task that has no result.
36-
/// </summary>
30+
/// </summary>
3731
internal static Task Completed()
3832
{
33+
#if NETCORE
34+
return Task.CompletedTask;
35+
#else
3936
return _defaultCompleted;
37+
#endif
4038
}
4139

4240
/// <summary>
4341
/// Returns an error task. The task is Completed, IsCanceled = False, IsFaulted = True
4442
/// </summary>
4543
internal static Task FromError(Exception exception)
4644
{
45+
#if NETCORE
46+
return Task.FromException(exception);
47+
#else
4748
return FromError<AsyncVoid>(exception);
49+
#endif
4850
}
4951

5052
/// <summary>
@@ -53,16 +55,16 @@ internal static Task FromError(Exception exception)
5355
/// <typeparam name="TResult"></typeparam>
5456
internal static Task<TResult> FromError<TResult>(Exception exception)
5557
{
58+
#if NETCORE
59+
return Task.FromException<TResult>(exception);
60+
#else
5661
TaskCompletionSource<TResult> tcs = new TaskCompletionSource<TResult>();
5762
tcs.SetException(exception);
5863
return tcs.Task;
64+
#endif
5965
}
6066

61-
internal static Task<object> NullResult()
62-
{
63-
return _completedTaskReturningNull;
64-
}
65-
67+
#if NETFX
6668
/// <summary>
6769
/// Used as the T in a "conversion" of a Task into a Task{T}
6870
/// </summary>
@@ -84,5 +86,6 @@ private static Task<TResult> GetCancelledTask()
8486
return tcs.Task;
8587
}
8688
}
89+
#endif
8790
}
8891
}

src/Microsoft.AspNet.OData.Shared/Formatter/ODataMessageWrapper.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNet.OData.Formatter
1212
/// <summary>
1313
/// Wrapper for IODataRequestMessage and IODataResponseMessage.
1414
/// </summary>
15-
internal class ODataMessageWrapper : IODataRequestMessage, IODataResponseMessage, IODataPayloadUriConverter, IContainerProvider
15+
internal class ODataMessageWrapper : IODataRequestMessage, IODataResponseMessage, IODataPayloadUriConverter, IContainerProvider, IDisposable
1616
{
1717
private Stream _stream;
1818
private Dictionary<string, string> _headers;
@@ -132,5 +132,23 @@ public Uri ConvertPayloadUri(Uri baseUri, Uri payloadUri)
132132
// Returning null for default resolution.
133133
return null;
134134
}
135+
136+
/// <inheritdoc/>
137+
public void Dispose()
138+
{
139+
Dispose(true);
140+
}
141+
142+
/// <inheritdoc/>
143+
protected void Dispose(bool disposing)
144+
{
145+
if (disposing)
146+
{
147+
if (_stream != null)
148+
{
149+
_stream.Dispose();
150+
}
151+
}
152+
}
135153
}
136154
}

src/Microsoft.AspNet.OData.Shared/PerRouteContainerBase.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public IServiceProvider CreateODataRootContainer(Action<IContainerBuilder> confi
6363
/// </summary>
6464
/// <param name="routeName">The route name.</param>
6565
/// <param name="rootContainer">The root container to set.</param>
66-
/// <returns>The root container for the route name.</returns>
6766
/// <remarks>Used by unit tests to insert root containers.</remarks>
6867
internal abstract void SetODataRootContainer(string routeName, IServiceProvider rootContainer);
6968

src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Nightly.Release.nuspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1515
<tags>Microsoft AspNet WebApi AspNetWebApi OData</tags>
1616
<dependencies>
17-
<dependency id="Microsoft.AspNet.WebApi.Client" version="$WebApiClientPackageDependency$" />
18-
<dependency id="Microsoft.AspNet.WebApi.Core" version="$WebApiCorePackageDependency$" />
19-
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="$DependencyInjectionPackageDependency$" />
17+
<dependency id="Microsoft.AspNet.WebApi.Client" version="$AspNetPackageDependency$" />
18+
<dependency id="Microsoft.AspNet.WebApi.Core" version="$AspNetPackageDependency$" />
19+
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="$DependencyInjection1PackageDependency$" />
2020
<dependency id="Microsoft.Extensions.DependencyInjection" version="$DependencyInjectionPackageDependency$" />
2121
<dependency id="Microsoft.OData.Core" version="$ODataLibPackageDependency$" />
2222
</dependencies>
@@ -29,5 +29,6 @@
2929
<file src="$ProductRoot$\Microsoft.AspNet.OData.pdb" target="lib\net45" />
3030
<file src="$ProductRoot$\Microsoft.AspNet.OData.xml" target="lib\net45" />
3131
<file src="$SourcesRoot$\src\Microsoft.AspNet.OData\**\*.cs" target="src\Microsoft.AspNet.OData" />
32+
<file src="$SourcesRoot$\src\Microsoft.AspNet.OData.Shared\**\*.cs" target="src\Microsoft.AspNet.OData.Shared" />
3233
</files>
3334
</package>

src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.Release.nuspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1515
<tags>Microsoft AspNet WebApi AspNetWebApi OData</tags>
1616
<dependencies>
17-
<dependency id="Microsoft.AspNet.WebApi.Client" version="$WebApiClientPackageDependency$" />
18-
<dependency id="Microsoft.AspNet.WebApi.Core" version="$WebApiCorePackageDependency$" />
19-
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="$DependencyInjectionPackageDependency$" />
17+
<dependency id="Microsoft.AspNet.WebApi.Client" version="$AspNetPackageDependency$" />
18+
<dependency id="Microsoft.AspNet.WebApi.Core" version="$AspNetPackageDependency$" />
19+
<dependency id="Microsoft.Extensions.DependencyInjection.Abstractions" version="$DependencyInjection1PackageDependency$" />
2020
<dependency id="Microsoft.Extensions.DependencyInjection" version="$DependencyInjectionPackageDependency$" />
2121
<dependency id="Microsoft.OData.Core" version="$ODataLibPackageDependency$" />
2222
</dependencies>
@@ -29,5 +29,6 @@
2929
<file src="$ProductRoot$\Microsoft.AspNet.OData.pdb" target="lib\net45" />
3030
<file src="$ProductRoot$\Microsoft.AspNet.OData.xml" target="lib\net45" />
3131
<file src="$SourcesRoot$\src\Microsoft.AspNet.OData\**\*.cs" target="src\Microsoft.AspNet.OData" />
32+
<file src="$SourcesRoot$\src\Microsoft.AspNet.OData.Shared\**\*.cs" target="src\Microsoft.AspNet.OData.Shared" />
3233
</files>
3334
</package>

src/Microsoft.AspNet.OData/Microsoft.AspNet.OData.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
<RootNamespace>Microsoft.AspNet.OData</RootNamespace>
88
<AssemblyName>Microsoft.AspNet.OData</AssemblyName>
99
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
10-
<RunCodeAnalysis>$(CodeAnalysis)</RunCodeAnalysis>
10+
<!-- Unable to run code analysis in Release configuration. Release assemblies do not include SuppressMessage
11+
attributes (so code analysis would always fail with the errors that are normally suppressed -->
12+
<RunCodeAnalysis Condition=" '$(CodeAnalysis)' == '' and '$(Configuration)' != 'Release' ">true</RunCodeAnalysis>
1113
<CodeAnalysisRuleSet>..\Strict.ruleset</CodeAnalysisRuleSet>
14+
<StyleCopEnabled Condition=" '$(StyleCopEnabled)' == '' ">true</StyleCopEnabled>
1215
<DefineConstants>$(DefineConstants);ASPNETODATA;ASPNETWEBAPI</DefineConstants>
1316
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1417
<DefineConstants>$(DefineConstants);ASPNETODATA;ASPNETWEBAPI;NETFX;NETFX45</DefineConstants>

src/Microsoft.AspNetCore.OData/Adapters/WebApiContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNet.OData.Interfaces;
77
using Microsoft.OData.UriParser;
88
using Microsoft.OData.UriParser.Aggregation;
9+
using IODataRoutingConvention = Microsoft.AspNet.OData.Routing.Conventions.IODataRoutingConvention;
910
using ODataPath = Microsoft.AspNet.OData.Routing.ODataPath;
1011

1112
namespace Microsoft.AspNet.OData.Adapters

src/Microsoft.AspNetCore.OData/Adapters/WebApiOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal class WebApiOptions : IWebApiOptions
1515
/// <summary>
1616
/// Initializes a new instance of the WebApiOptions class.
1717
/// </summary>
18-
/// <param name="feature">The inner feature.</param>
18+
/// <param name="options">The inner options.</param>
1919
public WebApiOptions(ODataOptions options)
2020
{
2121
if (options == null)

src/Microsoft.AspNetCore.OData/Builder/ODataConventionModelBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class ODataConventionModelBuilder
1818
/// <summary>
1919
/// Initializes a new instance of the <see cref="ODataConventionModelBuilder"/> class.
2020
/// </summary>
21-
/// <param name="configuration">The <see cref="IAssembliesResolver"/> to use.</param>
21+
/// <param name="provider">The service provider to use.</param>
2222
/// <remarks>
2323
/// While this function does not use types that are AspNetCore-specific,
2424
/// the functionality is due to the way assembly resolution is done in AspNet vs AspnetCore.
@@ -31,7 +31,7 @@ public ODataConventionModelBuilder(IServiceProvider provider)
3131
/// <summary>
3232
/// Initializes a new instance of the <see cref="ODataConventionModelBuilder"/> class.
3333
/// </summary>
34-
/// <param name="configuration">The <see cref="HttpConfiguration"/> to use.</param>
34+
/// <param name="provider">The service provider to use.</param>
3535
/// <param name="isQueryCompositionMode">If the model is being built for only querying.</param>
3636
/// <remarks>The model built if <paramref name="isQueryCompositionMode"/> is <c>true</c> has more relaxed
3737
/// inference rules and also treats all types as entity types. This constructor is intended for use by unit testing only.</remarks>

src/Microsoft.AspNetCore.OData/DefaultQuerySettingsSetup.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ public class DefaultQuerySettingsSetup : IConfigureOptions<DefaultQuerySettings>
1616
{
1717
private IServiceProvider services;
1818

19+
/// <summary>
20+
/// Instantiates a new instance of the <see cref="DefaultQuerySettingsSetup"/> class.
21+
/// </summary>
22+
/// <param name="services">The services collection.</param>
1923
public DefaultQuerySettingsSetup(IServiceProvider services)
2024
{
2125
if (services == null)
@@ -26,6 +30,10 @@ public DefaultQuerySettingsSetup(IServiceProvider services)
2630
this.services = services;
2731
}
2832

33+
/// <summary>
34+
/// Invoked to configure a <see cref="DefaultQuerySettingsSetup"/> instance.
35+
/// </summary>
36+
/// <param name="options">The options instance to configure.</param>
2937
public void Configure(DefaultQuerySettings options)
3038
{
3139
// DefaultQuerySettings requires no additional configuration.

src/Microsoft.AspNetCore.OData/ETagMessageHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Net.Http.Headers;
56
using Microsoft.AspNet.OData.Common;
67
using Microsoft.AspNet.OData.Extensions;
@@ -11,9 +12,10 @@
1112
namespace Microsoft.AspNet.OData
1213
{
1314
/// <summary>
14-
/// Defines a <see cref="HttpMessageHandler"/> to add an ETag header value to an OData response when the response
15+
/// Defines a <see cref="ActionFilterAttribute"/> to add an ETag header value to an OData response when the response
1516
/// is a single resource that has an ETag defined.
1617
/// </summary>
18+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
1719
public partial class ETagMessageHandler : ActionFilterAttribute
1820
{
1921
/// <inheritdoc/>

src/Microsoft.AspNetCore.OData/Extensions/HttpRequestExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
namespace Microsoft.AspNet.OData.Extensions
2525
{
26+
/// <summary>
27+
/// Provides extension methods for the <see cref="HttpRequestExtensions"/>.
28+
/// </summary>
2629
public static class HttpRequestExtensions
2730
{
2831
/// <summary>

src/Microsoft.AspNetCore.OData/Extensions/HttpResponseExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55

66
namespace Microsoft.AspNet.OData.Extensions
77
{
8+
/// <summary>
9+
/// Provides extension methods for the <see cref="HttpResponseExtensions"/>.
10+
/// </summary>
811
public static class HttpResponseExtensions
912
{
13+
/// <summary>
14+
/// Determine if the response has a success status code.
15+
/// </summary>
16+
/// <param name="response">The response.</param>
17+
/// <returns>True if the response has a success status code; false otherwise.</returns>
1018
public static bool IsSuccessStatusCode(this HttpResponse response)
1119
{
1220
return response?.StatusCode >= 200 && response.StatusCode < 300;

src/Microsoft.AspNetCore.OData/Extensions/ODataServiceCollectionExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Linq;
56
using Microsoft.AspNet.OData.Common;
67
using Microsoft.AspNet.OData.Formatter;
78
using Microsoft.AspNet.OData.Interfaces;
@@ -72,7 +73,7 @@ public static IODataBuilder AddOData(this IServiceCollection services)
7273
/// <see cref="EnableQueryAttribute"/> to validate incoming queries. For more information, visit
7374
/// http://go.microsoft.com/fwlink/?LinkId=279712.
7475
/// </summary>
75-
/// <param name="configuration">The server configuration.</param>
76+
/// <param name="services">The services collection.</param>
7677
public static IServiceCollection AddODataQueryFilter(this IServiceCollection services)
7778
{
7879
return AddODataQueryFilter(services, new EnableQueryAttribute());
@@ -84,7 +85,7 @@ public static IServiceCollection AddODataQueryFilter(this IServiceCollection ser
8485
/// <see cref="EnableQueryAttribute"/> to validate incoming queries. For more information, visit
8586
/// http://go.microsoft.com/fwlink/?LinkId=279712.
8687
/// </summary>
87-
/// <param name="configuration">The server configuration.</param>
88+
/// <param name="services">The services collection.</param>
8889
/// <param name="queryFilter">The action filter that executes the query.</param>
8990
public static IServiceCollection AddODataQueryFilter(this IServiceCollection services, IActionFilter queryFilter)
9091
{

src/Microsoft.AspNetCore.OData/Extensions/UrlHelperExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace Microsoft.AspNet.OData.Extensions
1616
{
1717
/// <summary>
18-
/// Provides extension methods for the <see cref="UrlHelper"/> class.
18+
/// Provides extension methods for the <see cref="IUrlHelper"/> class.
1919
/// </summary>
2020
[EditorBrowsable(EditorBrowsableState.Never)]
2121
public static class UrlHelperExtensions

src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataDeserializerContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.OData.Formatter.Deserialization
88
{
99
/// <summary>
1010
/// This class encapsulates the state and settings that get passed to <see cref="ODataDeserializer"/>
11-
/// from the <see cref="ODataMediaTypeFormatter"/>.
11+
/// from the <see cref="ODataInputFormatter"/>.
1212
/// </summary>
1313
public partial class ODataDeserializerContext
1414
{

0 commit comments

Comments
 (0)