Why is AppDomainSetup.ShadowCopyFiles a string?

。_饼干妹妹 提交于 2019-12-18 19:01:53

问题


From the documentation:

A String containing the string value "true" to indicate that shadow copying is turned on; or "false" to indicate that shadow copying is turned off.

And its been this way since 1.1. Can anyone shed any light?

I reflector'd the getter and setter for good measure:

public string ShadowCopyFiles
{
    get
    {
        return this.Value[8];
    }
    set
    {
        if ((value != null) && (string.Compare(value, "true", StringComparison.OrdinalIgnoreCase) == 0))
        {
            this.Value[8] = value;
        }
        else
        {
            this.Value[8] = null;
        }
    }
}

//The referenced Value property...

internal string[] Value
{
    get
    {
        if (this._Entries == null)
        {
            this._Entries = new string[0x10];
        }
        return this._Entries;
    }
}

private string[] _Entries; 

So maybe the Value array begets an easier copy constructor or something?


回答1:


Lack of caffeine. Some things are not meant to be understood.

This clearly seems to be a mistake from .NET first version, not fixed because that could break "legacy" code.

Gosh, I just found this:

Thanks for your feedback on the .NET Framework! We agree that this is an oversight and that the property type should be a boolean. However, it is quite difficult (if not impossible) to make this change in a backwards compatible release (such as Orcas), because we would break the code of any customer relying on string comparisons. So unfortunately we must weigh the risk of breaking compatibility vs. the benefits of API cleanliness...and when it comes to best supporting our customer base, the former typically wins. We will track this internally as a good thing to improve and we'll continue to consider it in future releases.

From here



来源:https://stackoverflow.com/questions/1862434/why-is-appdomainsetup-shadowcopyfiles-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!