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

Attributes - is it possible to generate [AttributeName(ArgumentName = true)] #76

Open
jeffward01 opened this issue Jan 13, 2022 · 5 comments

Comments

@jeffward01
Copy link
Collaborator

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!

MilleBo added a commit that referenced this issue Jan 14, 2022
* Added AssignArgument type #76 
* Changed name on ClassInitializeArgument to ObjectCreationArgument
* Fixed spelling errors in the MathBinaryExpression class
@MilleBo
Copy link
Contributor

MilleBo commented Jan 14, 2022

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).

@jeffward01
Copy link
Collaborator Author

You are a lightening fast super-hero Jedi!!! This is very awesome, can't wait to check it out!

@MilleBo
Copy link
Contributor

MilleBo commented Jan 15, 2022

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.

@jeffward01
Copy link
Collaborator Author

jeffward01 commented Jan 16, 2022

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:

image

This is from the TV show Silicon Valley, very funny programmer humor if you have never seen it!

@MilleBo
Copy link
Contributor

MilleBo commented Jan 16, 2022

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 ;-)

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

No branches or pull requests

2 participants