SA1200 : CSharp.Ordering : All using directives must be placed inside of the namespace.

以下的StyleCop警告主要是和Scope 有關的..
SA1200 : CSharp.Ordering : All using directives must be placed inside of the namespace.
SA1200 : CSharp.Ordering : All using directives must be placed inside of the namespace

當你有很多不同的ClassesNamespace
而你的這個Class 和另外一個Namespace上的Class 有相同的名稱上時..
directives放在Namespace內會比較好一點..

這個情況有點複雜..有時候再多加解釋

解決方法:
我們只要把directives放在Namespace內便可以了
E.G. 把程式碼由這個


<strong>using System;</strong>
<strong>using System.Collections.Generic;</strong>
<strong>using System.Linq;</strong>
<strong>using System.Text;</strong>
<strong>using System.Threading.Tasks;</strong>

namespace LGetTextWP8.Classes
{

    class Get_Text_CL
    {
    }
}

SA1200 : CSharp.Ordering : All using directives must be placed inside of the namespace
轉成

namespace LGetTextWP8.Classes
{
  <strong>  using System;</strong>
<strong>    using System.Collections.Generic;</strong>
<strong>    using System.Linq;</strong>
<strong>    using System.Text;</strong>
<strong>    using System.Threading.Tasks;</strong>

    class Get_Text_CL
    {
    }
}

SA1200  CSharp.Ordering  All using directives must be placed inside of the namespace
Happy Coding – Please correct me if my concept is wrong

Leave a Reply