Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in code fix for SA1200 Using directive must appear in namespace declaration #2363

Closed
GregReddick opened this issue May 27, 2017 · 0 comments · Fixed by #2435
Closed

Bug in code fix for SA1200 Using directive must appear in namespace declaration #2363

GregReddick opened this issue May 27, 2017 · 0 comments · Fixed by #2435
Assignees
Milestone

Comments

@GregReddick
Copy link

GregReddick commented May 27, 2017

Create a file that looks like this:

// <copyright file="Program.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

// xxxyyy
using System;
using System.Runtime.InteropServices;

namespace Cdg.Interop
{
	/// <summary>A monthly dow.</summary>
	[CLSCompliant(false)]
	[StructLayout(LayoutKind.Sequential)]
	public struct MonthlyDow
	{
		int foo;
	}
}

It will complain that the using directives are not within the namespace with warning SA1200. Apply the code fix. The resulting code looks like this:

// <copyright file="Program.cs" company="PlaceholderCompany">
// Copyright (c) PlaceholderCompany. All rights reserved.
// </copyright>

namespace Cdg.Interop
{

    // xxxyyyusing System;
    using System.Runtime.InteropServices;

	/// <summary>A monthly dow.</summary>
	[CLSCompliant(false)]
	[StructLayout(LayoutKind.Sequential)]
	public struct MonthlyDow
	{
		int foo;
	}
}

The comment above the usings moved into the namespace and effectively commented out the "using System".

@sharwell sharwell added this to the 1.1.0 milestone Jun 9, 2017
@sharwell sharwell self-assigned this Jun 19, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 19, 2017
@sharwell sharwell modified the milestones: 1.1.0 Beta 4, 1.1.0 Jun 19, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 19, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 19, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants