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)
82 references to CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (82)
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) 1420private Dictionary<CSharpDirective.Named, CSharpDirective.Named>? _seen; 1426public void CheckDirective(CSharpDirective.Named directive, ErrorReporter reportError, out bool shouldKeep) 1428if (directive is CSharpDirective.Project or CSharpDirective.Ref or CSharpDirective.IncludeOrExclude) 1459private static bool HasSameValue(CSharpDirective.Named existingDirective, CSharpDirective.Named directive) 1462Debug.Assert(existingDirective is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1463Debug.Assert(directive is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1467(CSharpDirective.Sdk existing, CSharpDirective.Sdk current) => 1469(CSharpDirective.Property existing, CSharpDirective.Property current) => 1471(CSharpDirective.Package existing, CSharpDirective.Package current) => 1491if (!CSharpDirective.MetadataNameComparer.Equals(existing.Name, current.Name) || 1492!CSharpDirective.MetadataValueComparer.Equals(existing.Value, current.Value)) 1505internal sealed class NamedDirectiveComparer : IEqualityComparer<CSharpDirective.Named> 1511public bool Equals(CSharpDirective.Named? x, CSharpDirective.Named? y) 1521public int GetHashCode(CSharpDirective.Named obj)
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (48)
39private (ImmutableArray<CSharpDirective> Original, ImmutableArray<CSharpDirective> Evaluated)? _evaluatedDirectives; 145return directives.OfType<CSharpDirective.Property>() 217/// <c>#:include</c>/<c>#:exclude</c> have their <see cref="CSharpDirective.IncludeOrExclude.ItemType"/> determined 220private async ValueTask<ImmutableArray<CSharpDirective>> EvaluateDirectivesAsync( 222ImmutableArray<CSharpDirective> directives, 225if (!directives.Any(static d => d is CSharpDirective.Project or CSharpDirective.IncludeOrExclude or CSharpDirective.Ref)) 230var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 234foreach (var directive in directives) 238case CSharpDirective.Project projectDirective: 239projectDirective = projectDirective.WithName(await project.ExpandStringAsync(projectDirective.Name).ConfigureAwait(false), CSharpDirective.Project.NameKind.Expanded); 245case CSharpDirective.Ref refDirective: 246refDirective = refDirective.WithName(await project.ExpandStringAsync(refDirective.Name).ConfigureAwait(false), CSharpDirective.Ref.NameKind.Expanded); 252case CSharpDirective.IncludeOrExclude includeOrExcludeDirective: 278return CSharpDirective.IncludeOrExclude.ParseMapping( 279await project.GetPropertyValueAsync(CSharpDirective.IncludeOrExclude.MappingPropertyName).ConfigureAwait(false), 303ImmutableArray<CSharpDirective> evaluatedDirectives) 307public ImmutableArray<CSharpDirective> EvaluatedDirectives { get; } = evaluatedDirectives; 313ImmutableArray<CSharpDirective> directives = default, 320ImmutableArray<CSharpDirective> evaluatedDirectives; 348var evaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(); 366var deduplicatedFileEvaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(fileEvaluatedDirectives.Length); 367foreach (var directive in fileEvaluatedDirectives) 369if (directive is CSharpDirective.Sdk) 375if (directive is CSharpDirective.Named named) 440ImmutableArray<CSharpDirective> DeduplicateSdkDirectives(ImmutableArray<CSharpDirective> directives) 442if (!directives.Any(static directive => directive is CSharpDirective.Sdk)) 447var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 450foreach (var directive in directives) 452if (directive is CSharpDirective.Sdk sdk) 475ImmutableArray<CSharpDirective> directives, 537ImmutableArray<CSharpDirective> directives, 542if (!directives.Any(static d => d is CSharpDirective.Ref)) 550foreach (var refDirective in directives.OfType<CSharpDirective.Ref>()) 575ImmutableArray<CSharpDirective> directives, 589var sdkDirectives = directives.OfType<CSharpDirective.Sdk>(); 590var propertyDirectives = directives.OfType<CSharpDirective.Property>(); 591var packageDirectives = directives.OfType<CSharpDirective.Package>(); 592var projectDirectives = directives.OfType<CSharpDirective.Project>(); 593var refDirectives = directives.OfType<CSharpDirective.Ref>(); 594var includeOrExcludeDirectives = directives.OfType<CSharpDirective.IncludeOrExclude>().ToArray(); 647<FileBasedProgramsItemMapping>{CSharpDirective.IncludeOrExclude.DefaultMappingString}</FileBasedProgramsItemMapping> 823if (includeOrExclude.Kind == CSharpDirective.IncludeOrExcludeKind.Include) 916Debug.Assert(processedDirectives + directives.OfType<CSharpDirective.Shebang>().Count() == directives.Length); 983static void WriteImport(TextWriter writer, string project, CSharpDirective.Sdk sdk)