2 types derived from CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (2)
830public sealed class Shebang(in ParseInfo info) : CSharpDirective(info) 835public 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) 1458private Dictionary<CSharpDirective.Named, CSharpDirective.Named>? _seen; 1464public void CheckDirective(CSharpDirective.Named directive, ErrorReporter reportError, out bool shouldKeep) 1466if (directive is CSharpDirective.Project or CSharpDirective.Ref or CSharpDirective.IncludeOrExclude) 1497private static bool HasSameValue(CSharpDirective.Named existingDirective, CSharpDirective.Named directive) 1500Debug.Assert(existingDirective is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1501Debug.Assert(directive is CSharpDirective.Sdk or CSharpDirective.Property or CSharpDirective.Package); 1505(CSharpDirective.Sdk existing, CSharpDirective.Sdk current) => 1507(CSharpDirective.Property existing, CSharpDirective.Property current) => 1509(CSharpDirective.Package existing, CSharpDirective.Package current) => 1529if (!CSharpDirective.MetadataNameComparer.Equals(existing.Name, current.Name) || 1530!CSharpDirective.MetadataValueComparer.Equals(existing.Value, current.Value)) 1543internal sealed class NamedDirectiveComparer : IEqualityComparer<CSharpDirective.Named> 1549public bool Equals(CSharpDirective.Named? x, CSharpDirective.Named? y) 1559public int GetHashCode(CSharpDirective.Named obj)
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (48)
45private (ImmutableArray<CSharpDirective> Original, ImmutableArray<CSharpDirective> Evaluated)? _evaluatedDirectives; 151return directives.OfType<CSharpDirective.Property>() 223/// <c>#:include</c>/<c>#:exclude</c> have their <see cref="CSharpDirective.IncludeOrExclude.ItemType"/> determined 226private async ValueTask<ImmutableArray<CSharpDirective>> EvaluateDirectivesAsync( 228ImmutableArray<CSharpDirective> directives, 231if (!directives.Any(static d => d is CSharpDirective.Project or CSharpDirective.IncludeOrExclude or CSharpDirective.Ref)) 236var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 240foreach (var directive in directives) 244case CSharpDirective.Project projectDirective: 245projectDirective = projectDirective.WithName(await project.ExpandStringAsync(projectDirective.Name).ConfigureAwait(false), CSharpDirective.Project.NameKind.Expanded); 251case CSharpDirective.Ref refDirective: 252refDirective = refDirective.WithName(await project.ExpandStringAsync(refDirective.Name).ConfigureAwait(false), CSharpDirective.Ref.NameKind.Expanded); 258case CSharpDirective.IncludeOrExclude includeOrExcludeDirective: 284return CSharpDirective.IncludeOrExclude.ParseMapping( 285await project.GetPropertyValueAsync(CSharpDirective.IncludeOrExclude.MappingPropertyName).ConfigureAwait(false), 309ImmutableArray<CSharpDirective> evaluatedDirectives) 313public ImmutableArray<CSharpDirective> EvaluatedDirectives { get; } = evaluatedDirectives; 319ImmutableArray<CSharpDirective> directives = default, 326ImmutableArray<CSharpDirective> evaluatedDirectives; 354var evaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(); 372var deduplicatedFileEvaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<CSharpDirective>(fileEvaluatedDirectives.Length); 373foreach (var directive in fileEvaluatedDirectives) 375if (directive is CSharpDirective.Sdk) 381if (directive is CSharpDirective.Named named) 446ImmutableArray<CSharpDirective> DeduplicateSdkDirectives(ImmutableArray<CSharpDirective> directives) 448if (!directives.Any(static directive => directive is CSharpDirective.Sdk)) 453var builder = ImmutableArray.CreateBuilder<CSharpDirective>(directives.Length); 456foreach (var directive in directives) 458if (directive is CSharpDirective.Sdk sdk) 481ImmutableArray<CSharpDirective> directives, 543ImmutableArray<CSharpDirective> directives, 548if (!directives.Any(static d => d is CSharpDirective.Ref)) 556foreach (var refDirective in directives.OfType<CSharpDirective.Ref>()) 581ImmutableArray<CSharpDirective> directives, 595var sdkDirectives = directives.OfType<CSharpDirective.Sdk>(); 596var propertyDirectives = directives.OfType<CSharpDirective.Property>(); 597var packageDirectives = directives.OfType<CSharpDirective.Package>(); 598var projectDirectives = directives.OfType<CSharpDirective.Project>(); 599var refDirectives = directives.OfType<CSharpDirective.Ref>(); 600var includeOrExcludeDirectives = directives.OfType<CSharpDirective.IncludeOrExclude>().ToArray(); 653<FileBasedProgramsItemMapping>{CSharpDirective.IncludeOrExclude.DefaultMappingString}</FileBasedProgramsItemMapping> 829if (includeOrExclude.Kind == CSharpDirective.IncludeOrExcludeKind.Include) 925Debug.Assert(processedDirectives + directives.OfType<CSharpDirective.Shebang>().Count() == directives.Length); 997static void WriteImport(TextWriter writer, string project, CSharpDirective.Sdk sdk)