2 types derived from CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (2)
821public sealed class Shebang(in ParseInfo info) : CSharpDirective(info) 826public abstract class Named(in ParseInfo info) : CSharpDirective(info)
87 references to CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (87)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (34)
38public static ImmutableArray<CSharpDirective> FindDirectives(SourceFile sourceFile, bool reportAllErrors, ErrorReporter errorReporter, bool checkDuplicates = true) 40var builder = ImmutableArray.CreateBuilder<CSharpDirective>(); 90ImmutableArray<CSharpDirective>.Builder? builder, 119var info = new CSharpDirective.ParseInfo 126builder?.Add(new CSharpDirective.Shebang(info)); 153var context = new CSharpDirective.ParseContext 169if (CSharpDirective.Parse(context) is { } directive) 323internal abstract class CSharpDirective(in CSharpDirective.ParseInfo info) 1422private Dictionary<CSharpDirective.Named, CSharpDirective.Named>? _seen; 1428public void CheckDirective(CSharpDirective.Named directive, ErrorReporter reportError, out bool shouldKeep) 1430if (directive is CSharpDirective.Project or CSharpDirective.Ref or CSharpDirective.IncludeOrExclude) 1461private static bool HasSameValue(CSharpDirective.Named existingDirective, CSharpDirective.Named directive) 1464Debug.Assert(existingDirective is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1465Debug.Assert(directive is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1469(CSharpDirective.Sdk existing, CSharpDirective.Sdk current) => 1471(CSharpDirective.Property existing, CSharpDirective.Property current) => 1473(CSharpDirective.Package existing, CSharpDirective.Package current) => 1493if (!CSharpDirective.MetadataNameComparer.Equals(existing.Name, current.Name) || 1494!CSharpDirective.MetadataValueComparer.Equals(existing.Value, current.Value)) 1507internal sealed class NamedDirectiveComparer : IEqualityComparer<CSharpDirective.Named> 1513public bool Equals(CSharpDirective.Named? x, CSharpDirective.Named? y) 1523public int GetHashCode(CSharpDirective.Named obj)
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (53)
40private (ImmutableArray<CSharpDirective> Original, ImmutableArray<CSharpDirective> Evaluated)? _evaluatedDirectives; 146return directives.OfType<CSharpDirective.Property>() 218/// <c>#:include</c>/<c>#:exclude</c> have their <see cref="CSharpDirective.IncludeOrExclude.ItemType"/> determined 221private async ValueTask<ImmutableArray<CSharpDirective>> EvaluateDirectivesAsync( 223ImmutableArray<CSharpDirective> directives, 226if (!directives.Any(static d => d is CSharpDirective.Project or CSharpDirective.IncludeOrExclude or CSharpDirective.Ref)) 231var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 235foreach (var directive in directives) 239case CSharpDirective.Project projectDirective: 240projectDirective = projectDirective.WithName(await project.ExpandStringAsync(projectDirective.Name).ConfigureAwait(false), CSharpDirective.Project.NameKind.Expanded); 246case CSharpDirective.Ref refDirective: 247refDirective = refDirective.WithName(await project.ExpandStringAsync(refDirective.Name).ConfigureAwait(false), CSharpDirective.Ref.NameKind.Expanded); 253case CSharpDirective.IncludeOrExclude includeOrExcludeDirective: 279return CSharpDirective.IncludeOrExclude.ParseMapping( 280await project.GetPropertyValueAsync(CSharpDirective.IncludeOrExclude.MappingPropertyName).ConfigureAwait(false), 304ImmutableArray<CSharpDirective> evaluatedDirectives) 308public ImmutableArray<CSharpDirective> EvaluatedDirectives { get; } = evaluatedDirectives; 314ImmutableArray<CSharpDirective> directives = default, 321ImmutableArray<CSharpDirective> evaluatedDirectives; 349var evaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(); 367var deduplicatedFileEvaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(fileEvaluatedDirectives.Length); 368foreach (var directive in fileEvaluatedDirectives) 370if (directive is CSharpDirective.Sdk) 376if (directive is CSharpDirective.Named named) 441ImmutableArray<CSharpDirective> DeduplicateSdkDirectives(ImmutableArray<CSharpDirective> directives) 443if (!directives.Any(static directive => directive is CSharpDirective.Sdk)) 448var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 451foreach (var directive in directives) 453if (directive is CSharpDirective.Sdk sdk) 477ImmutableArray<CSharpDirective> directives, 539ImmutableArray<CSharpDirective> directives, 544if (!directives.Any(static d => d is CSharpDirective.Ref)) 552foreach (var refDirective in directives.OfType<CSharpDirective.Ref>()) 577ImmutableArray<CSharpDirective> directives, 582foreach (var directive in directives) 584if (directive is CSharpDirective.Ref) 586await CheckFlagEnabledAsync(refEnabled, CSharpDirective.Ref.ExperimentalFileBasedProgramEnableRefDirective, directive).ConfigureAwait(false); 590async ValueTask CheckFlagEnabledAsync(StrongBox<bool?> flag, string flagName, CSharpDirective directive) 607ImmutableArray<CSharpDirective> directives, 621var sdkDirectives = directives.OfType<CSharpDirective.Sdk>(); 622var propertyDirectives = directives.OfType<CSharpDirective.Property>(); 623var packageDirectives = directives.OfType<CSharpDirective.Package>(); 624var projectDirectives = directives.OfType<CSharpDirective.Project>(); 625var refDirectives = directives.OfType<CSharpDirective.Ref>(); 626var includeOrExcludeDirectives = directives.OfType<CSharpDirective.IncludeOrExclude>().ToArray(); 679<FileBasedProgramsItemMapping>{CSharpDirective.IncludeOrExclude.DefaultMappingString}</FileBasedProgramsItemMapping> 855if (includeOrExclude.Kind == CSharpDirective.IncludeOrExcludeKind.Include) 948Debug.Assert(processedDirectives + directives.OfType<CSharpDirective.Shebang>().Count() == directives.Length); 1015static void WriteImport(TextWriter writer, string project, CSharpDirective.Sdk sdk)