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