Skip to content

Set IDE0005 (Remove unnecessary using directives) severity to Warning #11643

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

Merged
merged 4 commits into from
Mar 31, 2025

Conversation

JaynieBai
Copy link
Member

@JaynieBai JaynieBai commented Mar 28, 2025

Fixes #10159

Context

some of the imports are unnecessary, due to the severity set to none: dotnet_diagnostic.IDE0005.severity = none in the .editorconfig file

Changes Made

  1. Change the severity to Warning: dotnet_diagnostic.IDE0005.severity = warning
  2. Removing the unnecessary imports.
  3. If GenerateDocumentationFile is set to false. Add <NoWarn>$(NoWarn);IDE0005</NoWarn> to ignore IDE0005
    image
    The reason is Compiler does not report unused imports when XML doc comments are disabled roslyn#41640
    image

@JaynieBai JaynieBai marked this pull request as ready for review March 31, 2025 08:48
@JaynieBai JaynieBai requested a review from Copilot March 31, 2025 09:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the project’s IDE0005 diagnostic configuration by changing its severity to Warning and removing unnecessary using directives from various unit test files. The changes help clean up the codebase and avoid clutter from unused imports.

  • Change IDE0005 severity from None to Warning.
  • Remove a number of unused using directives from multiple test files.
  • Update tests to add a NoWarn for IDE0005 when GenerateDocumentationFile is false.

Reviewed Changes

Copilot reviewed 369 out of 370 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Build.OM.UnitTests/Instance/ProjectTargetInstance_Tests.cs Removed the unnecessary "using System.Xml;"
src/Build.OM.UnitTests/Instance/ProjectOnErrorInstance_Tests.cs Removed unnecessary "using System.IO;" and "using System.Xml;" directives
src/Build.OM.UnitTests/Instance/ProjectItemInstance_Tests.cs Removed several unused using directives including "using System.Xml;", "using System.IO;", and others
src/Build.OM.UnitTests/Instance/ProjectInstance_Tests.cs Removed "using System.Xml;"
src/Build.OM.UnitTests/Definition/ProtectImports_Tests.cs Removed "using System.Xml;"
src/Build.OM.UnitTests/Definition/ProjectProperty_Tests.cs Removed "using System.Xml;"
src/Build.OM.UnitTests/Definition/ProjectMetadata_Tests.cs Removed "using System.Xml;"
src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs Removed "using System.Xml;" and "using Xunit.NetCore.Extensions;"
src/Build.OM.UnitTests/Definition/ProjectItemDefinition_Tests.cs Removed "using Microsoft.Build.Shared;"
src/Build.OM.UnitTests/Definition/EditingElementsReferencedByOrReferences_Tests.cs Removed "using System.IO;" and "using System.Xml;" directives
src/Build.OM.UnitTests/Definition/DefinitionEditing_Tests.cs Removed "using System.Xml;" and "using Microsoft.Build.Shared;" directives
src/Build.OM.UnitTests/Construction/SolutionFile_Tests.cs Removed several unnecessary using directives including "using System;", "using System.Collections;", "using System.IO;", "using System.Text;"
src/Build.OM.UnitTests/Construction/ProjectTaskElement_Tests.cs Removed "using System.IO;" and "using System.Xml;" directives
src/Build.OM.UnitTests/Construction/ProjectTargetElement_Tests.cs Removed "using Microsoft.Build.Shared;"
src/Build.OM.UnitTests/Construction/ProjectRootElement_Tests.cs Removed several unused using directives including "using System.Reflection;", "Shouldly", "Microsoft.Build.Framework", and "Xunit.NetCore.Extensions"
src/Build.OM.UnitTests/Construction/ProjectPropertyGroupElement_Tests.cs Removed "using System.IO;" and "using System.Xml;" directives
src/Build.OM.UnitTests/Construction/ProjectItemGroupElement_tests.cs Removed "using System.IO;" and "using System.Xml;" directives
src/Build.OM.UnitTests/Construction/ProjectFormatting_Tests.cs Removed "using System.Xml;"
src/Build.OM.UnitTests/Construction/ConstructionEditing_Tests.cs Removed "using System.Xml;"
Files not reviewed (1)
  • .editorconfig: Language not supported

@YuliiaKovalova YuliiaKovalova merged commit a4ef175 into dotnet:main Mar 31, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set IDE0005 (Remove unnecessary using directives) severity to Error/Warning
3 participants