-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
Warn and skip code gen for duplicate aliases #2487
Comments
Did a quick PoC that did a quick n' dirty signature duplicate check of alias methods/properties, which solves For code gen it's possible to exclude individual aliases, issue is if aliases if executed as extension methods on Looking at - Method "EnvironmentVariable" excluded from code generation and ill need to be fully qualified on ICakeContext.
- Method "Move" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "Move" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetMatchingFiles" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetFiles" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "ParseProject" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "ParseProject" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetOutputAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetOutputAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetSolutionAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetSolutionAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetProjectAssembly" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetProjectAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext.
- Method "GetProjectAssemblies" was included in code generation, but will need to be fully qualified on ICakeContext. Which would likely break many scripts, but in return it would at least be possible to fix scripts by using fully qualified names/using static for extension methods. Example use string extensions #addin nuget:?package=Cake.Incubator&version=3.1.0
using static Cake.Incubator.StringExtensions;
Information("true".EqualsIgnoreCase("True")); Potentially we could generate extension method proxies to for non duplicate aliases to reduce number of scripts causing issues, but rather unsure this would be worth it. Feels like a possible rabbit hole of issues. Also most extension methods in A more long term solution could be to update guidance for addins to not use just one namespace for all classes, but instead structure in multiple namespaces, reducing the impact if we exclude namespace. I.e. if Thoughts? |
Don't merge, just a quick PoC what parts affected by the issue, it does so by a dupe check on method/property signarture, if a colliede occurs it excludes that member from code gen, it also excludes it's namespace from default imported namespaces. For discusssion, thoughts see issue cake-build#2487
Added #2488 just for reference as a draft yolo pr ;) |
@wwwlicious adding you to get some input on this as well. |
@gep13 @devlead So I can certainly move things into namespaces per extension if that is what you are suggesting. It would also be beneficial for me to know if duplicates are added into the core cake repos so I can deprecate them over the span of a few releases. No point it being in both. It might be an opportune time for you to review what is in cake.incubator and cherry pick anything else you'd like in the core libs, that way we can co-ordinate removing them and setting min dependencies for upcoming releases. there are a number of methods already marked as obsolete which can prob be removed for the next maj version, a couple of which were in your list above.
|
That would be great 👍 , especially If we lift things from "incubation" to "official" having a few namespaces will make that a more seamless iterative process. |
@gep13 can you take a look at this so I can get a new incubator release out? |
@wwwlicious for that to work, you will need to bump the version of Cake that you are using here: https://github.com/cake-contrib/Cake.Incubator/blob/develop/tools/packages.config#L3 As a minimum, you will need 0.32.0. Hope that helps |
@gep13 tried updating in dev and master branch, running ClearCache target. Looks like appveyor still restoring cached copy. https://ci.appveyor.com/project/cakecontrib/cake-incubator/builds/22666972 |
@wwwlicious hmm, very strange! I have just tried clearing the cache, and it also isn't working for me. I seem to remember @pascalberger having a similar issue the other day, and he asked a question on Twitter. Don't know if he got a response or not though. Based on this configuration: https://github.com/cake-contrib/Cake.Incubator/blob/develop/.appveyor.yml#L27 Can you try making a slight alteration to the setup.cake file, see if that can force it through? |
That works too. |
@wwwlicious with 4.0 impact looks better - Namespace Cake.Incubator.EnvironmentExtensions excluded by code generation, affected methods:
- Method "EnvironmentVariable" excluded from code generation and will need to be fully qualified on ICakeContext. |
So it looks like this is breaking things for users. Is there a min cake version they will require? |
No new Cake version should be required. If there's no aliases in a namespace it won't to be imported automatically and would need a using statement tool be found. You can automatically import namespaces via attributes on an alias
|
GH2487: Add alias dupe check on method/property signarture
I've just caught up with the changes and everything works together, but there are still the potential issues that my implementation is not exactly the same as what is in I assign the default value if the environment variable is null: EnviromentAliases.cs#L71 (like ArgumentAliases.cs#L117): return value == null ? defaultValue : Convert<T>(value); Whereas return string.IsNullOrEmpty(value) ? defaultValue : Convert<T>(value); Also, I did not implement the other method that does not take a default value and throws: public static T EnvironmentVariable<T>(this ICakeContext context, string variable) There is a similar method in ArgumentAliases.cs#L72, but again it only checks for null, not null or empty, and it didn't seem like a good idea to throw an exception if an environment variable is missing, so I didn't bring it over. So in summary, I was implementing this in a way that was consistent with |
@devlead looks like you’re preparing for a release soon. Do you want me to do anything about the issues above, or leave it as is? |
@gitfool I'll say leave as is. |
PR #2455 created a conflict with existing Cake.Incubator addin
- (2688,10): error CS0111: Type 'Submission#0' already defines a member called 'EnvironmentVariable' with the same parameter types
Repro script
What we think we need to do here is track methods generated by code gen and skip & warn on any duplicates, prioritizing what's in Cake.Common.
Likely would need to add using statements to avoid errors with aliases being invoked on
ICakeContext
The text was updated successfully, but these errors were encountered: