Skip to content

Conversation

@roji
Copy link
Member

@roji roji commented Feb 5, 2021

Just specify them explicitly - simpler and more linker-friendly.

Part of #3300

Note: there are various other opportunities to refactor the type mapping setup code and make it nicer, but am intentionally restricting this PR to getting rid of the reflection.

Just specify them explicitly - simpler and more linker-friendly.

Part of npgsql#3300
@roji roji requested a review from YohDeadfall as a code owner February 5, 2021 20:52
@roji roji enabled auto-merge (squash) February 5, 2021 21:08
@roji roji linked an issue Feb 5, 2021 that may be closed by this pull request
6 tasks
Copy link
Contributor

@YohDeadfall YohDeadfall left a comment

Choose a reason for hiding this comment

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

It's weird that 1074b91 was dropped and that I was requested. What happened?

TypeHandlerFactory = new DefaultTypeHandlerFactory(typeof(CidrHandler))
}.Build());

var inetClrTypes = new List<Type>
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need a list here, arrays, arrays are more compact.

Copy link
Member Author

Choose a reason for hiding this comment

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

ReadOnlyIpAddress type is added just below when it's available.

This code gets executed exactly once at startup...

@roji
Copy link
Member Author

roji commented Feb 6, 2021

It's weird that 1074b91 was dropped and that I was requested. What happened?

That was my fault - I accidentally got my repos/branches crossed and force-pushed to the wrong place :( Have pushed that commit again.

Copy link
Member

@Brar Brar left a comment

Choose a reason for hiding this comment

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

🎉
This is they way it should always have been!

@roji roji merged commit be31084 into npgsql:main Feb 7, 2021
@roji roji deleted the DumpDynamicMapping branch February 7, 2021 16:23
@roji
Copy link
Member Author

roji commented Feb 7, 2021

My (stupid) past self apparently had some other ideas.

@Brar
Copy link
Member

Brar commented Feb 7, 2021

My (stupid) past self apparently had some other ideas.

I still see the point in those past ideas, but looking at it now it's about the same amount of code, with the difference that now the code flow is more obvious.
Sometimes we fall for the "magic" solution where the simple linear solution is the better one.

@roji
Copy link
Member Author

roji commented Feb 7, 2021

I completely agree. This was triggered by wanting to make Npgsql more linker-friendly, but I really think this also makes it more human-friendly too.

@roji
Copy link
Member Author

roji commented Feb 7, 2021

I wonder what you'll think of my next little project :)

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.

Trimming/AOT friendliness in 6.0

3 participants