Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting struct by default, would be great #556

Open
schittli opened this issue Feb 20, 2023 · 1 comment
Open

Supporting struct by default, would be great #556

schittli opened this issue Feb 20, 2023 · 1 comment

Comments

@schittli
Copy link

Good evening

thanks a lot for sharing your great work!

I tried to use fluid with c# struct objects and it looks like fluid usually always expects to get class objects, for example,
TemplateOptions.Default.MemberAccessStrategy.Register<T> is declared with: where T : class

I guess, that it would be great if fluid would support structs, by default, too.

Thanks a lot, kind regards,
Thomas

@mhehle
Copy link

mhehle commented Aug 13, 2024

using a struct anywhere will throw System.ArgumentException Cannot bind to the target method because its signature is not compatible with that of the delegate type

System.ArgumentException Cannot bind to the target method because its signature is not compatible with that of the delegate type.
   at System.Reflection.RuntimeMethodInfo.CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags)
   at Fluid.Accessors.PropertyInfoAccessor..ctor(PropertyInfo propertyInfo)
   at Fluid.MemberAccessStrategyExtensions.<>c__DisplayClass1_0.<GetTypeMembers>b__0(ValueTuple`2 key)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Fluid.MemberAccessStrategyExtensions.GetTypeMembers(Type type, MemberNameStrategy memberNameStrategy)
   at Fluid.MemberAccessStrategyExtensions.Register(MemberAccessStrategy strategy, Type type)
   at Fluid.UnsafeMemberAccessStrategy.GetAccessor(Type type, String name)
   at Fluid.Values.ObjectValueBase.GetValueAsync(String name, TemplateContext context)
   at Fluid.Ast.IdentifierSegment.ResolveAsync(FluidValue value, TemplateContext context)
   at Fluid.Ast.MemberExpression.EvaluateAsync(TemplateContext context)
   at Fluid.Ast.OutputStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
   at Fluid.Parser.FluidTemplate.RenderAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
   at Fluid.FluidTemplateExtensions.RenderAsync(IFluidTemplate template, TemplateContext context, TextEncoder encoder, Boolean isolateContext)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants