Freigeben über


The Difference between RSCC and .NET Reflector

.NET Reflector enables you to easily view, navigate, and search through the class hierarchies of .NET assemblies even if you don't have the code for them. With it, you can decompile and analyze .NET assemblies in C#, Visual Basic and IL.

Reference Source Code Center and it's integration inside Visual Studio 2008 enables a rich debug scenario for developers building applications on top of the Microsoft platforms. With it, you have fast and easy access to Microsoft’s platform source code.

What are the most important differences between RSCC and .NET Reflector?

  • RSCC can only display the sources of the .NET Framework that we currently support, .NET Reflector can enables you to see the reflected code of any .NET assembly
  • RSCC enables you to debug and step into the source code from inside Visual Studio
  • Both tools let you look at the .NET Framework source code in C#, but here's the difference in information you get as a developer:

.NET Reflector

 private void ApplyClientSize()
{
    if ((this.formState[FormStateWindowState] == 0) && base.IsHandleCreated)
    {
        Size clientSize = this.ClientSize;
        bool hScroll = base.HScroll;
        bool vScroll = base.VScroll;
        bool flag3 = false;
        if (this.formState[FormStateSetClientSize] != 0)
        {
            flag3 = true;
            this.formState[FormStateSetClientSize] = 0;
        }
        if (flag3)
        {
            if (hScroll)
            {
                clientSize.Height += SystemInformation.HorizontalScrollBarHeight;
            }
            if (vScroll)
            {
                clientSize.Width += SystemInformation.VerticalScrollBarWidth;
            }
        }

 

Reference Source Code

   /// <devdoc>
  ///     This adjusts the size of the windowRect so that the client rect is the 
  ///     correct size.
  /// </devdoc>
  /// <internalonly/>
  private void ApplyClientSize() { 
     if ((FormWindowState)formState[FormStateWindowState] != FormWindowState.Normal
           || !IsHandleCreated) { 
             return; 
       }
       // Cache the clientSize, since calling setBounds will end up causing
        // clientSize to get reset to the actual clientRect size...
     //
      Size correctClientSize = ClientSize; 
       bool hscr = HScroll;
        bool vscr = VScroll; 
       // This logic assumes that the caller of setClientSize() knows if the scrollbars
        // are showing or not. Since the 90% case is that setClientSize() is the persisted 
     // ClientSize, this is correct.
     // Without this logic persisted forms that were saved with the scrollbars showing,
      // don't get set to the correct size.
       // 
 bool adjustScroll = false;
  if (formState[FormStateSetClientSize] != 0) { 
       adjustScroll = true; 
       formState[FormStateSetClientSize] = 0;
 }

...

Comments

  • Anonymous
    September 05, 2008
    PingBack from http://hoursfunnywallpaper.cn/?p=4815

  • Anonymous
    September 05, 2008
    Oddly,  I like Reflector's coding style better than the human's.....

  • Anonymous
    September 05, 2008
    Hi James, That is indeed a bit odd, especially especially since the code in the sample itself is pretty similar, just that the reflector code does not have the comments or the original variable names in it. The code construct itself is very similar. steven

  • Anonymous
    September 05, 2008
    @JamesCurran I think it's because the .NET Reflector uses assembly's codes that has been optimized by C# compiler. I can see obvious differences there, ignoring the comments and the variable names of course. As Steven said "The code construct itself is very similar", but it's absolutely not exact. Never mind, the C# compiler knows what the best to do :D.

  • Anonymous
    September 08, 2008
    I think both code snippits are abbreviated (notice that the curly for the method isn't closed) so it would be easier for me to pass judgment of which is better/readable if I could see the whole method.   But anther thing that is interesting about the .NET Reflector code is that the 3rd if statement that begins with if (flag3) is completely useless.  flag3 is set to false in the first block and then only set to true if the second if block occurs.  The third if block should be a continuation of the second. @Maximilian, so does the C# compiler really know what best to do?

  • Anonymous
    September 09, 2008
    Both code samples are indeed abbreviated. The C# compiler can only optimize so much, and if you look at the code between both the RSCC and .NET Reflector version there really is no optimization regarding flag3 at all. I agree that there could be a more optimal way to write that piece of code but that would not necessarily have made it more readable.

  • Anonymous
    October 22, 2008
    RSCC invalidates your Mono contribution(s) and .NET Reflector does not, right?

  • Anonymous
    October 22, 2008
    I thought .NET Reflector invalidated Mono contributions as well.