Feature: Inspector (PropertyGrid Expansion)#502
Draft
Bamboy wants to merge 32 commits intords1983:masterfrom
Draft
Feature: Inspector (PropertyGrid Expansion)#502Bamboy wants to merge 32 commits intords1983:masterfrom
Bamboy wants to merge 32 commits intords1983:masterfrom
Conversation
#Conflicts: # src/Myra/Graphics2D/UI/Properties/AttachedPropertyRecord.cs # src/Myra/Graphics2D/UI/Properties/Record.cs
…elper intermediate class, PropertyGrid bypass of byte and sbyte types due to lacking math ops
…ding XML now parses "SpinButton" "GenericTypeArg" into a constructed generic type.
…lper, and MyraPad now accepts either type format. Fixed MyraPad codegen, saving, and loading for generic types. MyraPad now displays the generic type arg on the left pane.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR vastly expands the capabilities of
PropertyGrid,Record, and related types to allow anonymous inspection of any C#objecttype. Reflection is required.This will effectively allow Myra users to have a simple universal runtime debugging tool.
This PR adds one new lib dependency Generic.Math which is needed for netstandard2.0. This package requires Reflection.Emit & codegen. Targeting Net7 or above would remove this dependency req because we could use built-in math interfaces instead.
I am opening this PR as a draft so that @rds1983 can review progress, because so much new code is being added.
IMPLEMENTED:
Property Editing:
Myra.Samples.Inspector.PropertyEditorbase class encapsulates aRecord/MethodInfoand aWidget, as well as provides a means for selecting and creating aWidgetfor a givenRecord. Users are intended to be able to extendPropertyEditorto be able to provide drawer-widgets for their custom types. Just declare your extending class type with the below attribute and reflection will handle the rest during initialization...PropertyEditorAttributeregisters aPropertyEditortype to one or more Type that the editor can support. Open-generic editor types are supported (in which case the system will attempt to create a generic class of the specified type). If aPropertyEditordoes not have this attribute, the system ignores it. The system can be initialized with a custom collection of assemblies to scan for editor-types (possibly excluding Myra's assembly, this is untested). Manual user initialization ofPropertyEditortypes is not required, and by default the system will try to scan the entire AppDomains' loaded assemblies if it detects the database is null, potentially slow.Numerics:
NumericPropertyEditor<T>supports editing all built-in numeric types. It will spawn aSpinButton<T>widget according to the type ofMethodInfoto avoid data-rounding loss by using onlyfloat. If the type inMethodInfoisbyteorsbyte, the data is converted toushortorshortrespectively. (avoids lack of arithmetic operators)SpinButtonwas refactored from usingfloatto becomeSpinButton<T>, where T is a numeric type. I did this to fix prior overflow exceptions, and to fix floating point rounding errors.SpinButton<float>should still mostly work like before.BUGS (as of writing):
SpinButton's "DecimalPlaces" and "FixedNumberSize" properties no longer work like they did before in regard to string output. (It was changed to useSystem.Globalization.NumberFormatInfofor type compatibility)CollectionPropertyEditor(or was itCollectionEditor?) crashes if the collection type is string, with an Activator error.BooleanPropertyEditoris marked as Read-Only.PropertyGrid's "Custom" Funcs are in various states of operation.EVENTUALLY:
Ensure MyraPad still functions:
SpinButtongeneric-type format. (Reading + writing XML)PropertyGrid.Cleanup:
If/when this is merged into master, it should probably be a major version increment due to breaking API changes in
SpinButton.