From a724cb3efe3c0167752ad163f0524d524e3d68b8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 14 Oct 2023 00:10:13 +0200 Subject: [PATCH] Remove leftover generator APIs --- .../ComputeSharp.SourceGeneration.projitems | 1 - .../Extensions/CompilationExtensions.cs | 42 ------------------- .../Models/DeferredDiagnosticInfo.cs | 25 ----------- 3 files changed, 68 deletions(-) delete mode 100644 src/ComputeSharp.SourceGeneration/Models/DeferredDiagnosticInfo.cs diff --git a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems index 413e50cc..3dc0426f 100644 --- a/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems +++ b/src/ComputeSharp.SourceGeneration/ComputeSharp.SourceGeneration.projitems @@ -26,7 +26,6 @@ - diff --git a/src/ComputeSharp.SourceGeneration/Extensions/CompilationExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/CompilationExtensions.cs index 0c10fb39..364a639a 100644 --- a/src/ComputeSharp.SourceGeneration/Extensions/CompilationExtensions.cs +++ b/src/ComputeSharp.SourceGeneration/Extensions/CompilationExtensions.cs @@ -55,46 +55,4 @@ internal static class CompilationExtensions { return compilation.Options is CSharpCompilationOptions { AllowUnsafe: true }; } - - /// - /// - /// Checks whether or not a type with a specified metadata name is accessible from a given instance. - /// - /// - /// This method enumerates candidate type symbols to find a match in the following order: - /// - /// - /// If only one type with the given name is found within the compilation and its referenced assemblies, check its accessibility. - /// - /// - /// If the current defines the symbol, check its accessibility. - /// - /// - /// Otherwise, check whether the type exists and is accessible from any of the referenced assemblies. - /// - /// - /// - /// - /// The to consider for analysis. - /// The fully-qualified metadata type name to find. - /// Whether a type with the specified metadata name can be accessed from the given compilation. - public static bool HasAccessibleTypeWithMetadataName(this Compilation compilation, string fullyQualifiedMetadataName) - { - // If there is only a single matching symbol, check its accessibility - if (compilation.GetTypeByMetadataName(fullyQualifiedMetadataName) is INamedTypeSymbol typeSymbol) - { - return compilation.IsSymbolAccessibleWithin(typeSymbol, compilation.Assembly); - } - - // Otherwise, check all available types - foreach (INamedTypeSymbol currentTypeSymbol in compilation.GetTypesByMetadataName(fullyQualifiedMetadataName)) - { - if (compilation.IsSymbolAccessibleWithin(currentTypeSymbol, compilation.Assembly)) - { - return true; - } - } - - return false; - } } \ No newline at end of file diff --git a/src/ComputeSharp.SourceGeneration/Models/DeferredDiagnosticInfo.cs b/src/ComputeSharp.SourceGeneration/Models/DeferredDiagnosticInfo.cs deleted file mode 100644 index a88117ba..00000000 --- a/src/ComputeSharp.SourceGeneration/Models/DeferredDiagnosticInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Collections.Immutable; -using System.Linq; -using ComputeSharp.SourceGeneration.Helpers; -using Microsoft.CodeAnalysis; - -namespace ComputeSharp.SourceGeneration.Models; - -/// -/// A model for a serializeable diagnostic info to be reconstructed later in a pipeline. -/// -/// The wrapped instance. -/// The diagnostic arguments. -internal sealed record DeferredDiagnosticInfo(DiagnosticDescriptor Descriptor, EquatableArray Arguments) -{ - /// - /// Creates a new instance with the specified parameters. - /// - /// The input for the diagnostics to create. - /// The optional arguments for the formatted message to include. - /// A new instance with the specified parameters. - public static DeferredDiagnosticInfo Create(DiagnosticDescriptor descriptor, params object[] args) - { - return new(descriptor, args.Select(static arg => arg.ToString()).ToImmutableArray()); - } -} \ No newline at end of file