dotnet-smartcomponents / smartcomponents

Experimental, end-to-end AI features for .NET apps
622 stars 54 forks source link

Maybe use generics and model attributes? #39

Open afallingstone opened 3 months ago

afallingstone commented 3 months ago

So could it use generics and have an event callback? Really quick example and not code correct, just something like this.

<SmartPaste T=“MyModel” ReturnValue=“MyMethod” ><SmartPaste>

Then in the model I could add attributes like what has been suggested in other issues posted.

public class MyModel
{

      [SmartPasteDescription(“Please format the phone number like this: ###-###-####”)]
      Public string Phone { get; set; }

      [SmartPasteIgnore(“true”)]
      Public bool IsActive { get; set; }
}

***Edit: Fixed the bad sentence structure. Yikes 🥴

SteveSandersonMS commented 3 months ago

Yes, that's a totally reasonable suggestion.

Currently the API design makes it equivalent to the user typing things directly into the form, so it's agnostic to any bindings (or even what UI framework you're using). The approach you're suggesting would be more tied to the .NET UI framework, since it would have to apply the pasted values directly to the model object instead of to the form fields. There are pros and cons each way but conceptually I think your proposal would work fine.

I'll add this to the backlog for consideration. In the short term we're mostly focused on evaluating whether developers would use these components in practical reality (as compared with whether they just seem interesting but wouldn't actually be deployed to prod), so if you get a chance to fill out https://aka.ms/smartcomponents/survey please let us know your perspectives on it.

afallingstone commented 3 months ago

Thanks Steve, big fan of what you're doing!

I showed a working example of this in our software and people can't wait for it to be in production.

💯💯

SteveSandersonMS commented 3 months ago

@afallingstone Excellent - thanks very much for letting us know!