Greetings,
In my C# project, I'm using a third-party Opensource library... in
source code form. I mean no assemblies, just pure source code. It
allows me to add new application-specific functionality to that
library, finetune it, and see how things work.
Well, the problem is that the library is quite huge, so the
application's size gets not really acceptable - I'm developping for an
embedded environment. In fact, I'm using probably 5 percent of that
library. I manually excluded the big "modules " I will never use, but
there is still some unused code which could serve one day. Or not.
My question is : is it possible to tell the C# compiler (I'm using VS
..Net 2003 default compiler) to *exclude unused code* from compilation,
like many C/C++ compilers do ?
Thanks !
--
Maxim
"L'on endure tout fors que trop d'aise."
- proverbe françois 4 7137
"Maxim" <bo************ *****@gmail.com > wrote in message
news:mn******** *************** @127.0.0.1... My question is : is it possible to tell the C# compiler (I'm using VS .Net 2003 default compiler) to *exclude unused code* from compilation, like many C/C++ compilers do ?
Sure, use
#define IncludeStuff
#if IncludeStuff
// Code to include
#endif
You can put the #define in the source code, or you can set it as part of
project properties for the build in VS.NET, or if building from the command
line, you can use the /define flag.
-- Alan
Alan Pretre écrit: "Maxim" <bo************ *****@gmail.com > wrote in message news:mn******** *************** @127.0.0.1... My question is : is it possible to tell the C# compiler (I'm using VS .Net 2003 default compiler) to *exclude unused code* from compilation, like many C/C++ compilers do ?
Sure, use
#define IncludeStuff
#if IncludeStuff // Code to include #endif
You can put the #define in the source code, or you can set it as part of project properties for the build in VS.NET, or if building from the command line, you can use the /define flag.
Sure, but there is too much code to get it done manually. And it's
sometimes mixed, i.e., I can use a class having "huge" unused parts.
Good C/C++ compilers usually just don't compile unused code (if you
tell'em), and I'm wondering if it's possible with MS C# compiler.
I've googled about my problem, and it seems like the only 2 ways to
strip unused parts of an application are: use a third pary linker (like
Salamander), or run a "high-end" obfuscator on the assembly (e.g.,
Dotfuscator Professional).
--
Maxim
"Qui ne s'adventure n'a cheval ny mule."
- proverbe françois
"Maxim" <bo************ *****@gmail.com > wrote in message
news:mn******** *************** @127.0.0.1... Good C/C++ compilers usually just don't compile unused code (if you tell'em), and I'm wondering if it's possible with MS C# compiler.
Not directly. C/C++ is statically linked, so it's easy to exclude code.
However the .NET distributable is the dynamically linked assembly, and it is
impossible for the application to anticipate what usage will be made on an
assembly once it is "out of sight". By putting code into an assembly you are
saying that it is important for that code to be there, the compiler won't
second-guess you, since it does not know all the things that may call it.
I've googled about my problem, and it seems like the only 2 ways to strip unused parts of an application are: use a third pary linker (like Salamander), or run a "high-end" obfuscator on the assembly (e.g., Dotfuscator Professional).
A linker will result in the wiping out of redistribution, sharing, and
security feautures. An obfuscator will not remove the code, but will
compress all your code by cutting down the size of the symbols. I would
suggest that the "best" approach is Alan's suggestion combined with an
obfuscator.
-- Maxim "Qui ne s'adventure n'a cheval ny mule." - proverbe françois
May I suggest trying XenoCode, which contains a linker, an obfuscator
and dead code elimination features. Besides, we are 75% cheaper than
Dotfuscator Pro.
Lionel Lindemann, http://www.xenocode.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Wolfgang Meyer |
last post by:
Does someone know some metrics of how well common C++ compilers (say
g++ 3.2.x, vc++ 7.x) remove code that is unreachable in certain
instantiations of templates?
For example:
template<bool c>
class foo
{
void bar()
{
|
by: Geronimo W. Christ Esq |
last post by:
Are there any scripts or tools out there that could look recursively
through a group of C/C++ source files, and allow unreferenced function
calls or values to be easily identified ?
LXR is handy for indexing source code, and for a given function or
global variable it can show you all the places where it is referenced.
It would be really nice to have a tool that would simply list all of the
referenced functions, so that you could go...
|
by: AussieRules |
last post by:
Hi,
There use to be some 3rd party tools that would remove unused subs and
function and unused code from vb projects.
Is there are a way to do this in vb.net 03
|
by: Frank Rizzo |
last post by:
I inherited a solution that literally has hundreds of forms, regular
user controls, composite user controls, etc... Needless to say, the
solution takes its sweet time when loading.
Is there a tool that will go through the project and give me a report on
unused forms, controls, references, code, etc...
There used to be a tool like this in the vb6 days, but I can't remember
it now.
|
by: ThazKool |
last post by:
I am just wondering if all the methods that are never called upon
during a programs execution are removed when optimizing. For example
you have:
class FooA
{
void a();
...
void z();
}
| |
by: skip |
last post by:
At work we have a fairly large application (about 20 packages, 300+ modules)
that looks like we might be heading into a bit of a plateau stage. Now
seems like a good time to identify and delete old, unused code that's flown
under the radar screen for awhile simply because nobody was looking for it.
Trouble is, most of that unused code consists of module-level classes,
functions and variables, so it's hard to distinguish mechanically from...
|
by: Bern McCarty |
last post by:
We upgraded a bunch of MEC++ code to C++/CLI about 11 months ago and we've
noticed that our images bloated quite a lot in the process. Upon
investigating I observed that when a /clr compiland includes a header file
for a native type that has an inlined copy constructor, that both the
inlined copy constructor and the inlined destructor for that same type will
end up in my mixed image, even though there is no reference made to that
native...
|
by: navon2 |
last post by:
Hi
I need to find x that will minimize Ax-b=0, under the inequality
constraints Cx<d.
Actually the constraints in my problem are only upper and lower bounds
to x values.
x is 4x1 vector, A is about 100x4 (and b is of course 100x1(.
What is the appropriate algorithm?
Is there any C / C++ code available?
I succeeded solving the non-constrained problem with SVD, but some
|
by: srbakshi |
last post by:
Hi all!
I have a txt file that has some strings in the following format:
TAG=MyString
Eg:
FRUIT=I like mangoes
CARS=I like red cars
.
.
.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |