<commit_before>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Collections.Immutable;
using System.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Formatting
{
    public partial class CodeCleanupTests
    {
        private abstract class TestThirdPartyCodeFix : CodeFixProvider
        {
            public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create("HasDefaultCase");

            public override Task RegisterCodeFixesAsync(CodeFixContext context)
            {
                foreach (var diagnostic in context.Diagnostics)
                {
                    context.RegisterCodeFix(
                        CodeAction.Create(
                            "Remove default case",
                            async cancellationToken =>
                            {
                                var root = await context.Document.GetSyntaxRootAsync(cancellationToken);
                                var node = (await diagnostic.Location.SourceTree.GetRootAsync(cancellationToken)).FindNode(diagnostic.Location.SourceSpan);
                                return context.Document.WithSyntaxRoot(root.RemoveNode(node.Parent, SyntaxRemoveOptions.KeepNoTrivia));
                            },
                            nameof(TestThirdPartyCodeFix)),
                        diagnostic);
                }

                return Task.CompletedTask;
            }
        }

        [PartNotDiscoverable, Shared, ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic)]
        private class TestThirdPartyCodeFixWithFixAll : TestThirdPartyCodeFix
        {
            [ImportingConstructor]
            [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
            public TestThirdPartyCodeFixWithFixAll()
            {
            }

            public override FixAllProvider GetFixAllProvider() => BatchFixAllProvider.Instance;
        }

        [PartNotDiscoverable, Shared, ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic)]
        private class TestThirdPartyCodeFixWithOutFixAll : TestThirdPartyCodeFix<commit_msg>mark mef exported test types as `PartNotDiscoverable`<commit_after>﻿// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using System.Collections.Immutable;
using System.Composition;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Host.Mef;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Formatting
{
    public partial class CodeCleanupTests
    {
        private abstract class TestThirdPartyCodeFix : CodeFixProvider
        {
            public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create("HasDefaultCase");

            public override Task RegisterCodeFixesAsync(CodeFixContext context)
            {
                foreach (var diagnostic in context.Diagnostics)
                {
                    context.RegisterCodeFix(
                        CodeAction.Create(
                            "Remove default case",
                            async cancellationToken =>
                            {
                                var root = await context.Document.GetSyntaxRootAsync(cancellationToken);
                                var node = (await diagnostic.Location.SourceTree.GetRootAsync(cancellationToken)).FindNode(diagnostic.Location.SourceSpan);
                                return context.Document.WithSyntaxRoot(root.RemoveNode(node.Parent, SyntaxRemoveOptions.KeepNoTrivia));
                            },
                            nameof(TestThirdPartyCodeFix)),
                        diagnostic);
                }

                return Task.CompletedTask;
            }
        }

        [PartNotDiscoverable, Shared, ExportCodeFixProvider(LanguageNames.CSharp)]
        private class TestThirdPartyCodeFixWithFixAll : TestThirdPartyCodeFix
        {
            [ImportingConstructor]
            [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
            public TestThirdPartyCodeFixWithFixAll()
            {
            }

            public override FixAllProvider GetFixAllProvider() => BatchFixAllProvider.Instance;
        }

        [PartNotDiscoverable, Shared, ExportCodeFixProvider(LanguageNames.CSharp)]
        private class TestThirdPartyCodeFixWithOutFixAll : TestThirdPartyCodeFix
{'fraction_non_alphanumeric': 0.0627748900439824, 'fraction_numerical': 0.0, 'mean_word_length': 2.204996796925048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4155460', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1119, 'n_words': 255}