Skip to content

Commit

Permalink
Moves all MVC dependencies from core assemblies to a separate assembly.
Browse files Browse the repository at this point in the history
I still need to add DNOA.Mvc to some build and package authoring.
  • Loading branch information
AArnott committed Oct 20, 2013
1 parent dab0ace commit 9fac617
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 74 deletions.
34 changes: 34 additions & 0 deletions nuget/DotNetOpenAuth.Mvc.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>DotNetOpenAuth.Mvc</id>
<version>$version$</version>
<title>DotNetOpenAuth MVC extensions</title>
<authors>Andrew Arnott</authors>
<owners>Outercurve Foundation</owners>
<projectUrl>http://www.dotnetopenauth.net/</projectUrl>
<iconUrl>https://github.com/AArnott/dotnetopenid/raw/v3.4/doc/logo/dnoa-logo_32x32.png</iconUrl>
<licenseUrl>http://www.opensource.org/licenses/ms-pl.html</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<summary>Provides the HttpResponseMessage.AsActionResult() extension method.</summary>
<dependencies>
<dependency id="DotNetOpenAuth.Core" version="[$version$]" />
<dependency id="Microsoft.AspNet.Mvc" version="[5.0.0,6.0)" />
<dependency id="Microsoft.AspNet.Razor" version="[3.0.0,4.0)" />
<dependency id="Microsoft.AspNet.WebPages" version="[3.0.0,4.0)" />
<dependency id="Microsoft.Bcl" version="[1.1.3,2.0)" />
<dependency id="Microsoft.Bcl.Build" version="[1.0.10,2.0)" />
<dependency id="Microsoft.Net.Http" version="[2.2.15,3.0)" />
<dependency id="Microsoft.Web.Infrastructure" version="[1.0.0.0,2.0)" />
<dependency id="Validation" version="[2.0.2.13022,3.0)" />
</dependencies>
</metadata>
<files>
<file src="$OutputPath45$$signedSubPath$$identity$.dll" target="lib\net45-full\" />
<file src="$OutputPath45$$identity$.pdb" target="lib\net45-full\" />
<file src="$OutputPath45$$identity$.xml" target="lib\net45-full\" />

<file src="..\src\$Identity$\**\*.cs" target="src" exclude="..\src\$Identity$\obj\**" />
<file src="$GeneratedAssemblyInfoSourceFile$" target="src" />
</files>
</package>
4 changes: 4 additions & 0 deletions samples/OAuth2ProtectedWebApi/OAuth2ProtectedWebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@
<Project>{60426312-6ae5-4835-8667-37edea670222}</Project>
<Name>DotNetOpenAuth.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.Mvc\DotNetOpenAuth.Mvc.csproj">
<Project>{9d308ef2-2712-4f83-a14c-18bf08d45526}</Project>
<Name>DotNetOpenAuth.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.AuthorizationServer\DotNetOpenAuth.OAuth2.AuthorizationServer.csproj">
<Project>{99bb7543-ea16-43ee-a7bc-d7a25a3b22f6}</Project>
<Name>DotNetOpenAuth.OAuth2.AuthorizationServer</Name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
<Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project>
<Name>DotNetOpenAuth.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.Mvc\DotNetOpenAuth.Mvc.csproj">
<Project>{9d308ef2-2712-4f83-a14c-18bf08d45526}</Project>
<Name>DotNetOpenAuth.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.OAuth2.AuthorizationServer\DotNetOpenAuth.OAuth2.AuthorizationServer.csproj">
<Project>{99BB7543-EA16-43EE-A7BC-D7A25A3B22F6}</Project>
<Name>DotNetOpenAuth.OAuth2.AuthorizationServer</Name>
Expand Down
4 changes: 4 additions & 0 deletions samples/OpenIdProviderMvc/OpenIdProviderMvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
<Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project>
<Name>DotNetOpenAuth.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.Mvc\DotNetOpenAuth.Mvc.csproj">
<Project>{9d308ef2-2712-4f83-a14c-18bf08d45526}</Project>
<Name>DotNetOpenAuth.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId.Provider.UI\DotNetOpenAuth.OpenId.Provider.UI.csproj">
<Project>{9D0F8866-2131-4C2A-BC0E-16FEA5B50828}</Project>
<Name>DotNetOpenAuth.OpenId.Provider.UI</Name>
Expand Down
4 changes: 4 additions & 0 deletions samples/OpenIdRelyingPartyMvc/OpenIdRelyingPartyMvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
<Project>{60426312-6AE5-4835-8667-37EDEA670222}</Project>
<Name>DotNetOpenAuth.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.Mvc\DotNetOpenAuth.Mvc.csproj">
<Project>{9d308ef2-2712-4f83-a14c-18bf08d45526}</Project>
<Name>DotNetOpenAuth.Mvc</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\DotNetOpenAuth.OpenId.RelyingParty.UI\DotNetOpenAuth.OpenId.RelyingParty.UI.csproj">
<Project>{1ED8D424-F8AB-4050-ACEB-F27F4F909484}</Project>
<Name>DotNetOpenAuth.OpenId.RelyingParty.UI</Name>
Expand Down
28 changes: 0 additions & 28 deletions src/DotNetOpenAuth.Core/DotNetOpenAuth.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\log4net.2.0.2\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=2.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NLog.2.1.0\lib\net45\NLog.dll</HintPath>
Expand All @@ -189,30 +185,6 @@
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="Validation, Version=2.0.0.0, Culture=neutral, PublicKeyToken=2fc06f0d701809a7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Validation.2.0.2.13022\lib\portable-windows8+net40+sl5+windowsphone8\Validation.dll</HintPath>
Expand Down
39 changes: 0 additions & 39 deletions src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace DotNetOpenAuth.Messaging {
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using DotNetOpenAuth.Messaging.Bindings;
using DotNetOpenAuth.Messaging.Reflection;
Expand Down Expand Up @@ -410,16 +409,6 @@ public static Uri GetPublicFacingUrl() {
return GetPublicFacingUrl(new HttpRequestWrapper(HttpContext.Current.Request));
}

/// <summary>
/// Wraps a response message as an MVC <see cref="ActionResult"/> so it can be conveniently returned from an MVC controller's action method.
/// </summary>
/// <param name="response">The response message.</param>
/// <returns>An <see cref="ActionResult"/> instance.</returns>
public static ActionResult AsActionResult(this HttpResponseMessage response) {
Requires.NotNull(response, "response");
return new HttpResponseMessageActionResult(response);
}

/// <summary>
/// Wraps an instance of <see cref="HttpRequestBase"/> as an <see cref="HttpRequestMessage"/> instance.
/// </summary>
Expand Down Expand Up @@ -2043,33 +2032,5 @@ public int Compare(T x, T y) {

#endregion
}

/// <summary>
/// An MVC <see cref="ActionResult"/> that wraps an <see cref="HttpResponseMessage"/>
/// </summary>
private class HttpResponseMessageActionResult : ActionResult {
/// <summary>
/// The wrapped response.
/// </summary>
private readonly HttpResponseMessage response;

/// <summary>
/// Initializes a new instance of the <see cref="HttpResponseMessageActionResult"/> class.
/// </summary>
/// <param name="response">The response.</param>
internal HttpResponseMessageActionResult(HttpResponseMessage response) {
Requires.NotNull(response, "response");
this.response = response;
}

/// <summary>
/// Enables processing of the result of an action method by a custom type that inherits from the <see cref="T:System.Web.Mvc.ActionResult" /> class.
/// </summary>
/// <param name="context">The context in which the result is executed. The context information includes the controller, HTTP content, request context, and route data.</param>
public override void ExecuteResult(ControllerContext context) {
// Sadly, MVC doesn't support writing to the response stream asynchronously.
this.response.SendAsync(context.HttpContext).GetAwaiter().GetResult();
}
}
}
}
4 changes: 0 additions & 4 deletions src/DotNetOpenAuth.Core/packages.config
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.10" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.15" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="NLog" version="2.1.0" targetFramework="net45" />
<package id="Validation" version="2.0.2.13022" targetFramework="net45" />
</packages>
92 changes: 92 additions & 0 deletions src/DotNetOpenAuth.Mvc/DotNetOpenAuth.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))\EnlistmentInfo.props" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.props))' != '' " />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
</PropertyGroup>
<Import Project="$(ProjectRoot)tools\DotNetOpenAuth.props" />
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9D308EF2-2712-4F83-A14C-18BF08D45526}</ProjectGuid>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AssemblyName>DotNetOpenAuth.Mvc</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
</PropertyGroup>
<Import Project="$(ProjectRoot)tools\DotNetOpenAuth.Product.props" />
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.15\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Validation">
<HintPath>..\packages\Validation.2.0.2.13022\lib\portable-windows8+net40+sl5+windowsphone8\Validation.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MvcExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DotNetOpenAuth.Core\DotNetOpenAuth.Core.csproj">
<Project>{60426312-6ae5-4835-8667-37edea670222}</Project>
<Name>DotNetOpenAuth.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(ProjectRoot)tools\DotNetOpenAuth.targets" />
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))\EnlistmentInfo.targets" Condition=" '$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), EnlistmentInfo.targets))' != '' " />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.10\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
</Project>
61 changes: 61 additions & 0 deletions src/DotNetOpenAuth.Mvc/MvcExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//-----------------------------------------------------------------------
// <copyright file="MvcExtensions.cs" company="Andrew Arnott">
// Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Messaging
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using DotNetOpenAuth.Messaging;
using Validation;

/// <summary>
/// DotNetOpenAuth extensions for ASP.NET MVC.
/// </summary>
public static class MvcExtensions {
/// <summary>
/// Wraps a response message as an MVC <see cref="ActionResult"/> so it can be conveniently returned from an MVC controller's action method.
/// </summary>
/// <param name="response">The response message.</param>
/// <returns>An <see cref="ActionResult"/> instance.</returns>
public static ActionResult AsActionResult(this HttpResponseMessage response) {
Requires.NotNull(response, "response");
return new HttpResponseMessageActionResult(response);
}

/// <summary>
/// An MVC <see cref="ActionResult"/> that wraps an <see cref="HttpResponseMessage"/>
/// </summary>
private class HttpResponseMessageActionResult : ActionResult {
/// <summary>
/// The wrapped response.
/// </summary>
private readonly HttpResponseMessage response;

/// <summary>
/// Initializes a new instance of the <see cref="HttpResponseMessageActionResult"/> class.
/// </summary>
/// <param name="response">The response.</param>
internal HttpResponseMessageActionResult(HttpResponseMessage response) {
Requires.NotNull(response, "response");
this.response = response;
}

/// <summary>
/// Enables processing of the result of an action method by a custom type that inherits from the <see cref="T:System.Web.Mvc.ActionResult" /> class.
/// </summary>
/// <param name="context">The context in which the result is executed. The context information includes the controller, HTTP content, request context, and route data.</param>
public override void ExecuteResult(ControllerContext context) {
// Sadly, MVC doesn't support writing to the response stream asynchronously.
this.response.SendAsync(context.HttpContext).GetAwaiter().GetResult();
}
}
}
}
Loading

0 comments on commit 9fac617

Please sign in to comment.