Testura.Code
Testura.Code copied to clipboard
Attributes - is it possible to generate [AttributeName(ArgumentName = true)]
Hello!
Again, thank you for such an awesome library! It is my favorite!
I am writing some code to generate some classes which have some class properties with attributes from Sieve.
The attributes look like this:
public int Id { get; set; }
[Sieve(CanFilter = true, CanSort = true)]
public string Title { get; set; }
[Sieve(CanFilter = true, CanSort = true)]
public int LikeCount { get; set; }
[Sieve(CanFilter = true, CanSort = true)]
public int CommentCount { get; set; }
[Sieve(CanFilter = true, CanSort = true, Name = "created")]
public DateTimeOffset DateCreated { get; set; } = DateTimeOffset.UtcNow;
More specifically:
// This is how it looks in sieve
[Sieve(CanFilter = true, CanSort = true)]
public string Title { get; set; }
// This is what it would look like with the Testura.Code naming convention
[AttributeName(AttributeArgument = true)]
public string MyExample{ get; set; }
I know that this is possible with Testura.Code:
// This is implemented with the ValueArgument
[AttributeName(AttributeArgument: true)]
public string MyExample{ get; set; }
Note the ':' semi-colon sign. I am struggling to discover how to implement an '=' statement.
It would be great to use this Expression Statement generator as an IArgument
, but I do not think it is possible due to:
- Not convertable to IArgument
- The MathExpressions do not allow for the
=
equals sign
Currently I am writing it with an ':', then later using a mystring.Replace(':', '=');
in order to accomplish this. Is there a cleaner way of doing this?
Thanks so much!
I plan to add much to the Wiki! I have been compiling some notes and topics. Thanks!
Hello,
This is a missing case and I have added a new argument for this (AssignArgument
). Example:
To generate this:
[Test(with=1,value=true)]
You just write:
AttributeGenerator.Create(new Attribute("Test", new List<IArgument> { new AssignArgument("with", 1), new AssignArgument("value", true) }))
I will probably update the nuget later this weekend (are gonna try to finish record/namespace first).
You are a lightening fast super-hero Jedi!!! This is very awesome, can't wait to check it out!
No problems! I have just released the nuget (1.2.0) so try and see if it okay or if we should add something more.
No problems! I have just released the nuget (1.2.0) so try and see if it okay or if we should add something more.
Very cool!! I will give it a go tonight or tomorrow and let you know how it handles!
Quick question for you - related
- I do not know if GitHub offers this feature, but do you have a 'ToDo list' for
Testura.Code
, i forget if I asked this akready!
Something like this:
This is from the TV show Silicon Valley, very funny programmer humor if you have never seen it!
Very cool!! I will give it a go tonight or tomorrow and let you know how it handles!
Great! I forgot to add that you also have a new RecordBuilder
and you can also send in NamespaceType
in every builder (if you want file scoped namespace)
I do not know if GitHub offers this feature, but do you have a 'ToDo list' for Testura.Code, i forget if I asked this akread
I'm not super good with GitHub either but I tried to add you as collaborator and created a new board that we could work with. So try and see if you can access it and create new notes: https://github.com/Testura/Testura.Code/projects/1
This is from the TV show Silicon Valley, very funny programmer humor if you have never seen it!
Of course! Silicon Valley is really awesome ;-)