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