<|start_filename|>tools/FileIssues/Resources.Designer.cs<|end_filename|>
﻿//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace FileIssues {
    using System;
    
    
    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class Resources {
        
        private static global::System.Resources.ResourceManager resourceMan;
        
        private static global::System.Globalization.CultureInfo resourceCulture;
        
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal Resources() {
        }
        
        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileIssues.Resources", typeof(Resources).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }
        
        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Delaying {0} msec between issues....
        /// </summary>
        internal static string DebugDelaying {
            get {
                return ResourceManager.GetString("DebugDelaying", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to None.
        /// </summary>
        internal static string DependencyNone {
            get {
                return ResourceManager.GetString("DependencyNone", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Error: {0}.
        /// </summary>
        internal static string ErrorFormat {
            get {
                return ResourceManager.GetString("ErrorFormat", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to The rules inventory file &quot;{0}&quot; does not exist..
        /// </summary>
        internal static string ErrorRulesFileNotFound {
            get {
                return ResourceManager.GetString("ErrorRulesFileNotFound", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Adding label &quot;{0}&quot;....
        /// </summary>
        internal static string InfoAddingLabel {
            get {
                return ResourceManager.GetString("InfoAddingLabel", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Closing issue #{0}....
        /// </summary>
        internal static string InfoClosingIssue {
            get {
                return ResourceManager.GetString("InfoClosingIssue", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to --dry-run option specified; issue was not actually created..
        /// </summary>
        internal static string InfoDryRunIssueNotCreated {
            get {
                return ResourceManager.GetString("InfoDryRunIssueNotCreated", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to --dry-run option specified; issue was not actually updated..
        /// </summary>
        internal static string InfoDryRunIssueNotUpdated {
            get {
                return ResourceManager.GetString("InfoDryRunIssueNotUpdated", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to --dry-run option specified; labels were not actually updated..
        /// </summary>
        internal static string InfoDryRunLabelsNotUpdated {
            get {
                return ResourceManager.GetString("InfoDryRunLabelsNotUpdated", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Filing new issue for rule {0}....
        /// </summary>
        internal static string InfoFilingNewIssue {
            get {
                return ResourceManager.GetString("InfoFilingNewIssue", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Issue #{0} created..
        /// </summary>
        internal static string InfoIssueCreated {
            get {
                return ResourceManager.GetString("InfoIssueCreated", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Issue #{0} updated..
        /// </summary>
        internal static string InfoIssueUpdated {
            get {
                return ResourceManager.GetString("InfoIssueUpdated", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Removing label &quot;{0}&quot;....
        /// </summary>
        internal static string InfoRemovingLabel {
            get {
                return ResourceManager.GetString("InfoRemovingLabel", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Reopening issue #{0}....
        /// </summary>
        internal static string InfoReopeningIssue {
            get {
                return ResourceManager.GetString("InfoReopeningIssue", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Updating issue #{0} for rule {1}....
        /// </summary>
        internal static string InfoUpdatingExistingIssue {
            get {
                return ResourceManager.GetString("InfoUpdatingExistingIssue", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to Multiple issues exists for rule {0}: {1}.
        /// </summary>
        internal static string WarningMultipleIssuesExist {
            get {
                return ResourceManager.GetString("WarningMultipleIssuesExist", resourceCulture);
            }
        }
        
        /// <summary>
        ///   Looks up a localized string similar to No area label matches the proposed analyzer &quot;{0}&quot; for rule {1}..
        /// </summary>
        internal static string WarningNoAreaAssigned {
            get {
                return ResourceManager.GetString("WarningNoAreaAssigned", resourceCulture);
            }
        }
    }
}


<|start_filename|>tools/FileIssues/Program.cs<|end_filename|>
﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using CommandLine;
using CsvHelper;
using log4net;
using Octokit;

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

namespace FileIssues
{
    internal class Program
    {
        private const int Succeeded = 0;
        private const int Failed = 1;

        private const string FxCopPortLabel = "FxCop-Port";
        private const string NeedsReviewLabel = "Needs-Review";
        private const string CutLabel = "Resolution-Won't Fix";
        private const string PortedLabel = "Resolution-Fixed";
        private const string UrgencySoonLabel = "Urgency-Soon";

        private readonly ILog _log = LogHelper.GetLogger();
        private readonly FileIssuesOptions _options;

        private readonly IIssuesClient _issuesClient;
        private readonly IIssuesLabelsClient _issuesLabelsClient;

        private static int Main(string[] args)
        {
            return Parser.Default.ParseArguments<FileIssuesOptions>(args)
                .MapResult(
                    options => new Program(options).Run().Result,
                    errs => Failed
                    );
        }

        private Program(FileIssuesOptions options)
        {
            _options = options;

            _issuesClient = GitHub.GetIssuesClient(_options.Token);
            _issuesLabelsClient = GitHub.GetIssuesLabelsClient(_options.Token);
        }

        private async Task<int> Run()
        {
            if (!File.Exists(_options.RulesFilePath))
            {
                _log.ErrorFormat(Resources.ErrorRulesFileNotFound, _options.RulesFilePath);
                return Failed;
            }

            var rulesToPort = GetRulePortingInfo();
            await CreateIssues(rulesToPort);

            return Succeeded;
        }

        private IEnumerable<PortingInfo> GetRulePortingInfo()
        {
            var rulesToPort = new List<PortingInfo>();

            var reader = new StreamReader(new FileStream(_options.RulesFilePath, System.IO.FileMode.Open));
            var csv = new CsvReader(reader);
            csv.Configuration.RegisterClassMap<PortingInfoClassMap>();

            while (csv.Read())
            {
                var portingInfo = csv.GetRecord<PortingInfo>();
                if (portingInfo.Disposition != Disposition.Unknown)
                {
                    rulesToPort.Add(portingInfo);
                }
            }

            return rulesToPort;
        }

        private async Task CreateIssues(IEnumerable<PortingInfo> rulesToPort)
        {
            var existingIssues = await _issuesClient.GetAllForRepository(
                _options.RepoOwner,
                _options.RepoName,
                new RepositoryIssueRequest
                {
                    Filter = IssueFilter.All,   // Get issues whether or not they're assigned to me.
                    State = ItemState.All       // Get issues whether they're open or closed.
                });

            foreach (var ruleToPort in rulesToPort)
            {
                string title = MakeIssueTitle(ruleToPort);
                var matchingIssues = existingIssues.Where(issue => issue.Title == title);
                int numMatchingIssues = matchingIssues.Count();

                if (numMatchingIssues == 0)
                {
                    _log.InfoFormat(Resources.InfoFilingNewIssue, ruleToPort.Id);

                    Issue issue = FileIssueAsync(ruleToPort, title).Result;

                    // If the issue we just filed has already been dealt with, one way
                    // or another, then immediately close it. UpdateIssueAsync will do that.
                    if (ruleToPort.Disposition == Disposition.Cut || ruleToPort.Disposition == Disposition.Ported)
                    {
                        await UpdateIssueAsync(ruleToPort, issue);
                    }
                }
                else if (numMatchingIssues == 1)
                {
                    Issue existingIssue = matchingIssues.First();
                    int issueNumber = existingIssue.Number;

                    _log.InfoFormat(Resources.InfoUpdatingExistingIssue, issueNumber, ruleToPort.Id);

                    await UpdateIssueAsync(ruleToPort, existingIssue);
                }
                else if (numMatchingIssues > 1)
                {
                    _log.WarnFormat(
                        Resources.WarningMultipleIssuesExist,
                        ruleToPort.Id,
                        string.Join(", ", matchingIssues.Select(i => i.Number.ToString()).ToArray()));
                }

                if (_options.Delay > 0 && !_options.DryRun)
                {
                    _log.DebugFormat(Resources.DebugDelaying, _options.Delay);
                    Thread.Sleep(_options.Delay);
                }
            }
        }

        private async Task<Issue> FileIssueAsync(PortingInfo ruleToPort, string title)
        {
            Issue issue = null;

            NewIssue newIssue = CreateNewIssue(ruleToPort, title);
            if (_options.DryRun)
            {
                _log.Info(Resources.InfoDryRunIssueNotCreated);
                issue = MakeFakeIssue(newIssue);
            }
            else
            {
                issue = await _issuesClient.Create(_options.RepoOwner, _options.RepoName, newIssue);
                _log.InfoFormat(Resources.InfoIssueCreated, issue.Number);
            }

            return issue;
        }

        /// <summary>
        /// Synthesize an Issue object from the NewIssue object representing
        /// the issue we sent to GitHub to be filed.
        /// </summary>
        /// <param name="newIssue">
        /// Object representing the issue we sent to GitHub.
        /// </param>
        /// <returns>
        /// An Issue object, partially filled out with information from <paramref name="newIssue"/>.
        /// </returns>
        /// <remarks>
        /// In a dry run, we don't actually send the NewIssue object to GitHub, so we
        /// don't get a real Issue object back. If we then want to update the Issue object,
        /// as we do in the case where we want to immediately close it, we must
        /// synthesize an issue object so that the dry run correctly reports what
        /// would have happened in the course of the update.
        /// </remarks>
        private Issue MakeFakeIssue(NewIssue newIssue)
        {
            return new Issue(
                null,               // url
                null,               // htmlUrl
                null,               // commentsUrl
                9999,               // issue number
                ItemState.Open,     // state
                newIssue.Title,     // title
                newIssue.Body,      // body
                null,               // user
                newIssue.Labels     // labels (with conversion from label names to Label objects
                    .Select(labelName => new Label(null, labelName, "no color"))
                    .ToList().
                    AsReadOnly(),
                null,               // assignee
                null,               // milestone
                0,                  // number of comments
                null,               // pull request
                null,               // closed date
                DateTimeOffset.Now, // created date
                null                // updated date
                );
        }

        private async Task UpdateIssueAsync(PortingInfo ruleToPort, Issue existingIssue)
        {
            int issueNumber = existingIssue.Number;

            IssueUpdate issueUpdate = CreateIssueUpdate(ruleToPort, existingIssue);
            if (_options.DryRun)
            {
                _log.Info(Resources.InfoDryRunIssueNotUpdated);
            }
            else
            {
                await _issuesClient.Update(_options.RepoOwner, _options.RepoName, issueNumber, issueUpdate);
                _log.InfoFormat(Resources.InfoIssueUpdated, issueNumber);
            }

            // The GitHub Issues API doesn't let you add or remove individual labels in the course of
            // an Update operation. Use the IssuesLabels API to do that.
            await UpdateIssueLabelsAsync(ruleToPort, existingIssue);
        }

        private string MakeIssueTitle(PortingInfo ruleToPort)
        {
            // Don't localize this. Otherwise people with different locales would file issues
            // with different titles, and you would get duplicates.
            const string FxCopPortTitlePrefix = "Port FxCop rule";

            return $"{FxCopPortTitlePrefix} {ruleToPort.Id}: {ruleToPort.Name}";
        }

        private NewIssue CreateNewIssue(PortingInfo ruleToPort, string title)
        {
            var newIssue = new NewIssue(title);
            AddLabel(FxCopPortLabel, newIssue.Labels);

            AddAreaLabel(ruleToPort, newIssue.Labels);

            switch (ruleToPort.Disposition)
            {
                case Disposition.NeedsReview:
                    AddLabel(NeedsReviewLabel, newIssue.Labels);
                    break;

                case Disposition.Cut:
                    AddLabel(CutLabel, newIssue.Labels);
                    break;

                case Disposition.Ported:
                    AddLabel(PortedLabel, newIssue.Labels);
                    break;
            }

            if (ruleToPort.Soon)
            {
                AddLabel(UrgencySoonLabel, newIssue.Labels);
            }

            newIssue.Body = FormatIssueBody(ruleToPort);

            return newIssue;
        }

        private static readonly Dictionary<string, string> s_analyzerNameToLabelNameDictionary = new Dictionary<string, string>
        {
            { "ApiReview", "Area-ApiReview.Analyzers" },

            // TODO: Rename area to "Area-Desktop.Analyzers".
            { "Desktop", "Area-DesktopAnalyzers" },

            // Diagnostics applied to the Roslyn codebase itself.
            // TODO: Rename area to "Area-Roslyn.Diagnostics.Analyzers".
            { "Roslyn.Diagnostics", "Area-RoslynAnalyzers" },

            { "Microsoft.ApiDesignGuidelines", "Area-Microsoft.ApiDesignGuidelines.Analyzers" },

            // Diagnostics for usage of the Roslyn API (e.g., by analyzer authors).
            // TODO: Rename area to "Area-Microsoft.CodeAnalysis.Analyzers".
            { "Microsoft.CodeAnalysis", "Area-CodeAnalysisDiagnosticAnalyzers" },

            { "Microsoft.Composition", "Area-Microsoft.Composition.Analyzers" },
            { "Microsoft.Maintainability", "Area-Microsoft.Maintainability.Analyzers" },
            { "Microsoft.QualityGuidelines", "Area-Microsoft.QualityGuidelines.Analyzers" },
            { "System.Diagnostics", "Area-System.Diagnostics.Analyzers" },
            { "System.Resources", "Area-System.Resources.Analyzers" },

            // TODO: Rename area to "Area-System.Runtime.Analyzers".
            { "System.Runtime", "Area-SystemRuntimeAnalyzers" },

            { "System.Runtime.InteropServices", "Area-System.Runtime.InteropServices.Analyzers" },
            { "System.Security.Cryptography.Algorithms", "Area-System.Security.Cryptography.Algorithms.Analyzers" },
            { "System.Threading.Tasks", "Area-System.Threading.Tasks.Analyzers" },
            { "Text", "Area-Text.Analyzers" },
            { "XmlDocumentationComments", "Area-XmlDocumentationComments.Analyzers" }
        };

        private void AddAreaLabel(PortingInfo ruleToPort, Collection<string> labels)
        {
            string areaLabel;
            if (!s_analyzerNameToLabelNameDictionary.TryGetValue(ruleToPort.ProposedAnalyzer, out areaLabel))
            {
                _log.WarnFormat(Resources.WarningNoAreaAssigned, ruleToPort.ProposedAnalyzer, ruleToPort.Id);
            }
            else
            {
                AddLabel(areaLabel, labels);
            }
        }

        private IssueUpdate CreateIssueUpdate(PortingInfo ruleToPort, Issue existingIssue)
        {
            IssueUpdate issueUpdate = existingIssue.ToUpdate();
            issueUpdate.Body = FormatIssueBody(ruleToPort);

            if (existingIssue.State == ItemState.Open && (ruleToPort.Disposition == Disposition.Cut || ruleToPort.Disposition == Disposition.Ported))
            {
                _log.InfoFormat(Resources.InfoClosingIssue, existingIssue.Number);
                issueUpdate.State = ItemState.Closed;
            }

            if (existingIssue.State == ItemState.Closed && (ruleToPort.Disposition != Disposition.Cut && ruleToPort.Disposition != Disposition.Ported))
            {
                _log.InfoFormat(Resources.InfoReopeningIssue, existingIssue.Number);
                issueUpdate.State = ItemState.Open;
            }

            return issueUpdate;
        }

        private async Task UpdateIssueLabelsAsync(PortingInfo ruleToPort, Issue existingIssue)
        {
            var existingLabelNames = new Collection<string>(existingIssue.Labels.Select(label => label.Name).ToList());

            var labelNamesToAdd = new Collection<string>();
            var labelNamesToRemove = new Collection<string>();

            AddLabel(FxCopPortLabel, labelNamesToAdd, existingLabelNames);

            if (ruleToPort.Soon)
            {
                AddLabel(UrgencySoonLabel, labelNamesToAdd, existingLabelNames);
            }
            else
            {
                RemoveLabel(UrgencySoonLabel, labelNamesToRemove, existingLabelNames);
            }

            switch (ruleToPort.Disposition)
            {
                case Disposition.NeedsReview:
                    AddLabel(NeedsReviewLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Port:
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Cut:
                    AddLabel(CutLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(PortedLabel, labelNamesToRemove, existingLabelNames);
                    break;

                case Disposition.Ported:
                    AddLabel(PortedLabel, labelNamesToAdd, existingLabelNames);
                    RemoveLabel(CutLabel, labelNamesToRemove, existingLabelNames);
                    RemoveLabel(NeedsReviewLabel, labelNamesToRemove, existingLabelNames);
                    break;
            }

            RemoveAreaLabels(existingLabelNames, labelNamesToRemove);
            AddAreaLabel(ruleToPort, labelNamesToAdd);

            if (_options.DryRun)
            {
                _log.Info(Resources.InfoDryRunLabelsNotUpdated);
            }
            else
            {
                if (labelNamesToAdd.Any())
                {
                    await _issuesLabelsClient.AddToIssue(
                        _options.RepoOwner,
                        _options.RepoName,
                        existingIssue.Number,
                        labelNamesToAdd.ToArray());
                }

                // Take care not to remove any labels we've just added.
                //
                // For some reason the "Remove" API doesn't take an array.
                foreach (string labelName in labelNamesToRemove.Except(labelNamesToAdd))
                {
                    await _issuesLabelsClient.RemoveFromIssue(
                        _options.RepoOwner,
                        _options.RepoName,
                        existingIssue.Number,
                        labelName);
                }
            }
        }

        private void RemoveAreaLabels(Collection<string> existingLabelNames, Collection<string> labelNamesToRemove)
        {
            foreach (string label in existingLabelNames.Where(l => l.StartsWith("Area-") && l.EndsWith("Analyzers")))
            {
                RemoveLabel(label, labelNamesToRemove, existingLabelNames);
            }
        }

        private void AddLabel(string label, Collection<string> labels, Collection<string> existingLabels = null)
        {
            if (existingLabels == null || !existingLabels.Contains(label))
            {
                labels.Add(label);
                _log.InfoFormat(Resources.InfoAddingLabel, label);
            }
        }

        private void RemoveLabel(string label, Collection<string> labels, Collection<string> existingLabels = null)
        {
            if (existingLabels == null || existingLabels.Contains(label))
            {
                labels.Add(label);
                _log.InfoFormat(Resources.InfoRemovingLabel, label);
            }
        }

        private string FormatIssueBody(PortingInfo ruleToPort)
        {
            // Don't localize this. We want all the issues in English.
            return
                $"**Title:** {ruleToPort.Title}\n\n" +
                $"**Description:**\n\n{ruleToPort.Description}\n\n" +
                $"**Dependency:** {ruleToPort.Dependency}\n\n" +
                $"**Notes:**\n\n{ruleToPort.Notes}";
        }
    }
}


<|start_filename|>tools/AnalyzerCodeGenerator/template/cibuild.cmd<|end_filename|>
@setlocal enabledelayedexpansion

REM Parse Arguments.

set AnalyzersRoot=%~dp0
set BuildConfiguration=Debug
:ParseArguments
if "%1" == "" goto :DoneParsing
if /I "%1" == "/?" call :Usage && exit /b 1
if /I "%1" == "/debug" set BuildConfiguration=Debug&&shift&& goto :ParseArguments
if /I "%1" == "/release" set BuildConfiguration=Release&&shift&& goto :ParseArguments
call :Usage && exit /b 1
:DoneParsing

call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"

msbuild /v:m /m BuildAndTest.proj /p:CIBuild=true /p:Configuration=%BuildConfiguration%
if ERRORLEVEL 1 (
    taskkill /F /IM vbcscompiler.exe
    echo Build failed
    exit /b 1
)

REM Kill any instances of VBCSCompiler.exe to release locked files;
REM otherwise future CI runs may fail while trying to delete those files.
taskkill /F /IM vbcscompiler.exe

REM It is okay and expected for taskkill to fail (it's a cleanup routine).  Ensure
REM caller sees successful exit.
exit /b 0

:Usage
@echo Usage: cibuild.cmd [/debug^|/release]
@echo   /debug 	Perform debug build.  This is the default.
@echo   /release Perform release build
@goto :eof

<|start_filename|>tools/FileIssues/GitHub.cs<|end_filename|>
﻿using System;
using Octokit;

namespace FileIssues
{
    internal static class GitHub
    {
        private const string ApplicationName = "RoslynAnalyzerIssueFiler";

        private static GitHubClient _gitHubClient;

        private static GitHubClient GetGitHubClient(string token)
        {
            if (_gitHubClient == null)
            {
                _gitHubClient = new GitHubClient(new ProductHeaderValue(ApplicationName));
                _gitHubClient.Connection.Credentials = new Credentials(token);
            }

            return _gitHubClient;
        }

        internal static IIssuesClient GetIssuesClient(string token)
        {
            return GetGitHubClient(token).Issue;
        }

        internal static IIssuesLabelsClient GetIssuesLabelsClient(string token)
        {
            return GetIssuesClient(token).Labels;
        }
    }
}


<|start_filename|>tools/AnalyzerCodeGenerator/template/src/Test/Utilities/CodeFixTests.Extensions.cs<|end_filename|>
﻿// Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CSharp;
using Roslyn.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.UnitTests
{
    public static class DiagnosticFixerTestsExtensions
    {
        internal static Document Apply(this Document document, CodeAction action)
        {
            var operations = action.GetOperationsAsync(CancellationToken.None).Result;
            var solution = operations.OfType<ApplyChangesOperation>().Single().ChangedSolution;
            return solution.GetDocument(document.Id);
        }
    }
}


<|start_filename|>tools/FileIssues/PortingInfoClassMap.cs<|end_filename|>
﻿using CsvHelper.Configuration;

namespace FileIssues
{
    /// <summary>
    /// Class used by CsvHelper to map columns from the CSV file to properties of
    /// the <see cref="PortingInfo"/> class.
    /// </summary>
    public sealed class PortingInfoClassMap: CsvClassMap<PortingInfo>
    {
        public PortingInfoClassMap()
        {
            Map(pi => pi.Id).Name("Id");
            Map(pi => pi.Name).Name("Name");
            Map(pi => pi.Title).Name("Title");
            Map(pi => pi.Description).Name("Description");
            Map(pi => pi.Notes).Name("Notes");
            Map(pi => pi.ProposedAnalyzer).Name("Proposed Analyzer");
            Map(pi => pi.Disposition).Name("Port?").TypeConverter<DispositionConverter>();
            Map(pi => pi.RevisedPriority).Name("Revised Priority").TypeConverter<PriorityConverter>();
            Map(pi => pi.OriginalPriority).Name("Original Priority").TypeConverter<PriorityConverter>();
            Map(pi => pi.Dependency).Name("Dependency").TypeConverter<DependencyConverter>();
        }
    }
}


<|start_filename|>tools/FileIssues/Priority.cs<|end_filename|>
﻿namespace FileIssues
{
    public enum Priority
    {
        None = 0,
        Low,
        High
    }
}


<|start_filename|>tools/FileIssues/DispositionConverter.cs<|end_filename|>
﻿using System;
using CsvHelper.TypeConversion;

namespace FileIssues
{
    /// <summary>
    /// Class that converts the string value of the "Port?" column in the CSV file
    /// into a value for the <see cref="PortingInfo.Disposition"/> property.
    /// </summary>
    internal class DispositionConverter : ITypeConverter
    {
        public bool CanConvertFrom(Type type)
        {
            return type == typeof(string);
        }

        public bool CanConvertTo(Type type)
        {
            return type == typeof(Disposition);
        }

        public object ConvertFromString(TypeConverterOptions options, string text)
        {
            Disposition disposition = Disposition.Unknown;

            if (string.IsNullOrWhiteSpace(text))
            {
                disposition = Disposition.NeedsReview;
            }
            else if (text.StartsWith("yes", StringComparison.InvariantCultureIgnoreCase))
            {
                disposition = Disposition.Port;
            }
            else if (text.StartsWith("no", StringComparison.InvariantCultureIgnoreCase))
            {
                disposition = Disposition.Cut;
            }
            else if (text.StartsWith("ported", StringComparison.InvariantCultureIgnoreCase))
            {
                disposition = Disposition.Ported;
            }

            return disposition;
        }

        public string ConvertToString(TypeConverterOptions options, object value)
        {
            throw new NotImplementedException();
        }
    }
}

<|start_filename|>tools/FileIssues/PortingInfo.cs<|end_filename|>
﻿namespace FileIssues
{
    public class PortingInfo
    {
        public string Id { get; set; }

        public string Name { get; set; }

        public string Title { get; set; }

        public string Description { get; set; }

        public string ProposedAnalyzer { get; set; }

        public string Notes { get; set; }

        public Disposition Disposition { get; set; }

        public Priority OriginalPriority { get; set; }

        public Priority RevisedPriority { get; set; }

        public string Dependency { get; set; }

        public bool Soon
        {
            get
            {
                return RevisedPriority == Priority.High
                    || (RevisedPriority == Priority.None && OriginalPriority == Priority.High); 
            }
        }
    }
}


<|start_filename|>tools/FileIssues/PriorityConverter.cs<|end_filename|>
﻿using System;
using CsvHelper.TypeConversion;

namespace FileIssues
{
    /// <summary>
    /// Class that converts the string values of the "Original Priority" and
    /// "Revised Priority" columns in the CSV file into values for the
    /// <see cref="PortingInfo.OriginalPriority"/> and <see cref="PortingInfo.RevisedPriority"/>
    /// properties.
    /// </summary>
    internal class PriorityConverter : ITypeConverter
    {
        public bool CanConvertFrom(Type type)
        {
            return type == typeof(string);
        }

        public bool CanConvertTo(Type type)
        {
            return false;
        }

        public object ConvertFromString(TypeConverterOptions options, string text)
        {
            Priority priority = Priority.None;

            if (text.StartsWith("low", StringComparison.InvariantCultureIgnoreCase))
            {
                priority = Priority.Low;
            }
            else if (text.StartsWith("high", StringComparison.InvariantCultureIgnoreCase))
            {
                priority = Priority.High;
            }

            return priority;
        }

        public string ConvertToString(TypeConverterOptions options, object value)
        {
            throw new NotImplementedException();
        }
    }
}

<|start_filename|>tools/FileIssues/LogHelper.cs<|end_filename|>
﻿using System.Runtime.CompilerServices;
using log4net;

namespace FileIssues
{
    public static class LogHelper
    {
        public static ILog GetLogger([CallerFilePath] string fileName = "")
        {
            return LogManager.GetLogger(fileName);
        }
    }
}


<|start_filename|>tools/FileIssues/Disposition.cs<|end_filename|>
﻿namespace FileIssues
{
    public enum Disposition
    {
        Unknown = 0,
        NeedsReview = 1,
        Port = 2,
        Cut = 3,
        Ported
    }
}


<|start_filename|>tools/FileIssues/FileIssuesOptions.cs<|end_filename|>
﻿using CommandLine;

namespace FileIssues
{
    public class FileIssuesOptions
    {
        [Option(
            'f',
            "rules-file-path",
            Required = true,
            HelpText = "The path to the CSV file containing the rule porting information")]
        public string RulesFilePath { get; set; }

        [Option(
            'o',
            "repo-owner",
            Required = true,
            HelpText = "The owner of the repo in which issues should be filed")]
        public string RepoOwner { get; set; }

        [Option(
            'r',
            "repo-name",
            Required = true,
            HelpText = "The name of the repo in which issues should be filed")]
        public string RepoName { get; set; }

        [Option(
            't',
            "token",
            Required = true,
            HelpText = "Your GitHub personal access token")]
        public string Token { get; set; }

        [Option(
            'd',
            "delay",
            HelpText = "Delay after each issue creation (msec)",
            Default = 120000)]
        // This prevents GitHub from failing multiple rapid issue creation requests
        // because it considers them "abuse".
        public int Delay { get; set; }

        [Option(
            'n',
            "dry-run",
            HelpText = "Don't actually do anything; just show what would be done.",
            Default = false)]
        public bool DryRun { get; set; }
    }
}


<|start_filename|>src/Text.Analyzers/UnitTests/Properties/launchSettings.json<|end_filename|>
{
  "profiles": {
    "TestSetup": {
      "commandName": "Executable",
      "executablePath": "$(NuGetPackageRoot)\\xunit.runner.console\\$(XUnitVersion)\\tools\\xunit.console.x86.exe",
      "commandLineArgs": "$(AssemblyName).dll -noshadow -wait",
      "workingDirectory": "$(OutDir)"
    }
  }
}

<|start_filename|>tools/FileIssues/DependencyConverter.cs<|end_filename|>
﻿using System;
using CsvHelper.TypeConversion;

namespace FileIssues
{
    /// <summary>
    /// Class that adjusts the string value of the "Dependency" column in the CSV file
    /// before setting the <see cref="PortingInfo.Dependency"/> property.
    /// </summary>
    internal class DependencyConverter : ITypeConverter
    {
        public bool CanConvertFrom(Type type)
        {
            return type == typeof(string);
        }

        public bool CanConvertTo(Type type)
        {
            return type == typeof(string);
        }

        public object ConvertFromString(TypeConverterOptions options, string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                text = Resources.DependencyNone;
            }

            return text;
        }

        public string ConvertToString(TypeConverterOptions options, object value)
        {
            throw new NotImplementedException();
        }
    }
}