Skip to content

Preserve the type name string in CustomMarshalType if parsing it fails - #576

Merged
wtfsck merged 1 commit into
0xd4d:masterfrom
ElektroKill:feature/preserve-marshaler-name
May 31, 2026
Merged

Preserve the type name string in CustomMarshalType if parsing it fails#576
wtfsck merged 1 commit into
0xd4d:masterfrom
ElektroKill:feature/preserve-marshaler-name

Conversation

@ElektroKill

Copy link
Copy Markdown
Contributor

Currently, if the type name was not parsed, any empty string was written.

This has the side effect that code relying on GetCustomAttribute<MarshalAsAttribute>() will throw a different exception.

For example:
System.ArgumentException: The name of the type is invalid. (Parameter 'typeName@0')
vs.
System.ArgumentException: The value cannot be an empty string. (Parameter 'typeName')

This behavior could be used to detect rewriting with dnlib as a means of anti-tampering protection.

@wtfsck
wtfsck self-requested a review May 31, 2026 18:45
@wtfsck
wtfsck merged commit 2243679 into 0xd4d:master May 31, 2026
2 checks passed
@wtfsck

wtfsck commented May 31, 2026

Copy link
Copy Markdown
Contributor

Thanks, merged.

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