GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Mark applicable structs as readonly and use in-modifier by xtqqczze · Pull Request #13919 · PowerShell/PowerShell Conversation
|
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /// can only be used as a switch. | ||
| /// </summary> | ||
| public struct SwitchParameter | ||
| public readonly struct SwitchParameter |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This one could be an issue -- SwitchParameter is a very widely used public API
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
But SwitchParameter is immutable by design, and adding the readonly-modifier doesn't cause any overload resolution changes [1], so I think this is not a breaking change.
[1] https://blog.paranoidcoding.com/2019/03/27/readonly-struct-breaking-change.html
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ok I'm fairly convinced by this
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| { | ||
| [StructLayout(LayoutKind.Explicit, Size = 16)] | ||
| public struct EventDescriptor | ||
| public readonly struct EventDescriptor |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about changing public structs to readonly -- existing code that relies on the previous form may be affected
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This struct is immutable by design.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| /// <param name="eventPayload"> | ||
| /// </param> | ||
| public bool WriteEvent(ref EventDescriptor eventDescriptor, params object[] eventPayload) | ||
| public bool WriteEvent(in EventDescriptor eventDescriptor, params object[] eventPayload) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Changing the signature on a public method like this is a breaking change
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The compiler doesn't permit overloading on ref/out/in differences, so this change is non-breaking.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Technically the issue isn't with the compiler, but with the runtime. Modules compiled against the old API surface must continue to work after any changes are made to the API.
But I tested it out with a toy project (an exe and a lib, where I built an in version of the lib and then changed it so the exe is compiled against a ref version) and it seems to work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's still C# compiler rules, where the compiler statically decides which overload to resolve for a call. My concern was that the resolved method call in the IL might not match what the library was originally compiled against when its loaded at runtime (so even though the original program isn't broken it still requires recompilation, which is a dealbreaker for modules). It makes sense that that's not the case though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dongbo Wang (@daxian-dbw) can you review please? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
🎉 Handy links: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.