Ocramius / ProxyManager

🎩✨🌈 OOP Proxy wrappers/utilities - generates and manages proxies of your objects
MIT License
4.95k stars 188 forks source link

Property name (suffixes) differ after each generation of a proxy #367

Closed holtkamp closed 7 years ago

holtkamp commented 7 years ago

TL;DR; This is more of a question than an issue: is it really required to have a unique suffix of the property names each time they are generated?

Currently each time proxies are generated, the properties are slightly differently named, due to the use of the UniqueIdentifierGenerator (for example for the $publicProperties). Of course, functionally this is not a problem. But... is it required?

Rationale I know proxies "should" not be committed to a Source Code Management system like GIT / SVN, but PaaS-providers like Heroku 'work' like this (with GIT). Generating the proxies is currently part of our build + deploy process, since a lot (around 900+, 40MB) are involved this is done before pushing the code.

Now on each deploy GIT detects changes in each of the proxies, while actually nothing has changed:

screen shot 2017-03-14 at 10 56 31

Possible options to circumvent this:

A subjective reason to prefer proxy generation before pushing, is the feeling to be 'in-control' about the content being pushed. When a proxy changes, this is clearly visible in the GIT history of Heroku application. Of course, having them change each time, kind of makes this useless.

In summary So I guess my main question is: is it really required to have a unique suffix of the property names each time they are generated, would a hash suffice that only changes if really required?

Ocramius commented 7 years ago

This is more of a question than an issue: is it really required to have a unique suffix of the property names each time they are generated?

Yes, because otherwise people will exploit those properties somewhere. What could be done is using a deterministic suffix, but it's simply not worth doing it, as the hashing parameters would need to cross many layers.

holtkamp commented 7 years ago

Aah, ok, yeah that is an argument πŸ˜„ thanks for the swift response.

holtkamp commented 7 years ago

Yes, because otherwise people will exploit those properties somewhere.

Thinking about this again, but the visibility of these properties are all private, so if someones tries to use them, of a proxy, with a crazy class name... well, that is really awkward πŸ€” , right?

Ocramius commented 7 years ago

If someone is crazy enough to mess with this library's generated code, they are crazy enough to do so via reflection API...

On 14 Mar 2017 19:23, "Menno Holtkamp" notifications@github.com wrote:

Yes, because otherwise people will exploit those properties somewhere.

Thinking about this again, but the visibility of these properties are all private, so if someones tries to use them, of a proxy, with a crazy class name... well, that is really awkward πŸ€” , right?

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Ocramius/ProxyManager/issues/367#issuecomment-286514958, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJakBP4rkCDx9g0P6qh7VZk3WRepuYXks5rltsegaJpZM4McZYV .

holtkamp commented 7 years ago

ok, but then 'supporting' this would not be this library's responsibility, right?

Feel free to close this issue, you got more experience in long-term maintenance of such project. I would say a "don't mess with or try to access the generated code" warning would suffice to cover any potential problems...

PS, kind of sticking to this, since my other attempts to generate the proxies serverside failed miserably

Ocramius commented 7 years ago

ok, but then 'supporting' this would not be this library's responsibility, right?

I'm in a separate camp here: it should just not be possible at all.

Ocramius commented 7 years ago

@holtkamp I implemented this in https://github.com/Ocramius/ProxyManager/pull/385

Just note that there is a gotcha: the generated property name changes at every version change of your base repo.

This means that committing the proxies can effectively cause more proxy changes later.

Chicken-egg, but we are getting there, slowly. At least the name doesn't change each time you run the code generator :-)

holtkamp commented 7 years ago

Nice! One doubt:

the generated property name changes at every version change of your base repo.

"my" base repo? Seems to be the version of the ProxyManager, right?

Ocramius commented 7 years ago

@holtkamp PackageVersions\Versions::VERSIONS includes all versions of all dependencies, including your local project name.

holtkamp commented 7 years ago

Aah, ok, missed that, thanks!