473,513 Members | 2,708 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Suggestion: compiler warning/info for implicit boxing

I don't know whether this is the appropriate place to give product feedback,
but here goes:

I would love to see some kind of diagnostic to let me know when implicit
boxing has occurred.

We have had a few instances where one developer or another was working on
code, and did not realize that by passing their value type to a method that
accepted an object parameter (or in many cases, a delegate).

That's not an extremely common occurrence, but from time to time it can
happen, and in a team environment, it can be introduced by any developer,
and once it's done, it's not extremely noticeable. I would really love to
be able to do a build, or launch a probe, and be warned of lines where
implicit boxing is occurring. Then I or another team member could review
that code, to determine whether the boxing was intentional or accidental.
Nov 15 '05 #1
7 1958

Hi ,

I will do some research to find if there is a way to detect implicit boxing.
I will reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2
Thanks, Jeffrey. Is there a "suggestion box" for VS.Net out there
somewhere?

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:Fe**************@cpmsftngxa07.phx.gbl...

Hi ,

I will do some research to find if there is a way to detect implicit boxing. I will reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3
On Tue, 25 Nov 2003 09:23:03 -0600, "J.Marsch" <je****@ctcdeveloper.com> wrote:
Thanks, Jeffrey. Is there a "suggestion box" for VS.Net out there
somewhere?


http://register.microsoft.com/mswish...=EN-US&gssnb=1
Nov 15 '05 #4

Hi ,

You can use the ILDASM tool to open the compiled assembly and check the IL
code to see if there is boxing involved. For example, the following C# code:
int i = 123;
object o = i;
will be compiled to the following IL code:
IL_0000: ldc.i4.s 123
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: box [mscorlib]System.Int32
IL_0009: stloc.1
So it is boxed.

Actually, the following documentation lists the situations when boxing will
occur.
http://msdn.microsoft.com/library/?u...tml/vclrfcshar
pspec_4_3_1.asp?frame=true

For suggestion to Microsoft, you can visit:
http://register.microsoft.com/mswish...=EN-US&gssnb=1
or you can mail to ms****@microsoft.com

Your suggestion will make our product more efficient, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #5
Thank you for your help Jeffrey. In leiu of a warning from the tool,
perhaps we can make use of ILDASM by scanning the dissassembly of our
assemblies for instances of boxing.

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:wN**************@cpmsftngxa06.phx.gbl...

Hi ,

You can use the ILDASM tool to open the compiled assembly and check the IL
code to see if there is boxing involved. For example, the following C# code: int i = 123;
object o = i;
will be compiled to the following IL code:
IL_0000: ldc.i4.s 123
IL_0002: stloc.0
IL_0003: ldloc.0
IL_0004: box [mscorlib]System.Int32
IL_0009: stloc.1
So it is boxed.

Actually, the following documentation lists the situations when boxing will occur.
http://msdn.microsoft.com/library/?u...tml/vclrfcshar pspec_4_3_1.asp?frame=true

For suggestion to Microsoft, you can visit:
http://register.microsoft.com/mswish...=EN-US&gssnb=1 or you can mail to ms****@microsoft.com

Your suggestion will make our product more efficient, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6
Thank you, Kerry! Suggestion sent!

"Kerry Sanders" <di****@NOSPAMyahoo.com> wrote in message
news:46********************************@4ax.com...
On Tue, 25 Nov 2003 09:23:03 -0600, "J.Marsch" <je****@ctcdeveloper.com> wrote:
Thanks, Jeffrey. Is there a "suggestion box" for VS.Net out there
somewhere?

http://register.microsoft.com/mswish...=EN-US&gssnb=1

Nov 15 '05 #7

Hi,

If you want to find out all of the places in your code where a boxing
operation occurs, you can dump the assembly to an output file using ildasm
and grep for the box instruction in your IL.

Happy Thanksgiving!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2032
by: DFP | last post by:
I am posting the gcc 3.3.2 compiler error and the source lines below them. Please explain this warning and how to fix it. crt/crtmap.hpp:17: warning: `std::map<K, D, C,...
5
2492
by: Adrian | last post by:
Hi all, I am getting a warning compiling the following code using Borland C++ Builder 6, but I dont think I am doing anything wrong. When using g++ I get no warnings at all with a g++ -Wall...
29
2481
by: junky_fellow | last post by:
Consider the following piece of code: struct junk { int i_val; int i_val1; char c_val; }; int main(void) {
5
4591
by: cody | last post by:
hi! i always hear about the dangers (performance loss) that comes with implicit autoboxing. when are situations where this happens? i only know this happens when i assign a value type to a...
3
1142
by: Alexander Arlievsky | last post by:
Hi, C# compiler issues error message on the following lines: GetStruct().Depth = 10; if GetStruct() returns structure (value type). It seems to be correct - else you will modify temporary value...
30
1693
by: Philippe Bertrand | last post by:
Is this a bug in the C# compiler or CLR runtime? enum MyEnum { ZERO = 0, ONE = 1, TWO = 2 } class Foo { public Foo(string,object) { ... } public Foo(string,MyEnum) { ... } } Foo f = new...
25
3874
by: sravishnu | last post by:
Hello, I have written a program to concatanae two strings, and should be returned to the main program. Iam enclosing the code, please give me ur critics. Thanks, main() { char s1,s2;...
11
2003
by: zeppe | last post by:
Hi all, I've a problem. The code that follows creates a warning in both gcc and visual c++. However, I think it's correct: basically, there is a function that return an object of a derived...
14
1852
by: 2005 | last post by:
Would it suppress errors? Is he trying to hide errors in his code?
0
7259
marktang
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,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
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...
0
7523
tracyyun
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...
0
5683
agi2029
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,...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.