Skip to content

Commit

Permalink
Added NetCore 3.0 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
basarburak committed Sep 20, 2019
1 parent c107549 commit 3ad86c6
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 61 deletions.
6 changes: 1 addition & 5 deletions README.md
Expand Up @@ -145,8 +145,4 @@ return FormResult.CreateSuccessResult("Product saved. Please wait...", Url.Actio
>English Posts are not ready yet. But you can look the samples. It's so easy to use.
>
>**Turkish:**<br>
>[FormHelper ve Fluent Validation kullanarak ASP.NET Core Validation İşlemleri](http://www.sinanbozkus.com/form-helper-ve-fluent-validation-kullanarak-asp-net-core-validation-islemleri/)

## Next Releases (Roadmap)
- ASP.NET Core 3.0 support
>[FormHelper ve Fluent Validation kullanarak ASP.NET Core Validation İşlemleri](http://www.sinanbozkus.com/form-helper-ve-fluent-validation-kullanarak-asp-net-core-validation-islemleri/)
2 changes: 1 addition & 1 deletion sample/FormHelper.Samples/Controllers/HomeController.cs 100644 → 100755
Expand Up @@ -64,7 +64,7 @@ public IActionResult Post()
return View(new ProductFormViewModel());
}

[FormValidator(UseAjax = false, ViewName = "IndexPost")]
[FormValidator(UseAjax = false, ViewName = "Post")]
public IActionResult SavePost(ProductFormViewModel viewModel)
{
// ...
Expand Down
14 changes: 5 additions & 9 deletions sample/FormHelper.Samples/FormHelper.Samples.csproj 100644 → 100755
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,16 +14,13 @@
<None Include="wwwroot\js\formhelper.js" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="8.3.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<ItemGroup>
<ProjectReference Include="..\..\src\FormHelper\FormHelper.csproj" />
</ItemGroup>


<ItemGroup>
<ProjectReference Include="..\..\src\FormHelper\FormHelper.csproj" />
<PackageReference Include="FluentValidation.AspNetCore" Version="8.5.0-preview5" />
</ItemGroup>

</Project>
</Project>
22 changes: 9 additions & 13 deletions sample/FormHelper.Samples/Program.cs 100644 → 100755
@@ -1,24 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace FormHelper.Samples
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
CreateHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
40 changes: 23 additions & 17 deletions sample/FormHelper.Samples/Startup.cs 100644 → 100755
@@ -1,14 +1,12 @@
using FormHelper.Samples.Models;
using FormHelper;
using FormHelper.Samples.Validators;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Serialization;
using Microsoft.Extensions.Hosting;
using FluentValidation;
using FluentValidation.AspNetCore;
using FormHelper.Samples.Models;
using FormHelper.Samples.Validators;

namespace FormHelper.Samples
{
Expand All @@ -21,7 +19,6 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add FormHelper to the project.
Expand All @@ -39,24 +36,33 @@ public void ConfigureServices(IServiceCollection services)
// You can add these validators in a separate class.
services.AddTransient<IValidator<ProductFormViewModel>, ProductFormViewModelValidator>();

services.AddMvc()
.AddFluentValidation()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver())
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddControllersWithViews()
.AddFluentValidation();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDeveloperExceptionPage();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
}

app.UseStaticFiles();

app.UseRouting();

app.UseFormHelper();

app.UseMvc(routes =>
app.UseEndpoints(endpoints =>
{
routes.MapRoute(
endpoints.MapControllerRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample/FormHelper.Samples/Views/Home/TagHelper.cshtml 100644 → 100755
Expand Up @@ -16,7 +16,7 @@
<form asp-formhelper="true"
asp-controller="Home"
asp-action="Save"
asp-dataType="Json"
asp-dataType="FormData"
asp-callback="ProductFormCallback"
asp-beforeSubmit="ProductFormBeforeSubmit"
enctype="multipart/form-data">
Expand Down
2 changes: 1 addition & 1 deletion sample/FormHelper.Samples/Views/Shared/_Layout.cshtml 100644 → 100755
Expand Up @@ -27,7 +27,7 @@
<body>

<div class="text-center mt-3">
<h1 class="display-4"><img src="~/formhelper-logo.png" " class="mb-2 mr-3" />Form Helper</h1>
<h1 class="display-4"><img src="~/formhelper-logo.png" class="mb-2 mr-3" />Form Helper</h1>
<p>Form & Validation Helper for <a href="https://dotnet.microsoft.com/learn/web/aspnet-hello-world-tutorial/intro" target="_blank">ASP.NET Core</a></p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion sample/FormHelper.Samples/Views/_ViewImports.cshtml 100644 → 100755
Expand Up @@ -3,4 +3,4 @@
@using FormHelper.Samples.Models
@using FormHelper.Samples.Enums
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, FormHelper
@addTagHelper *, FormHelper
11 changes: 4 additions & 7 deletions src/FormHelper/Extensions/ServiceCollectionExtensions.cs 100644 → 100755
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
Expand All @@ -14,13 +14,10 @@ public static IServiceCollection AddFormHelper(this IServiceCollection services,
else
services.AddSingleton(config);

services.Configure<RazorViewEngineOptions>(options =>
{
options.FileProviders.Add(
new EmbeddedFileProvider(typeof(FormHelperHtmlHelpers).GetTypeInfo().Assembly));
});
services.Configure<MvcRazorRuntimeCompilationOptions>(opts =>
opts.FileProviders.Add(new EmbeddedFileProvider(typeof(FormHelperHtmlHelpers).GetTypeInfo().Assembly)));

return services;
}
}
}
}
13 changes: 7 additions & 6 deletions src/FormHelper/FormHelper.csproj 100644 → 100755
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<PackageId>FormHelper</PackageId>
<Version>2.1.0</Version>
<Version>3.0.0</Version>
<Authors>Sinan Bozkus</Authors>
<projectUrl>https://github.com/sinanbozkus/FormHelper</projectUrl>
<RepositoryUrl>https://github.com/sinanbozkus/FormHelper</RepositoryUrl>
Expand All @@ -14,7 +14,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -35,9 +35,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.2.0" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0.0-rc1.19457.4" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.0.0-rc1.19456.10" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>

</Project>
</Project>

0 comments on commit 3ad86c6

Please sign in to comment.