By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,417 Members | 1,845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,417 IT Pros & Developers. It's quick & easy.

Suggestion: compiler warning/info for implicit boxing

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a

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

P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a
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

P: n/a

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 discussion thread is closed

Replies have been disabled for this discussion.