Replies: 1 comment 3 replies
-
Wondering if it's something like what Cake codegen does you're after, that would look something like public static string FileReadText(this ICakeContext context, FilePath file)
=> System.IO.File.ReadAllText(file.MakeAbsolute(context.Environment).FullPath);
public string FileReadText(FilePath file)
=> Context.FileReadText(file); One static extension method and one local utilizing local Context property. Making it avail both in script and a static context. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After I updated gitfool/Cake.Dungeon for Cake v3, I hit the usual issues with incompatible addins, so I looked at my usage more closely and realized I only needed a single alias from them! I subsequently worked around the issues by removing the addins and inlining my own extensions to
ICakeContext
. This works well enough but has the distinct disadvantage that what was an alias available directly (without qualification) from inside a task must now be explicitly qualified with aContext
namespace, likeContext.FileReadText
.Hence I am now pondering would it be possible to effectively make my own aliases from inside a cake script, without needing a separately compiled addin, such that they can be used elsewhere in the same loaded cake scripts without qualification. That would be really handy for very simple aliases like the ones I inlined.
Obviously this does not work out of the box, unless I'm missing something, so is this a good idea and what changes would be required?
Beta Was this translation helpful? Give feedback.
All reactions