-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Consider Reloadable Attribute for Hot Reload #54633
Comments
Since it's an API proposal: [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
public sealed class ReloadableAttribute : Attribute
{
} Also consider |
|
We should also consider placing the attribute in the System.Reflection.Metadata namespace, which is next to the MetadataUpdateHandler attribute. |
I chose |
Updated the proposal with @pranavkm's suggestion to include |
Do we envision this ever being applied to things beyond types (even if not in .NET 6)? Wondering if it should be named ReloadableType instead of just Reloadable. |
One possibility would be methods if we need finer-grained control. |
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false)]
public class EditMetadataByCreatingNewTypeAttribute : Attribute
{
}
} |
How about |
We agreed over email to |
Background and Motivation
Roslyn is adding a Reloadable Type feature. Types marked with the
Reloadable
attribute instructs the Roslyn compiler to emit a new type rather than updating it when applying changes with .NET Hot Reload. This feature enables inner-dev loop changes to be made that normally would be considered to be rude edits. We are proposing theReloadable
attribute to be used by frameworks, 3rd party libraries, and end users. It will be consumed by the Roslyn compiler.Proposed API
Usage Examples
MyUIFramework knows how to serialize, instantiate, reinitialize, and display onscreen any View subclass. So even 'rude edits' that ends up being new version of types can be applied by MyUIFramework during a .NET Hot Reload session.
Alternative Designs
One alternative would be to the add known types at the Roslyn level, though this limits future extensibility by 3rd parties and app developers.
Another alternative is to define an internal attribute for each framework that supports the reloadable type feature. The disadvantage is that there are possible conflicts when using InternalVisibleTo, and a lack of central documentation of the feature.
Risks
None at the runtime library level, as this only defines an attribute
UPDATE:
ReloadableAttribute
renamed toCreateNewOnMetadataUpdateAttribute
The text was updated successfully, but these errors were encountered: