Skip to content

Commit

Permalink
Target net461 and update CsvHelper and Dapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jehhynes committed Sep 14, 2021
1 parent cd9593f commit e69efe1
Show file tree
Hide file tree
Showing 40 changed files with 237 additions and 209 deletions.
4 changes: 2 additions & 2 deletions Build/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("3.6.1")]
[assembly: AssemblyFileVersion("3.6.1")]
[assembly: AssemblyVersion("3.6.2")]
[assembly: AssemblyFileVersion("3.6.2")]
//[assembly: AssemblyInformationalVersion("2.5-filters")]
14 changes: 7 additions & 7 deletions Build/Griddly.Core.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
<language>en-US</language>

<dependencies>
<group targetFramework="net45">
<dependency id="CsvHelper" version="6.1.1" />
<dependency id="Dapper" version="1.50.2" />
<group targetFramework="net461">
<dependency id="CsvHelper" version="27.1.1" />
<dependency id="Dapper" version="2.0.90" />
<dependency id="EPPlus" version="4.5.3" />
<dependency id="Newtonsoft.Json" version="11.0.2" />
</group>
<group targetFramework="netcoreapp3.1">
<dependency id="CsvHelper" version="6.1.1" />
<dependency id="Dapper" version="1.50.2" />
<dependency id="CsvHelper" version="27.1.1" />
<dependency id="Dapper" version="2.0.90" />
<dependency id="EPPlus" version="4.5.3" />
<dependency id="Newtonsoft.Json" version="11.0.2" />
</group>
<group targetFramework="net5.0">
<dependency id="CsvHelper" version="6.1.1" />
<dependency id="Dapper" version="1.50.2" />
<dependency id="CsvHelper" version="27.1.1" />
<dependency id="Dapper" version="2.0.90" />
<dependency id="EPPlus" version="4.5.3" />
<dependency id="Newtonsoft.Json" version="11.0.2" />
</group>
Expand Down
2 changes: 1 addition & 1 deletion Build/Griddly.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<description>Pagable, sortable, MVC enabled grid</description>
<language>en-US</language>
<dependencies>
<group targetFramework="net45">
<group targetFramework="net461">
<dependency id="Griddly.Core" version="" />
</group>
<group targetFramework="netcoreapp3.1">
Expand Down
12 changes: 6 additions & 6 deletions Build/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<RemoveDir Directories="$(BaseDir)\Griddly\obj" />

<ItemGroup>
<!--net45 items-->
<!--net461 items-->
<Content Include="$(BaseDir)\Griddly\**\griddly.js" />
<Content Include="$(BaseDir)\Griddly\**\griddly.css" />
<Content Include="$(BaseDir)\Griddly\**\Views\Shared\Griddly\*.*" />
<Libs Include="$(BaseDir)\Griddly.Mvc\bin\$(Configuration)\net45\Griddly.Mvc.dll" />
<Libs Include="$(BaseDir)\Griddly.Mvc\bin\$(Configuration)\net461\Griddly.Mvc.dll" />

<!--coreapp items-->
<LibsCoreApp Include="$(BaseDir)\Griddly.Mvc\bin\$(Configuration)\netcoreapp3.1\Griddly.Mvc.dll" />
Expand All @@ -46,18 +46,18 @@
<Copy SourceFiles="$(MSBuildProjectDirectory)\Griddly.Core.nuspec" DestinationFolder="$(PackageDir)\Griddly.Core" />

<!-- Copy the source files to the package dir -->
<Copy SourceFiles="@(Content)" DestinationFolder="$(PackageDir)\Griddly\content\net45\%(RecursiveDir)" />
<Copy SourceFiles="@(Libs)" DestinationFolder="$(PackageDir)\Griddly.Core\lib\net45\%(RecursiveDir)" />
<Copy SourceFiles="@(Content)" DestinationFolder="$(PackageDir)\Griddly\content\net461\%(RecursiveDir)" />
<Copy SourceFiles="@(Libs)" DestinationFolder="$(PackageDir)\Griddly.Core\lib\net461\%(RecursiveDir)" />
<Copy SourceFiles="@(ContentCoreApp)" DestinationFolder="$(PackageDir)\Griddly\staticwebassets\%(RecursiveDir)" />
<Copy SourceFiles="@(LibsCoreApp)" DestinationFolder="$(PackageDir)\Griddly.Core\lib\netcoreapp\%(RecursiveDir)" />
<Copy SourceFiles="@(LibsCoreAppRazor)" DestinationFolder="$(PackageDir)\Griddly\lib\netcoreapp\%(RecursiveDir)" />
<Copy SourceFiles="@(BuildCoreApp)" DestinationFolder="$(PackageDir)\Griddly\%(RecursiveDir)" />

<!-- Get the version number of the main assembly to insert into the nuspec files -->
<GetAssemblyIdentity AssemblyFiles="$(PackageDir)\Griddly.Core\lib\net45\Griddly.Mvc.dll">
<GetAssemblyIdentity AssemblyFiles="$(PackageDir)\Griddly.Core\lib\net461\Griddly.Mvc.dll">
<Output TaskParameter="Assemblies" ItemName="AsmInfo" />
</GetAssemblyIdentity>
<GetAssemblyInformationalVersion AssemblyFile="$(PackageDir)\Griddly.Core\lib\net45\Griddly.Mvc.dll">
<GetAssemblyInformationalVersion AssemblyFile="$(PackageDir)\Griddly.Core\lib\net461\Griddly.Mvc.dll">
<Output TaskParameter="Value" ItemName="AssemblyVersion" />
</GetAssemblyInformationalVersion>
<PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions Griddly.Mvc/Griddly.Mvc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net45</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
<RootNamespace>Griddly.Mvc</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Expand All @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="6.1.1" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="CsvHelper" Version="27.1.1" />
<PackageReference Include="Dapper" Version="2.0.90" />
<PackageReference Include="EPPlus" Version="4.5.3" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions Griddly.Mvc/GriddlyButton.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
#if NET45
#if NET45_OR_GREATER
using System.Web.Mvc;
#else
using System.Net.Http;
Expand Down Expand Up @@ -70,7 +70,7 @@ public GriddlyButton Add(GriddlyButton item)
}

public
#if NET45
#if NET45_OR_GREATER
HttpVerbs
#else
HttpMethod
Expand All @@ -82,7 +82,7 @@ public GriddlyButton Add(GriddlyButton item)
switch (Action)
{
case GriddlyButtonAction.Navigate:
#if NET45
#if NET45_OR_GREATER
return HttpVerbs.Get;
#else
return HttpMethod.Get;
Expand All @@ -91,13 +91,13 @@ public GriddlyButton Add(GriddlyButton item)
case GriddlyButtonAction.PostCriteria:
case GriddlyButtonAction.Ajax:
case GriddlyButtonAction.AjaxBulk:
#if NET45
#if NET45_OR_GREATER
return HttpVerbs.Post;
#else
return HttpMethod.Post;
#endif
default:
#if NET45
#if NET45_OR_GREATER
return HttpVerbs.Get;
#else
return HttpMethod.Get;
Expand Down
16 changes: 8 additions & 8 deletions Griddly.Mvc/GriddlyColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Web;
#if NET45
#if NET45_OR_GREATER
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Routing;
Expand Down Expand Up @@ -66,23 +66,23 @@ string GetIdFromExpression(LambdaExpression expression)
public GriddlyFilter Filter { get; set; }

public abstract HtmlString RenderUnderlyingValue(object row,
#if NET45
#if NET45_OR_GREATER
HtmlHelper html
#else
IHtmlHelper html
#endif
);

public abstract HtmlString RenderCell(object row, GriddlySettings settings,
#if NET45
#if NET45_OR_GREATER
HtmlHelper html,
#else
IHtmlHelper html,
#endif
bool encode = true);

public abstract object RenderCellValue(object row,
#if NET45
#if NET45_OR_GREATER
HttpContextBase httpContext,
#else
HttpContext httpContext,
Expand All @@ -100,7 +100,7 @@ public virtual IDictionary<string, object> GenerateHtmlAttributes(object row, Gr
}

public virtual HtmlString RenderValue(object value,
#if NET45
#if NET45_OR_GREATER
HtmlHelper html,
#else
IHtmlHelper html,
Expand Down Expand Up @@ -201,7 +201,7 @@ public override IDictionary<string, object> GenerateHtmlAttributes(object row, G
}

public override HtmlString RenderCell(object row, GriddlySettings settings,
#if NET45
#if NET45_OR_GREATER
HtmlHelper html,
#else
IHtmlHelper html,
Expand Down Expand Up @@ -251,7 +251,7 @@ public override HtmlString RenderCell(object row, GriddlySettings settings,
}

public override HtmlString RenderUnderlyingValue(object row,
#if NET45
#if NET45_OR_GREATER
HtmlHelper html
#else
IHtmlHelper html
Expand Down Expand Up @@ -287,7 +287,7 @@ IHtmlHelper html
}

public override object RenderCellValue(object row,
#if NET45
#if NET45_OR_GREATER
HttpContextBase httpContext,
#else
HttpContext httpContext,
Expand Down
6 changes: 3 additions & 3 deletions Griddly.Mvc/GriddlyCookieFilterValueProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#if NET45
#if NET45_OR_GREATER
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -47,15 +47,15 @@ public ValueProviderResult GetValue(string key)
if (value != null)
attemptedValue = string.Join(",", value);

#if NET45
#if NET45_OR_GREATER
return new ValueProviderResult(value, attemptedValue, CultureInfo.CurrentCulture);
#else
return new ValueProviderResult(value, CultureInfo.CurrentCulture);
#endif
}
}

#if NET45
#if NET45_OR_GREATER
public class GriddlyCookieFilterValueProviderFactory : ValueProviderFactory
{
Func<ControllerContext, bool> _canProvide = (controllerContext) => controllerContext.HttpContext.Request.QueryString.Count == 0;
Expand Down
11 changes: 6 additions & 5 deletions Griddly.Mvc/GriddlyCsvResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
#if NET45
using System.Globalization;
#if NET45_OR_GREATER
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
Expand All @@ -29,7 +30,7 @@ public GriddlyCsvResult(IEnumerable<T> data, GriddlySettings settings, string na
_exportName = exportName;
}

#if NET45
#if NET45_OR_GREATER
public override void ExecuteResult(ControllerContext context)
#else
public override async Task ExecuteResultAsync(ActionContext context)
Expand All @@ -41,12 +42,12 @@ public override async Task ExecuteResultAsync(ActionContext context)

context.HttpContext.Response.Headers.Add("content-disposition", "attachment; filename=" + _name + "." + format);

#if NET45
#if NET45_OR_GREATER
var tw = context.HttpContext.Response.Output;
#else
using (var tw = new StreamWriter(context.HttpContext.Response.Body))
#endif
using (CsvWriter w = new CsvWriter(tw, new Configuration() { HasHeaderRecord = true, Delimiter = _format == GriddlyExportFormat.Tsv ? "\t" : "," }))
using (CsvWriter w = new CsvWriter(tw, new CsvConfiguration(CultureInfo.CurrentCulture) { HasHeaderRecord = true, Delimiter = _format == GriddlyExportFormat.Tsv ? "\t" : "," }))
{
var export = _settings.Exports.FirstOrDefault(x => x.Name == _exportName);
var columns = export == null ? _settings.Columns : export.Columns;
Expand All @@ -71,7 +72,7 @@ public override async Task ExecuteResultAsync(ActionContext context)

w.WriteField(renderedValue);
}
#if NET45
#if NET45_OR_GREATER
w.NextRecord();
#else
await w.NextRecordAsync(); //Fix: Synchronous operations are disallowed. Call WriteAsync or set AllowSynchronousIO to true instead.
Expand Down
6 changes: 3 additions & 3 deletions Griddly.Mvc/GriddlyExcelResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Web;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
#if NET45
#if NET45_OR_GREATER
using System.Web.Mvc;
#else
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -34,7 +34,7 @@ public GriddlyExcelResult(IEnumerable<T> data, GriddlySettings settings, string
static readonly Regex _htmlMatch = new Regex(@"<[^>]*>", RegexOptions.Compiled);
// static readonly Regex _aMatch = new Regex(@"<a\s[^>]*\s?href=""(.*?)"">(.*?)</a>", RegexOptions.Compiled | RegexOptions.IgnoreCase);

#if NET45
#if NET45_OR_GREATER
public override void ExecuteResult(ControllerContext context)
#else
public override async Task ExecuteResultAsync(ActionContext context)
Expand Down Expand Up @@ -114,7 +114,7 @@ public override async Task ExecuteResultAsync(ActionContext context)
context.HttpContext.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
context.HttpContext.Response.Headers.Add("content-disposition", "attachment; filename=" + _name + ".xlsx");

#if NET45
#if NET45_OR_GREATER
p.SaveAs(context.HttpContext.Response.OutputStream);
#else
var bytes = p.GetAsByteArray();
Expand Down
12 changes: 6 additions & 6 deletions Griddly.Mvc/GriddlyExport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Linq;
using System.Linq.Expressions;
using System.Web;
#if NET45
#if NET45_OR_GREATER
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Routing;
Expand All @@ -19,7 +19,7 @@ namespace Griddly.Mvc
{
public class GriddlyExport
{
#if NET45
#if NET45_OR_GREATER
public GriddlyExport(string name, bool useGridColumns = false)
#else
public GriddlyExport(IHtmlHelper html, string name, bool useGridColumns = false)
Expand All @@ -29,20 +29,20 @@ public GriddlyExport(IHtmlHelper html, string name, bool useGridColumns = false)
this.UseGridColumns = useGridColumns;
this.Name = name;
this.Columns = new List<GriddlyColumn>();
#if !NET45
#if !NET45_OR_GREATER
this.Html = html;
#endif
}
public string Name { get; set; }
public bool UseGridColumns { get; set; }
public List<GriddlyColumn> Columns { get; set; }
#if !NET45
#if !NET45_OR_GREATER
public IHtmlHelper Html { get; set; }
#endif
}
public class GriddlyExport<TRow> : GriddlyExport
{
#if NET45
#if NET45_OR_GREATER
public GriddlyExport(string name, bool useGridColumns = false)
: base(name, useGridColumns)
#else
Expand All @@ -55,7 +55,7 @@ public GriddlyExport<TRow> Column<TProperty>(Expression<Func<TRow, TProperty>> e
{
if (expression != null)
{
#if NET45
#if NET45_OR_GREATER
ModelMetadata metadata = ModelMetadata.FromLambdaExpression<TRow, TProperty>(expression, new ViewDataDictionary<TRow>());
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
#else
Expand Down
Loading

0 comments on commit e69efe1

Please sign in to comment.