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

How to store binary resources when reflection is off? #2152

Closed
edward-a opened this issue Jan 5, 2023 · 3 comments
Closed

How to store binary resources when reflection is off? #2152

edward-a opened this issue Jan 5, 2023 · 3 comments
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation question Further information is requested

Comments

@edward-a
Copy link

edward-a commented Jan 5, 2023

Considering that Assembly.GetManifestResourceNames() is unavailable when reflection is off, is there a way to store binary resources in an assembly or library compiled with NativeAOT? I am specifically interested in reflection-less builds since it reduces the size and makes reverse engineering more difficult.

@jkotas jkotas added the area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation label Jan 11, 2023
@jkotas
Copy link
Member

jkotas commented Jan 11, 2023

If you would like to avoid dependency on manifest resources, you can embed binary data as ReadOnlySpan using C#. Here is example from dotnet/runtime repo: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfoData.cs

NativeAOT project has been moved to dotnet/runtime repo. It is best to ask questions like this in dotnet/runtime repo.

@jkotas jkotas added the question Further information is requested label Jan 11, 2023
@jkotas jkotas closed this as completed Jan 11, 2023
@edward-a
Copy link
Author

I tried the suggested method of storing binary resource as byte arrays in C# files. Apparently, this method is only suitable for small data. With something bigger it makes Visual Studio grind to a halt. E.g. storing a 2MB mp3 file make VS consume about 12GB of RAM. So, this issue is not resolved and needs to be re-opened.

@jkotas
Copy link
Member

jkotas commented Jan 18, 2023

The reflection-free mode has been an experiment to demonstrate how far can reflection stripping get us. We do not plan to build full end-to-end experience around it.

dotnet/runtime#67193 is the best place to continue this discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-coreclr .NET runtime optimized for ahead of time compilation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants