From 33cc640942729fc95629355f68e7a8a3276d2691 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 18 May 2017 14:17:29 +0100 Subject: [PATCH] Remove obsolete 1.x APIs --- samples/misc/NodeServicesExamples/Startup.cs | 6 ++++- .../Webpack/Clientside/PrerenderingSample.ts | 17 ------------- .../FullPagePrerenderingController.cs | 25 ------------------- samples/misc/Webpack/Startup.cs | 6 ++++- samples/misc/Webpack/Views/Home/Index.cshtml | 3 --- ...NodeServicesServiceCollectionExtensions.cs | 14 ----------- .../INodeServices.cs | 21 ---------------- .../NodeServicesImpl.cs | 12 --------- .../Prerendering/JavaScriptModuleExport.cs | 6 ----- .../Prerendering/PrerenderTagHelper.cs | 13 +--------- 10 files changed, 11 insertions(+), 112 deletions(-) delete mode 100644 samples/misc/Webpack/Clientside/PrerenderingSample.ts delete mode 100644 samples/misc/Webpack/Controllers/FullPagePrerenderingController.cs diff --git a/samples/misc/NodeServicesExamples/Startup.cs b/samples/misc/NodeServicesExamples/Startup.cs index 1c38c60..4ef4802 100755 --- a/samples/misc/NodeServicesExamples/Startup.cs +++ b/samples/misc/NodeServicesExamples/Startup.cs @@ -41,7 +41,6 @@ namespace NodeServicesExamples }); app.UseStaticFiles(); - loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( @@ -53,6 +52,11 @@ namespace NodeServicesExamples public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseKestrel() diff --git a/samples/misc/Webpack/Clientside/PrerenderingSample.ts b/samples/misc/Webpack/Clientside/PrerenderingSample.ts deleted file mode 100644 index c9d0ca1..0000000 --- a/samples/misc/Webpack/Clientside/PrerenderingSample.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default function (params: any): Promise<{ html: string, globals?: any }> { - return new Promise((resolve, reject) => { - - // Here, you could put any logic that synchronously or asynchronously prerenders - // your SPA components. For example, see the boot-server.ts files in the AngularSpa - // and ReactReduxSpa templates for ways to prerender Angular and React components. - // - // If you wanted, you could use a property on the 'params.data' object to specify - // which SPA component or template to render. - - const html = ` -

Hello

- It works! You passed ${ JSON.stringify(params.data) } - and are currently requesting ${ params.location.path }`; - resolve({ html }); - }); -}; diff --git a/samples/misc/Webpack/Controllers/FullPagePrerenderingController.cs b/samples/misc/Webpack/Controllers/FullPagePrerenderingController.cs deleted file mode 100644 index 4893545..0000000 --- a/samples/misc/Webpack/Controllers/FullPagePrerenderingController.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.SpaServices.Prerendering; -using Webpack.ActionResults; - -namespace Webpack.Controllers -{ - // This sample shows how you could invoke the prerendering APIs directly from an MVC - // action result. - public class FullPagePrerenderingController : Controller - { - private static JavaScriptModuleExport BootModule = new JavaScriptModuleExport("Clientside/PrerenderingSample") - { - // Because the boot module is written in TypeScript, we need to specify a webpack - // config so it can be built. If it was written in JavaScript, this would not be needed. - WebpackConfig = "webpack.config.js" - }; - - public IActionResult Index() - { - var dataToSupply = new { nowTime = DateTime.Now.Ticks }; - return this.Prerender(BootModule, dataToSupply); - } - } -} diff --git a/samples/misc/Webpack/Startup.cs b/samples/misc/Webpack/Startup.cs index c81e5c0..a471781 100755 --- a/samples/misc/Webpack/Startup.cs +++ b/samples/misc/Webpack/Startup.cs @@ -32,7 +32,6 @@ namespace Webpack }); app.UseStaticFiles(); - loggerFactory.AddConsole(); app.UseMvc(routes => { routes.MapRoute( @@ -44,6 +43,11 @@ namespace Webpack public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => + { + factory.AddConsole(); + factory.AddDebug(); + }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseKestrel() diff --git a/samples/misc/Webpack/Views/Home/Index.cshtml b/samples/misc/Webpack/Views/Home/Index.cshtml index 365dfaa..7828ec1 100755 --- a/samples/misc/Webpack/Views/Home/Index.cshtml +++ b/samples/misc/Webpack/Views/Home/Index.cshtml @@ -5,9 +5,6 @@

Hello

Hi there. Enter some text: -
-See also: Full-page prerendering example - @section scripts { } diff --git a/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesServiceCollectionExtensions.cs index bc453ae..f74ae08 100644 --- a/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesServiceCollectionExtensions.cs @@ -15,20 +15,6 @@ namespace Microsoft.Extensions.DependencyInjection public static void AddNodeServices(this IServiceCollection serviceCollection) => AddNodeServices(serviceCollection, _ => {}); - /// - /// Adds NodeServices support to the . - /// - /// The . - /// Options for configuring the instances. - [Obsolete("Use the AddNodeServices(Action setupAction) overload instead.")] - public static void AddNodeServices(this IServiceCollection serviceCollection, NodeServicesOptions options) - { - serviceCollection.AddSingleton(typeof (INodeServices), _ => - { - return NodeServicesFactory.CreateNodeServices(options); - }); - } - /// /// Adds NodeServices support to the . /// diff --git a/src/Microsoft.AspNetCore.NodeServices/INodeServices.cs b/src/Microsoft.AspNetCore.NodeServices/INodeServices.cs index c2a9289..2a1ce1a 100644 --- a/src/Microsoft.AspNetCore.NodeServices/INodeServices.cs +++ b/src/Microsoft.AspNetCore.NodeServices/INodeServices.cs @@ -50,26 +50,5 @@ namespace Microsoft.AspNetCore.NodeServices /// Any sequence of JSON-serializable arguments to be passed to the Node.js function. /// A representing the completion of the RPC call. Task InvokeExportAsync(CancellationToken cancellationToken, string moduleName, string exportedFunctionName, params object[] args); - - /// - /// Asynchronously invokes code in the Node.js instance. - /// - /// The JSON-serializable data type that the Node.js code will asynchronously return. - /// The path to the Node.js module (i.e., JavaScript file) relative to your project root whose default CommonJS export is the function to be invoked. - /// Any sequence of JSON-serializable arguments to be passed to the Node.js function. - /// A representing the completion of the RPC call. - [Obsolete("Use InvokeAsync instead")] - Task Invoke(string moduleName, params object[] args); - - /// - /// Asynchronously invokes code in the Node.js instance. - /// - /// The JSON-serializable data type that the Node.js code will asynchronously return. - /// The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked. - /// Specifies the CommonJS export to be invoked. - /// Any sequence of JSON-serializable arguments to be passed to the Node.js function. - /// A representing the completion of the RPC call. - [Obsolete("Use InvokeExportAsync instead")] - Task InvokeExport(string moduleName, string exportedFunctionName, params object[] args); } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.NodeServices/NodeServicesImpl.cs b/src/Microsoft.AspNetCore.NodeServices/NodeServicesImpl.cs index 8dd2044..d1cf924 100644 --- a/src/Microsoft.AspNetCore.NodeServices/NodeServicesImpl.cs +++ b/src/Microsoft.AspNetCore.NodeServices/NodeServicesImpl.cs @@ -161,17 +161,5 @@ namespace Microsoft.AspNetCore.NodeServices { return _nodeInstanceFactory(); } - - // Obsolete method - will be removed soon - public Task Invoke(string moduleName, params object[] args) - { - return InvokeAsync(moduleName, args); - } - - // Obsolete method - will be removed soon - public Task InvokeExport(string moduleName, string exportedFunctionName, params object[] args) - { - return InvokeExportAsync(moduleName, exportedFunctionName, args); - } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaServices/Prerendering/JavaScriptModuleExport.cs b/src/Microsoft.AspNetCore.SpaServices/Prerendering/JavaScriptModuleExport.cs index 65e82d4..97456b6 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Prerendering/JavaScriptModuleExport.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Prerendering/JavaScriptModuleExport.cs @@ -26,11 +26,5 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering /// If not set, the JavaScript module's default CommonJS export must itself be the prerendering function. /// public string ExportName { get; set; } - - /// - /// Obsolete. Do not use. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly. - /// - [Obsolete("Do not use. This feature will be removed. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.")] - public string WebpackConfig { get; set; } } } \ No newline at end of file diff --git a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs index 6462e22..bad274f 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs @@ -19,7 +19,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering { private const string PrerenderModuleAttributeName = "asp-prerender-module"; private const string PrerenderExportAttributeName = "asp-prerender-export"; - private const string PrerenderWebpackConfigAttributeName = "asp-prerender-webpack-config"; private const string PrerenderDataAttributeName = "asp-prerender-data"; private const string PrerenderTimeoutAttributeName = "asp-prerender-timeout"; private static INodeServices _fallbackNodeServices; // Used only if no INodeServices was registered with DI @@ -59,13 +58,6 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering [HtmlAttributeName(PrerenderExportAttributeName)] public string ExportName { get; set; } - /// - /// Obsolete. Do not use. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly. - /// - [Obsolete("Do not use. This feature will be removed. Instead, configure Webpack to build a Node.js-compatible bundle and reference that directly.")] - [HtmlAttributeName(PrerenderWebpackConfigAttributeName)] - public string WebpackConfigPath { get; set; } - /// /// An optional JSON-serializable parameter to be supplied to the prerendering code. /// @@ -111,10 +103,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering _nodeServices, new JavaScriptModuleExport(ModuleName) { - ExportName = ExportName, -#pragma warning disable CS0618 // Type or member is obsolete - WebpackConfig = WebpackConfigPath -#pragma warning restore CS0618 // Type or member is obsolete + ExportName = ExportName }, unencodedAbsoluteUrl, unencodedPathAndQuery,