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