BUG: Right Click / Copy As

KaelumKaelum Posts: 7
I don't know which update broke this, but this context menu item no longer works correctly. It now always returns code in a .NET 4.6 / C# 6 / VB 14 format, no matter what Optimization you have it set for. However, if your current Optimization is not set to .NET 4.6 / C# 6 / VB 14, the code copied to the clipboard is not even valid code.

Comments

  • HI Kaelum, can you confirm which version you are running please?
    Have you visited our Help Centre?
  • I'm using 9.0.1.374 VSPro
  • Hi Kaelum,

    Sorry I've been trying to reproduce this but am unable to so far, I'm able to get valid code out no matter what combinations I select. Can you provide some examples of what you're seeing please?
    Have you visited our Help Centre?
  • Here is System.Configuration.Provider.ProviderBase disassembled for .NET 4.5:
    public abstract class ProviderBase
    {
        // Fields
        private string _Description;
        private bool _Initialized;
        private string _name;
    
        // Methods
        protected ProviderBase()
        {
        }
    
        public virtual void Initialize(string name, NameValueCollection config)
        {
            ProviderBase base2 = this;
            lock (base2)
            {
                if (this._Initialized)
                {
                    throw new InvalidOperationException(SR.GetString("Provider_Already_Initialized"));
                }
                this._Initialized = true;
            }
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (name.Length == 0)
            {
                throw new ArgumentException(SR.GetString("Config_provider_name_null_or_empty"), "name");
            }
            this._name = name;
            if (config != null)
            {
                this._Description = config["description"];
                config.Remove("description");
            }
        }
    
        // Properties
        public virtual string Description
        {
            get
            {
                if (!string.IsNullOrEmpty(this._Description))
                {
                    return this._Description;
                }
                return this.Name;
            }
        }
    
        public virtual string Name
        {
            get
            {
                return this._name;
            }
        }
    }
    

    and here is what you get if you right click / Copy As / Text:
    namespace System.Configuration.Provider
    {
        using System;
        using System.Collections.Specialized;
        using System.Configuration;
    
        public abstract class ProviderBase
        {
            private string _Description;
            private bool _Initialized;
            private string _name;
    
            protected ProviderBase()
            {
            }
    
            public virtual void Initialize(string name, NameValueCollection config)
            {
                ProviderBase base2 = this;
                lock (base2)
                {
                    if (this._Initialized)
                    {
                        throw new InvalidOperationException(System.Configuration.SR.GetString("Provider_Already_Initialized"));
                    }
                    this._Initialized = true;
                }
                if (name == null)
                {
                    throw new ArgumentNullException("name");
                }
                if (name.Length == 0)
                {
                    throw new ArgumentException(System.Configuration.SR.GetString("Config_provider_name_null_or_empty"), "name");
                }
                this._name = name;
                if (config != null)
                {
                    this._Description = config["description"];
                    config.Remove("description");
                }
            }
    
            public virtual string Description
            {
                get
                {
                    if (!string.IsNullOrEmpty(this._Description))
                    {
                        return this._Description;
                    }
                    return this.Name;
                }
            }
    
            public virtual string Name =>
                this._name;
        }
    }
    

    As you can see, what is being shown in the disassembler is not what is copied to the clipboard. The code for the Name property is completely different and does not compile in VS 2013.
  • Alex BAlex B Posts: 1,131 Diamond 4
    Hi Kaelum,

    I have been able to reproduce this - just for everyone's clarification this is when you right click on the Expand Methods link at the bottom of the disassembled code. You right click > Copy As > Text (or Rich Text or HTML all seem to give the same text) and then when you paste you get the odd outcome seen. The workaround that I can see at this point is to click Expand Methods, then highlight the text and Ctrl+C or right click the highlighted text and choose copy.

    I have raised this bug with internal reference RP-3952 but unfortunately we don't have a time-frame for when this may be addressed.

    Hope this helps clear things up and thanks for pointing this out to us!

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.