Skip to content
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

Use a fixed list of operations in ReflectionGraphicsStateOperationFac… #832

Merged
merged 2 commits into from
May 9, 2024

Conversation

Numpsy
Copy link
Contributor

@Numpsy Numpsy commented May 6, 2024

…tory rather than searching via reflection.

The simple approach discussed in #790 , to just use a fix list of operations rather than doing anything clever.

It's a draft for comments, and because we might be able to add tests to GraphicsStateOperationTests to compare the fixed list with all the types it finds via GetOperationTypes()

var result = new Dictionary<string, Type>();

foreach (var assemblyType in assemblyTypes)
private static readonly IReadOnlyDictionary<string, Type> operations =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands, operations is instanced to the class, but as the contents is constant, is it ok for it be static instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that there is a .NET 8 build, it may or may not be useful to see if using a FrozenDictionary would have any benefits here? (just a thought, i don't have any real experience with using those yet)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that'd be definitely a great use of frozen dictionary here indeed!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use FrozenDictionary in the .NET 8.0 build

….operations contains all supported graphics operations
@Numpsy
Copy link
Contributor Author

Numpsy commented May 8, 2024

Updated with an attempt at a unit test for checking that the operations dictionary contains all the operations

@Numpsy Numpsy marked this pull request as ready for review May 8, 2024 21:56
Copy link
Collaborator

@BobLd BobLd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for that @Numpsy, looks good to me with the tests!

@BobLd BobLd merged commit d86c2f4 into UglyToad:master May 9, 2024
1 check passed
@Numpsy Numpsy deleted the reflect_away branch May 9, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants