-
Notifications
You must be signed in to change notification settings - Fork 99
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
[suggestion] anonymous array declaration, relax object syntax (JS/Json syntax) #94
Comments
Good idea. I was just thinking about this these days. I will probably create a few options for this. like : OptionJsonSyntaxForAnonymousObjectInit = true;
// for
x = new {a: 10, b: 20, c: 30}
// ...
OptionAllowStringForPropertiesInAnonymousObjectInit = true;
// for
x = new {"a": 10, "b": 20, "c": 30}
OptionAllowToOmitInitializationKeywordForAnonymousObjectInit = true;
// for
x = {"a": 10, "b": 20, "c": 30}
Oops this is my French that popup. |
@codingseb great idea. To keep consistency with newly added EE.OptionSyntaxRules.ObjectInitPropertyValueDelimiter = string[] {'='}
.ObjectInitAllowPropertyAsString = false
.KeywordNew = string[] {'new'}
.StatementTerminalPunctuators = string[] {';'}
OptionSyntaxRules.ObjectInitPropertyValueDelimiter = new {"=", ":"};
x = new {a: 10, b = 20}
OptionNewKeywordAliases = new {"->"}; in which case only |
I am currently reflecting about this. I agree that Options need to be refactor to offer a better intellisense experience. Also, for the arrays options I am not sure that it will be possible everywhere without changing a lot of stuffs (and taking a lot of time) so to go forward with this, maybe I will firstly propose simpler version of some options. I mean maybe just a simple string option to start. |
I already published an alpha version for v.1.5 from branch evaluator.OptionsSyntaxRules.IsNewKeywordForAnonymousExpandoObjectOptional = true;
evaluator.OptionsSyntaxRules.InitializerPropertyValueSeparators = new[] { "=", ":" };
evaluator.OptionsSyntaxRules.InitializerAllowStringForProperties = true;
evaluator.OptionsSyntaxRules.AllowSimplifiedCollectionSyntax = true;
// And we can also use (To do a List<object> in place of a object[]):
evaluator.OptionsSyntaxRules.SimplifiedCollectionMode = SimplifiedCollectionMode.List; Take note that it introduce some breaking changes with previous versions and some others breaking changes can still happend until the official 1.5.0.0 release |
Great news @codingseb thanks for all the effort you are putting into this! |
Currently EE can evaluate anonymous object declarations:
property = value
is enforced in methodInitSimpleObjet
(we should rename that toInitSimpleObject
). First part of this suggestion is to relax this syntax and allow customization (preferably in the way customization ofnew
works now) such as:second part of this suggestion proposes support of JS-like anonymous array declaration (respecting c#
new
initialization pattern), which would internally map toList<object>
:@codingseb do you think this would be possible to implement and of use?
The text was updated successfully, but these errors were encountered: