2 types derived from CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (2)
371public sealed class Shebang(in ParseInfo info) : CSharpDirective(info) 376public abstract class Named(in ParseInfo info) : CSharpDirective(info)
85 references to CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (85)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (32)
38public static ImmutableArray<CSharpDirective> FindDirectives(SourceFile sourceFile, bool reportAllErrors, ErrorReporter errorReporter, bool checkDuplicates = true) 40var builder = ImmutableArray.CreateBuilder<CSharpDirective>(); 88ImmutableArray<CSharpDirective>.Builder? builder, 115var info = new CSharpDirective.ParseInfo 122builder?.Add(new CSharpDirective.Shebang(info)); 137var context = new CSharpDirective.ParseContext 157if (CSharpDirective.Parse(context) is { } directive) 274internal abstract class CSharpDirective(in CSharpDirective.ParseInfo info) 885private Dictionary<CSharpDirective.Named, CSharpDirective.Named>? _seen; 891public void CheckDirective(CSharpDirective.Named directive, ErrorReporter reportError, out bool shouldKeep) 893if (directive is CSharpDirective.Project or CSharpDirective.Ref or CSharpDirective.IncludeOrExclude) 924private static bool HasSameValue(CSharpDirective.Named existingDirective, CSharpDirective.Named directive) 927Debug.Assert(existingDirective is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 928Debug.Assert(directive is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 932(CSharpDirective.Sdk existing, CSharpDirective.Sdk current) => 934(CSharpDirective.Property existing, CSharpDirective.Property current) => 936(CSharpDirective.Package existing, CSharpDirective.Package current) => 946internal sealed class NamedDirectiveComparer : IEqualityComparer<CSharpDirective.Named> 952public bool Equals(CSharpDirective.Named? x, CSharpDirective.Named? y) 962public int GetHashCode(CSharpDirective.Named obj)
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (53)
40private (ImmutableArray<CSharpDirective> Original, ImmutableArray<CSharpDirective> Evaluated)? _evaluatedDirectives; 144return directives.OfType<CSharpDirective.Property>() 210/// <c>#:include</c>/<c>#:exclude</c> have their <see cref="CSharpDirective.IncludeOrExclude.ItemType"/> determined 213private async ValueTask<ImmutableArray<CSharpDirective>> EvaluateDirectivesAsync( 215ImmutableArray<CSharpDirective> directives, 218if (!directives.Any(static d => d is CSharpDirective.Project or CSharpDirective.IncludeOrExclude or CSharpDirective.Ref)) 223var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 227foreach (var directive in directives) 231case CSharpDirective.Project projectDirective: 232projectDirective = projectDirective.WithName(await project.ExpandStringAsync(projectDirective.Name).ConfigureAwait(false), CSharpDirective.Project.NameKind.Expanded); 238case CSharpDirective.Ref refDirective: 239refDirective = refDirective.WithName(await project.ExpandStringAsync(refDirective.Name).ConfigureAwait(false), CSharpDirective.Ref.NameKind.Expanded); 245case CSharpDirective.IncludeOrExclude includeOrExcludeDirective: 271return CSharpDirective.IncludeOrExclude.ParseMapping( 272await project.GetPropertyValueAsync(CSharpDirective.IncludeOrExclude.MappingPropertyName).ConfigureAwait(false), 296ImmutableArray<CSharpDirective> evaluatedDirectives) 300public ImmutableArray<CSharpDirective> EvaluatedDirectives { get; } = evaluatedDirectives; 306ImmutableArray<CSharpDirective> directives = default, 313ImmutableArray<CSharpDirective> evaluatedDirectives; 341var evaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(); 359var deduplicatedFileEvaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(fileEvaluatedDirectives.Length); 360foreach (var directive in fileEvaluatedDirectives) 362if (directive is CSharpDirective.Sdk) 368if (directive is CSharpDirective.Named named) 433ImmutableArray<CSharpDirective> DeduplicateSdkDirectives(ImmutableArray<CSharpDirective> directives) 435if (!directives.Any(static directive => directive is CSharpDirective.Sdk)) 440var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 443foreach (var directive in directives) 445if (directive is CSharpDirective.Sdk sdk) 469ImmutableArray<CSharpDirective> directives, 516ImmutableArray<CSharpDirective> directives, 521if (!directives.Any(static d => d is CSharpDirective.Ref)) 529foreach (var refDirective in directives.OfType<CSharpDirective.Ref>()) 554ImmutableArray<CSharpDirective> directives, 559foreach (var directive in directives) 561if (directive is CSharpDirective.Ref) 563await CheckFlagEnabledAsync(refEnabled, CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective, directive).ConfigureAwait(false); 567async ValueTask CheckFlagEnabledAsync(StrongBox<bool?> flag, string flagName, CSharpDirective directive) 584ImmutableArray<CSharpDirective> directives, 597var sdkDirectives = directives.OfType<CSharpDirective.Sdk>(); 598var propertyDirectives = directives.OfType<CSharpDirective.Property>(); 599var packageDirectives = directives.OfType<CSharpDirective.Package>(); 600var projectDirectives = directives.OfType<CSharpDirective.Project>(); 601var refDirectives = directives.OfType<CSharpDirective.Ref>(); 602var includeOrExcludeDirectives = directives.OfType<CSharpDirective.IncludeOrExclude>().ToArray(); 640<FileBasedProgramsItemMapping>{CSharpDirective.IncludeOrExclude.DefaultMappingString}</FileBasedProgramsItemMapping> 816if (includeOrExclude.Kind == CSharpDirective.IncludeOrExcludeKind.Include) 919Debug.Assert(processedDirectives + directives.OfType<CSharpDirective.Shebang>().Count() == directives.Length); 969static void WriteImport(TextWriter writer, string project, CSharpDirective.Sdk sdk)