Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Fluid.Benchmarks/CompiledFluidBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public class CompiledFluidBenchmarks : BaseBenchmarks

public CompiledFluidBenchmarks()
{
_options.MemberAccessStrategy.Register<Product>();
_options.MemberAccessStrategy.MemberNameStrategy = MemberNameStrategies.CamelCase;
_options.ModelNamesComparer = StringComparers.CamelCase;
_parser.TryParse(ProductTemplate, out _fluidTemplate, out var _);

CheckBenchmark();
Expand Down
3 changes: 1 addition & 2 deletions Fluid.Benchmarks/FluidBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class FluidBenchmarks : BaseBenchmarks

public FluidBenchmarks()
{
_options.MemberAccessStrategy.MemberNameStrategy = MemberNameStrategies.CamelCase;
_options.MemberAccessStrategy.Register<Product>();
_options.ModelNamesComparer = StringComparers.CamelCase;
_parser.TryParse(ProductTemplate, out _fluidTemplate, out var _);

CheckBenchmark();
Expand Down
2 changes: 1 addition & 1 deletion Fluid.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Program
{
static void Main(string[] args)
{
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}
3 changes: 1 addition & 2 deletions Fluid.MvcSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fluid.MvcViewEngine;
using Fluid.MvcViewEngine;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -15,7 +15,6 @@ public void ConfigureServices(IServiceCollection services)
services.Configure<FluidMvcViewOptions>(options =>
{
options.Parser = new CustomFluidViewParser(new FluidParserOptions());
options.TemplateOptions.MemberAccessStrategy = UnsafeMemberAccessStrategy.Instance;
});

services.AddMvc().AddFluid();
Expand Down
4 changes: 1 addition & 3 deletions Fluid.MvcViewEngine/FluidRendering.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fluid.ViewEngine;
using Fluid.ViewEngine;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
Expand All @@ -23,8 +23,6 @@ public FluidRendering(
_hostingEnvironment = hostingEnvironment;
_options = optionsAccessor.Value;

_options.TemplateOptions.MemberAccessStrategy.Register<ViewDataDictionary>();
_options.TemplateOptions.MemberAccessStrategy.Register<ModelStateDictionary>();
_options.TemplateOptions.FileProvider = _options.PartialsFileProvider ?? _hostingEnvironment.ContentRootFileProvider;

_fluidViewRenderer = new FluidViewRenderer(_options);
Expand Down
28 changes: 7 additions & 21 deletions Fluid.Tests/ArrayFiltersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public async Task Map()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a" }.GetType());

var result = await ArrayFilters.Map(input, arguments, context);

Expand All @@ -169,8 +168,6 @@ public async Task Map_DeepProperties()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(sample.GetType());
options.MemberAccessStrategy.Register(sample.Title.GetType());

var result = await ArrayFilters.Map(input, arguments, context);

Expand Down Expand Up @@ -252,7 +249,6 @@ public async Task Sort()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(sample.GetType(), "Title");

var result = await ArrayFilters.Sort(input, arguments, context);

Expand All @@ -264,9 +260,7 @@ public async Task Sort()
arguments = new FilterArguments().Add(new StringValue("Address.Zip"));

options = new TemplateOptions();
context = new TemplateContext(options);
options.MemberAccessStrategy.Register(sample.GetType(), "Address");
options.MemberAccessStrategy.Register(sample.Address.GetType(), "Zip");
context = new TemplateContext(options);

result = await ArrayFilters.Sort(input, arguments, context);

Expand Down Expand Up @@ -408,7 +402,6 @@ public async Task Where()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("Pinned"));

Expand Down Expand Up @@ -446,8 +439,6 @@ public async Task WhereWithTruthy()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true, Missing = 1 }.GetType());

// x | where: "Missing"

Expand Down Expand Up @@ -494,7 +485,6 @@ public async Task WhereShouldNotThrow()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("a.b.c"));

Expand All @@ -518,7 +508,7 @@ public async Task Sum()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(sample.GetType(), "Value");
//options.MemberAccessStrategy.Register(sample.GetType(), "Value");

var result = await ArrayFilters.Sum(input, arguments, context);

Expand Down Expand Up @@ -713,11 +703,11 @@ public async Task SumWithDecimalsAndArguments(string filterArgument, decimal exp

var options = new TemplateOptions();
var context = new TemplateContext(options);

options.MemberAccessStrategy.Register(quantityObjectType.GetType(), filterArgument);
options.MemberAccessStrategy.Register(weightObjectType.GetType(), filterArgument);
options.MemberAccessStrategy.Register(quantityAndWeightObjectType.GetType(), filterArgument);

//options.MemberAccessStrategy.Register(quantityObjectType.GetType(), filterArgument);
//options.MemberAccessStrategy.Register(weightObjectType.GetType(), filterArgument);
//options.MemberAccessStrategy.Register(quantityAndWeightObjectType.GetType(), filterArgument);
var result = await ArrayFilters.Sum(input, arguments, context);

Assert.Equal(expectedValue, result.ToNumberValue());
Expand All @@ -734,7 +724,6 @@ public async Task Reject()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("Pinned"));

Expand Down Expand Up @@ -771,7 +760,6 @@ public async Task Find()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("Pinned")).Add(BooleanValue.True);

Expand Down Expand Up @@ -822,7 +810,6 @@ public async Task FindIndex()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("Pinned")).Add(BooleanValue.True);

Expand Down Expand Up @@ -873,7 +860,6 @@ public async Task Has()

var options = new TemplateOptions();
var context = new TemplateContext(options);
options.MemberAccessStrategy.Register(new { Title = "a", Pinned = true }.GetType());

var arguments1 = new FilterArguments().Add(new StringValue("Pinned")).Add(BooleanValue.True);

Expand Down
2 changes: 0 additions & 2 deletions Fluid.Tests/BinaryExpressionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ public async Task ObjectValuesShouldCompareByValueNotReference()
_parser.TryParse("{% if obj1 == obj2 %}equal{% else %}not equal{% endif %}", out var template, out var messages);

var context = new TemplateContext();
context.Options.MemberAccessStrategy.Register<TestObject>();
context.SetValue("obj1", obj1);
context.SetValue("obj2", obj2);

Expand All @@ -316,7 +315,6 @@ public async Task ArrayContainsShouldCompareByValueNotReference()
_parser.TryParse("{% if array contains obj2 %}found{% else %}not found{% endif %}", out var template, out var messages);

var context = new TemplateContext();
context.Options.MemberAccessStrategy.Register<TestObject>();
context.SetValue("array", array);
context.SetValue("obj2", obj2);

Expand Down
Loading