-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add List Properties, Attributes #21
Comments
As a quick starting note, the generated code you show could be produced, assuming you were willing to have attributes on each field. public partial class Author
{
[InterceptedProperty] string _name;
[InterceptedProperty] int _age;
public void UpdateAuthor(string Name, int Age)
{
this.Name = Name;
this.Age = Age;
}
} But, I gather that isn't what you are asking. If I'm understanding it, I'm sure we could support this kind of looping, technically, but I suspect the complexity would sprawl. There will be a point where custom generators or post sharp are better answers. I don't know what the cutoff will be, so examples of when it is useful will help me decide that. But we can still do some of this.
|
but postsharp is paid =( |
Yep, and IL weaving has capabilities that roslyn source gen doesn't, by design. So this can't compete directly with postsharp anyway. The point on the limitations is that within what we can do with roslyn source gen, I want to provide as much capability as possible without letting the library become very complicated to use or maintain. |
Thanks, your idea is great, and plus I think I found a free injection kit the essence of my problem was that, I wanted to create proxy attributes: using OneOf;
using Shared;
namespace Services{
public class TodoServiceProxy : TodoService
{
public override Task<int> CreateTodo(CreateTodoCommand command)
{
return Call("CreateTodo", command).AsT2;
}
public void Complete() { };
public int Sum(int a, int b) { return Call("Sum", new Tuple<int, int>(a, b)).AsT0; }
public bool IsCorrect(bool corr = true) { return Call("IsCorrect", corr).AsT1; }
public OneOf<int, bool, Task<int>> Call(string methodName, OneOf<Tuple<int, int>, bool, CreateTodoCommand> args)
{
return methodName switch
{
"Sum" => base.Sum(args.AsT0.Item1, args.AsT0.Item1),
"IsCorrect" => base.IsCorrect(args.AsT1),
"CreateTodo" => base.CreateTodo(args.AsT2),
_ => throw new NotImplementedException(),
};
}
}
}
as you can see in the example, I want to make something like dynamic calls without reflection, and in principle I succeed, this is where the arguments were needed, but I understand this will complicate =( |
I don't think i'm following this example. Is everything shown generated code? |
I created it myself, I just wanted to show, I will still find a use for your package =) |
hello cool idea, but is it possible to add a list of properties of a class, let's say I want to create something like an interceptor
The text was updated successfully, but these errors were encountered: