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

[Question] Trim Unused Code option #529

Open
ghost opened this issue Dec 13, 2022 · 5 comments
Open

[Question] Trim Unused Code option #529

ghost opened this issue Dec 13, 2022 · 5 comments
Labels
help wanted We would be willing to take a well-written PR to help fix this. question

Comments

@ghost
Copy link

ghost commented Dec 13, 2022

I have a console app taking an argument and several options which are passed in as settings.

As such the compiler is seeing the properties as unused because they are never changed only read.
Setting them as public prevents the warnings but not the compiler behaviour.

When I publish the application as a single file with the 'Trim Unused Code' option enable then run app.exe -? none of the options appear, just the basic help text. Running the app doesn't work as exceptions are thrown for the missing options.

When I publish the app without the option the help shows and the code works.

Is this expected behaviour, or am I setting this up wrong.

I can put together a sample app if required.

@ghost ghost added the question label Dec 13, 2022
@samuel-lucas6
Copy link

Trimming worked with this library and .NET 6 but not .NET 7 last I checked. Are you using .NET 7?

@ghost
Copy link
Author

ghost commented Jan 30, 2023

I am using .Net 7 yes.

@samuel-lucas6
Copy link

I am using .Net 7 yes.

Could you try .NET 6? You will get a warning, but it should work. It'll be interesting to see if it's a problem in .NET 8.

@natemcmaster I understand the project is in maintenance mode, but would you be willing to address this at some point, particularly if it continues to be a problem in .NET 8?

@natemcmaster
Copy link
Owner

@natemcmaster I understand the project is in maintenance mode, but would you be willing to address this at some point, particularly if it continues to be a problem in .NET 8?

I'm willing to take pull requests. If someone is willing to investigate the problem and identify a solution, please let me know what it takes to fix this. I'm not planning to do that work myself.

@natemcmaster natemcmaster added the help wanted We would be willing to take a well-written PR to help fix this. label Feb 4, 2023
@samuel-lucas6
Copy link

@natemcmaster #539 is related and explains the fix. It would be good to get this fixed as it's important for self-contained apps and affects .NET 8 as well as .NET 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We would be willing to take a well-written PR to help fix this. question
Projects
None yet
Development

No branches or pull requests

2 participants