-
-
Notifications
You must be signed in to change notification settings - Fork 736
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
Allow defining a typed context to be used throughout a Cake script. #2008
Comments
I like this idea. I may be missing context, but just reading over the code real quick, I have one comment. For this, it appears that the delegate type is
Assuming that the definition of At any rate, there are several categories of types that I would find useful to manage in this fashion, but they have parameterized construction, so it would be useful, if even by providing overloads, to have a method like this:
To facilitate something like this:
|
While you're looking into making changes, can you see about making the PerformSetup change I asked about in #1772? |
@patriksvensson great, thanks. If I am reading the code right (pretty sure I am), the intention is:
So, effectively, the marker interface is the derived requirement of what is intended to unify 1..N values or references under a single context. So what you have intended for an overall real-world use-case is more or less this, I suspect. (Let me know if this is way off!)
The only thought I have is that I didn't fully grasp that this was going to hinge on the same
I still like that as an idea because it would eliminate the need to create additional aggregating types (to implement
In summary -
|
What you're describing will be possible (multiple setup/teardown for different typed contexts), it's internals have just not been implemented yet. This is just a proof of concept and I wanted to have a discussion about it before writing more code. My thought about this is that this should be supported:
I'm also thinking about adding automatic disposal of contexts implementing |
@patriksvensson Got it, thanks for the explanation. Agree with you on all points as far as your use-case as described above. I don't think it would hurt anything to handle As a final point of clarification, your types |
I was just asking for this feature on Gitter. I would love to have something like this. 👍 |
* patriksvensson-feature/GH-2008: Added support for typed context.
* Releates to cake-build#2008, cake-build#1594 and cake-build#1772 * Changes Setup from ICakeContext to ISetupContext * Adds target/initating task as TargetTask on ISetupContext * Adds typed context WithCriteria CakeTaskBuilder extension methods * Adds integration tests for ISetupContext/TData Setup and typed WithCriteria
* Relates to cake-build#2008, cake-build#1594 and cake-build#1772 * Changes Setup from ICakeContext to ISetupContext * Adds target/initating task as TargetTask on ISetupContext * Adds typed context WithCriteria CakeTaskBuilder extension methods * Adds integration tests for ISetupContext/TData Setup and typed WithCriteria
* patriksvensson-feature/GH-2008-1: Fixed some inconsistency in new public API.
Allow defining a typed context data class to be used throughout a Cake script.
Example of usage:
Declare a context in your Cake script like this:
And now you can use it like this:
This would remove dependencies on global variables and shared mutable states that make larger Cake script difficult to maintain in some scenarios. Declaring a
Setup<TContextData>
should be required to use the context data in the script. If noSetup<TContextData>
has been declared, an error should be thrown when the script compiles.With this approach we could even allow multiple setup/teardown methods for different types of context data, but that is something for later.
I'm going to write a quick proof-of-concept for this, and we can discuss this more after support for .NET Standard 2.0 has been released.
The text was updated successfully, but these errors were encountered: