2 types derived from CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (2)
371
public sealed class Shebang(in ParseInfo info) :
CSharpDirective
(info)
376
public abstract class Named(in ParseInfo info) :
CSharpDirective
(info)
85 references to CSharpDirective
Microsoft.CodeAnalysis.CSharp.Workspaces (85)
SyncedSource\FileBasedPrograms\FileLevelDirectiveHelpers.cs (32)
38
public static ImmutableArray<
CSharpDirective
> FindDirectives(SourceFile sourceFile, bool reportAllErrors, ErrorReporter errorReporter, bool checkDuplicates = true)
40
var builder = ImmutableArray.CreateBuilder<
CSharpDirective
>();
88
ImmutableArray<
CSharpDirective
>.Builder? builder,
115
var info = new
CSharpDirective
.ParseInfo
122
builder?.Add(new
CSharpDirective
.Shebang(info));
137
var context = new
CSharpDirective
.ParseContext
157
if (
CSharpDirective
.Parse(context) is { } directive)
274
internal abstract class CSharpDirective(in
CSharpDirective
.ParseInfo info)
885
private Dictionary<
CSharpDirective
.Named,
CSharpDirective
.Named>? _seen;
891
public void CheckDirective(
CSharpDirective
.Named directive, ErrorReporter reportError, out bool shouldKeep)
893
if (directive is
CSharpDirective
.Project or
CSharpDirective
.Ref or
CSharpDirective
.IncludeOrExclude)
924
private static bool HasSameValue(
CSharpDirective
.Named existingDirective,
CSharpDirective
.Named directive)
927
Debug.Assert(existingDirective is
CSharpDirective
.Sdk or
CSharpDirective
.Property or
CSharpDirective
.Package);
928
Debug.Assert(directive is
CSharpDirective
.Sdk or
CSharpDirective
.Property or
CSharpDirective
.Package);
932
(
CSharpDirective
.Sdk existing,
CSharpDirective
.Sdk current) =>
934
(
CSharpDirective
.Property existing,
CSharpDirective
.Property current) =>
936
(
CSharpDirective
.Package existing,
CSharpDirective
.Package current) =>
946
internal sealed class NamedDirectiveComparer : IEqualityComparer<
CSharpDirective
.Named>
952
public bool Equals(
CSharpDirective
.Named? x,
CSharpDirective
.Named? y)
962
public int GetHashCode(
CSharpDirective
.Named obj)
SyncedSource\FileBasedPrograms\VirtualProjectBuilder.cs (53)
40
private (ImmutableArray<
CSharpDirective
> Original, ImmutableArray<
CSharpDirective
> Evaluated)? _evaluatedDirectives;
144
return directives.OfType<
CSharpDirective
.Property>()
210
/// <c>#:include</c>/<c>#:exclude</c> have their <see cref="
CSharpDirective
.IncludeOrExclude.ItemType"/> determined
213
private async ValueTask<ImmutableArray<
CSharpDirective
>> EvaluateDirectivesAsync(
215
ImmutableArray<
CSharpDirective
> directives,
218
if (!directives.Any(static d => d is
CSharpDirective
.Project or
CSharpDirective
.IncludeOrExclude or
CSharpDirective
.Ref))
223
var builder = ImmutableArray.CreateBuilder<
CSharpDirective
>(directives.Length);
227
foreach (
var
directive in directives)
231
case
CSharpDirective
.Project projectDirective:
232
projectDirective = projectDirective.WithName(await project.ExpandStringAsync(projectDirective.Name).ConfigureAwait(false),
CSharpDirective
.Project.NameKind.Expanded);
238
case
CSharpDirective
.Ref refDirective:
239
refDirective = refDirective.WithName(await project.ExpandStringAsync(refDirective.Name).ConfigureAwait(false),
CSharpDirective
.Ref.NameKind.Expanded);
245
case
CSharpDirective
.IncludeOrExclude includeOrExcludeDirective:
271
return
CSharpDirective
.IncludeOrExclude.ParseMapping(
272
await project.GetPropertyValueAsync(
CSharpDirective
.IncludeOrExclude.MappingPropertyName).ConfigureAwait(false),
296
ImmutableArray<
CSharpDirective
> evaluatedDirectives)
300
public ImmutableArray<
CSharpDirective
> EvaluatedDirectives { get; } = evaluatedDirectives;
306
ImmutableArray<
CSharpDirective
> directives = default,
313
ImmutableArray<
CSharpDirective
> evaluatedDirectives;
341
var evaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<
CSharpDirective
>();
359
var deduplicatedFileEvaluatedDirectiveBuilder = ImmutableArray.CreateBuilder<
CSharpDirective
>(fileEvaluatedDirectives.Length);
360
foreach (
var
directive in fileEvaluatedDirectives)
362
if (directive is
CSharpDirective
.Sdk)
368
if (directive is
CSharpDirective
.Named named)
433
ImmutableArray<
CSharpDirective
> DeduplicateSdkDirectives(ImmutableArray<
CSharpDirective
> directives)
435
if (!directives.Any(static directive => directive is
CSharpDirective
.Sdk))
440
var builder = ImmutableArray.CreateBuilder<
CSharpDirective
>(directives.Length);
443
foreach (
var
directive in directives)
445
if (directive is
CSharpDirective
.Sdk sdk)
469
ImmutableArray<
CSharpDirective
> directives,
516
ImmutableArray<
CSharpDirective
> directives,
521
if (!directives.Any(static d => d is
CSharpDirective
.Ref))
529
foreach (var refDirective in directives.OfType<
CSharpDirective
.Ref>())
554
ImmutableArray<
CSharpDirective
> directives,
559
foreach (
var
directive in directives)
561
if (directive is
CSharpDirective
.Ref)
563
await CheckFlagEnabledAsync(refEnabled,
CSharpDirective
.Ref.ExperimentalFileBasedProgramEnableRefDirective, directive).ConfigureAwait(false);
567
async ValueTask CheckFlagEnabledAsync(StrongBox<bool?> flag, string flagName,
CSharpDirective
directive)
584
ImmutableArray<
CSharpDirective
> directives,
597
var sdkDirectives = directives.OfType<
CSharpDirective
.Sdk>();
598
var propertyDirectives = directives.OfType<
CSharpDirective
.Property>();
599
var packageDirectives = directives.OfType<
CSharpDirective
.Package>();
600
var projectDirectives = directives.OfType<
CSharpDirective
.Project>();
601
var refDirectives = directives.OfType<
CSharpDirective
.Ref>();
602
var includeOrExcludeDirectives = directives.OfType<
CSharpDirective
.IncludeOrExclude>().ToArray();
640
<FileBasedProgramsItemMapping>{
CSharpDirective
.IncludeOrExclude.DefaultMappingString}</FileBasedProgramsItemMapping>
816
if (includeOrExclude.Kind ==
CSharpDirective
.IncludeOrExcludeKind.Include)
919
Debug.Assert(processedDirectives + directives.OfType<
CSharpDirective
.Shebang>().Count() == directives.Length);
969
static void WriteImport(TextWriter writer, string project,
CSharpDirective
.Sdk sdk)