<commit_before>﻿// Copyright (c) Microsoft Open Technologies, Inc.  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.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.FindSymbols
{
    /// <summary>
    /// Provides helper methods for finding dependent projects across a solution that a given symbol can be referenced within.
    /// </summary>
    internal static class DependentProjectsFinder
    {
        private struct DefinitionProject
        {
            private readonly bool isSourceProject;
            private readonly string assemblyName;

            public DefinitionProject(bool isSourceProject, string assemblyName)
            {
                this.isSourceProject = isSourceProject;
                this.assemblyName = assemblyName;
            }
        }

        private struct DependentProject
        {
            public readonly ProjectId ProjectId;
            public readonly bool HasInternalsAccess;

            public DependentProject(ProjectId dependentProjectId, bool hasInternalsAccess)
            {
                this.ProjectId = dependentProjectId;
                this.HasInternalsAccess = hasInternalsAccess;
            }
        }

        /// <summary>
        /// Dependent projects cache.
        /// For a given solution, maps from an assembly (source/metadata) to the set of projects referencing it.
        ///     Key: DefinitionProject, which contains the assembly name and a flag indicating whether assembly is source or metadata assembly.
        ///     Value: List of DependentProjects, where each DependentProject contains a dependent project ID and a flag indicating whether the dependent project has internals access to definition project.
        /// </summary><commit_msg>DependentProject equality<commit_after>﻿// Copyright (c) Microsoft Open Technologies, Inc.  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.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.FindSymbols
{
    /// <summary>
    /// Provides helper methods for finding dependent projects across a solution that a given symbol can be referenced within.
    /// </summary>
    internal static class DependentProjectsFinder
    {
        private struct DefinitionProject
        {
            private readonly bool isSourceProject;
            private readonly string assemblyName;

            public DefinitionProject(bool isSourceProject, string assemblyName)
            {
                this.isSourceProject = isSourceProject;
                this.assemblyName = assemblyName;
            }
        }

        private struct DependentProject : IEquatable<DependentProject>
        {
            public readonly ProjectId ProjectId;
            public readonly bool HasInternalsAccess;

            public DependentProject(ProjectId dependentProjectId, bool hasInternalsAccess)
            {
                this.ProjectId = dependentProjectId;
                this.HasInternalsAccess = hasInternalsAccess;
            }

            public override bool Equals(object obj)
            {
                return obj is DependentProject && this.Equals((DependentProject)obj);
            }

            public override int GetHashCode()
            {
                return Hash.Combine(HasInternalsAccess, ProjectId.GetHashCode());
            }

            public bool Equals(DependentProject other)
            {
                return HasInternalsAccess == other.HasInternalsAccess && ProjectId.Equals(other.ProjectId);
            }
        }

        /// <summary>
        /// Dependent projects cache.
        /// For a given solution, maps from an assembly (source/metadata) to the set of projects referencing it.
        ///     Key: DefinitionProject, which contains the assembly name and a flag indicating whether assembly is source or metadata assembly.
        ///     Value: List of DependentProjects, where each DependentProject contains a dependent project ID and a flag indicating whether the dependent project has internals access to definition project.
        /// </summary>
{'fraction_non_alphanumeric': 0.06233817964548895, 'fraction_numerical': 0.0007966540529774945, 'mean_word_length': 2.610352264557872, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6037342', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1105, 'n_words': 392}