Closed wisdark closed 2 years ago
What is the exact compilation error ?
Do you really need .NET 2.0 and not .NET 3.5 ?
The linked repository says "Compatible with .NET Framework 4.0+, Mono 2.1+ Profile, .NET Standard and .NET Core". To make it work in .NET 2.0, you would need to build it from source targeting .NET 2.0. To that end, Theraot.Core might help. Did you try compiling the project in the linked repository from code with Theraot.Core as a dependency and targeting .NET 2.0? Did it cause any errors?
This won't compile even with .NET 3.5 due to:
public static object GetDefaultValue(this Type type)
{
var e = Expression.Lambda<Func<object>>(
Expression.Convert(
Expression.Default(type),
typeof(object)));
return e.Compile()();
}
Expression.Default is supported only starting .NET 4.0.
Opened a branch for .NET 3.5: https://github.com/NN---/commandline/tree/net35 The real blocker is Expression.Default.
@NN--- What about .NET 2.0?
There is a DefaultExpression: https://github.com/theraot/Theraot/blob/master/Framework.Core/System/Linq/Expressions/DefaultExpression.cs
Seems like the condition is incorrect ;)
It should be #if LESSTHAN_NET40
since .NET 3.5 doesn't have this class.
@NN--- What about .NET 2.0?
First step is .NET 3.5. Possibly it will be good enough. @wisdark ?
@NN--- However .NET 3.5 has Expression. How are you going to add Expression.Default
to it? And how will the visitor work? Go ahead, an try to extend it, it is an up hill battle.
Ah right.. so what is the solution here ?:( Can we have ExpressionEx.Default maybe?
@NN--- Not sure. I believe it could work if ExpressionEx.Default
did not return a DefaultExpression
but a valid equivalent expression supported in .NET 3.5 - however, that would not pass type scrutiny.
Actually , does this code needs Expression ? Can it be ?
public static object GetDefaultValue(this Type type) =>
type.IsValueType ? Activator.CreateInstance(type) : null;
@wisdark Do you still need this library and need .NET 2.0 ?
can't use theraot in .net 2.0 to support commandline
https://github.com/commandlineparser/commandline