0

I'm working on a UWP app where it's important to reduce the size of the app. Recently, I discovered that simply adding 6 await statements increased the .dll size by 20KB which I thought was an unexpectedly large amount but made sense when I realized that async/await generates a lot of state machine code.

What techniques or patterns are available in C# and .NET Core to reduce the size of my binaries? I'm assuming that code reuse would be high up on that list.

Muhammad Rehan Saeed
  • 35,627
  • 39
  • 202
  • 311
  • [Don't ask about .... **Requests for lists of things,** polls, **opinions,** discussions, etc.](https://stackoverflow.com/tour/) – Selvin Mar 28 '19 at 14:24
  • 1
    A far as techniques, start disassembling your output code into IL (for example with ILSpy, where you can easily switch between C# and IL views) and compare different ways of doing the same thing and how much code they end up generating. Like in most cases, a "for" is going to be smaller than a "foreach" loop, because foreach does stuff behind the scenes for you. A lot of things that make your life easier as a programmer will end up making the code bigger. – Bryce Wagner Mar 28 '19 at 14:35
  • problem with UWP is that in fact it is compiled to native – Selvin Mar 28 '19 at 14:37
  • 1
    interesting question, but I guess there is not so much experience of .NET native out there?! – Falco Alexander Mar 29 '19 at 09:41

0 Answers0