2 types derived from CSharpDirective
dotnet (2)
FileLevelDirectiveHelpers.cs (2)
355
public sealed class Shebang(in ParseInfo info) :
CSharpDirective
(info)
360
public abstract class Named(in ParseInfo info) :
CSharpDirective
(info)
88 references to CSharpDirective
dotnet (54)
Commands\Package\Add\PackageAddCommand.cs (2)
256
editor.Add(new
CSharpDirective
.Package(default) { Name = _packageId.Id, Version = version });
268
editor.Add(new
CSharpDirective
.Package(default) { Name = _packageId.Id, Version = value });
Commands\Package\Remove\PackageRemoveCommand.cs (2)
79
var
directive = directives[i];
80
if (directive is
CSharpDirective
.Package p &&
Commands\Project\Convert\ProjectConvertCommand.cs (5)
168
ImmutableArray<
CSharpDirective
> UpdateDirectives(ImmutableArray<
CSharpDirective
> directives)
170
var result = ImmutableArray.CreateBuilder<
CSharpDirective
>(directives.Length);
172
foreach (
var
directive in directives)
175
if (directive is
CSharpDirective
.Project project &&
Commands\Run\FileBasedAppSourceEditor.cs (10)
31
public ImmutableArray<
CSharpDirective
> Directives
80
public void Add(
CSharpDirective
directive)
86
private TextChange DetermineAddChange(
CSharpDirective
directive)
90
var named = directive as
CSharpDirective
.Named;
92
Directives.OfType<
CSharpDirective
.Named>().FirstOrDefault(d => NamedDirectiveComparer.Instance.Equals(d, named)) is { } toReplace)
99
CSharpDirective
? addAfter = null;
100
foreach (
var
existingDirective in Directives)
106
existingDirective is
CSharpDirective
.Named existingNamed &&
229
public void Remove(
CSharpDirective
directive)
237
private static int DetermineTrailingLengthToRemove(
CSharpDirective
directive)
Commands\Run\RunTelemetry.cs (8)
147
public static int CountSdks(ImmutableArray<
CSharpDirective
> directives)
155
var sdkDirectives = directives.OfType<
CSharpDirective
.Sdk>().Count();
165
public static int CountPackageReferences(ImmutableArray<
CSharpDirective
> directives)
173
return directives.OfType<
CSharpDirective
.Package>().Count();
181
public static int CountProjectReferences(ImmutableArray<
CSharpDirective
> directives)
189
return directives.OfType<
CSharpDirective
.Project>().Count();
217
public static int CountAdditionalProperties(ImmutableArray<
CSharpDirective
> directives)
224
return directives.OfType<
CSharpDirective
.Property>().Count();
Commands\Run\VirtualProjectBuildingCommand.cs (13)
168
public ImmutableArray<
CSharpDirective
> Directives
462
if (Directives.Any(static d => d is
CSharpDirective
.Project))
704
.Where(static d => d is not
CSharpDirective
.Shebang)
1142
ImmutableArray<
CSharpDirective
> directives,
1155
var sdkDirectives = directives.OfType<
CSharpDirective
.Sdk>();
1156
var propertyDirectives = directives.OfType<
CSharpDirective
.Property>();
1157
var packageDirectives = directives.OfType<
CSharpDirective
.Package>();
1158
var projectDirectives = directives.OfType<
CSharpDirective
.Project>();
1384
Debug.Assert(processedDirectives + directives.OfType<
CSharpDirective
.Shebang>().Count() == directives.Length);
1431
static void WriteImport(TextWriter writer, string project,
CSharpDirective
.Sdk sdk)
1448
public static SourceText? RemoveDirectivesFromFile(ImmutableArray<
CSharpDirective
> directives, SourceText text)
1459
var
directive = directives[i];
1466
public static void RemoveDirectivesFromFile(ImmutableArray<
CSharpDirective
> directives, SourceText text, string filePath)
FileLevelDirectiveHelpers.cs (14)
43
public static ImmutableArray<
CSharpDirective
> FindDirectives(SourceFile sourceFile, bool reportAllErrors, DiagnosticBag diagnostics)
45
var builder = ImmutableArray.CreateBuilder<
CSharpDirective
>();
94
ImmutableArray<
CSharpDirective
>.Builder? builder)
98
var deduplicated = new Dictionary<
CSharpDirective
.Named,
CSharpDirective
.Named>(NamedDirectiveComparer.Instance);
122
var info = new
CSharpDirective
.ParseInfo
128
builder?.Add(new
CSharpDirective
.Shebang(info));
143
var context = new
CSharpDirective
.ParseContext
163
if (
CSharpDirective
.Parse(context) is { } directive)
281
internal abstract class CSharpDirective(in
CSharpDirective
.ParseInfo info)
549
internal sealed class NamedDirectiveComparer : IEqualityComparer<
CSharpDirective
.Named>
555
public bool Equals(
CSharpDirective
.Named? x,
CSharpDirective
.Named? y)
565
public int GetHashCode(
CSharpDirective
.Named obj)
dotnet.Tests (34)
CommandTests\Run\FileBasedAppSourceEditorTests.cs (21)
28
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
42
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
61
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
81
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
99
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
125
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
161
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
187
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
211
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
234
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
254
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
282
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
313
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
338
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
367
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "Test", Version = "1.0.0" }),
399
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
425
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
452
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
481
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
510
editor.Remove(editor.Directives.OfType<
CSharpDirective
.Package>().First());
511
editor.Remove(editor.Directives.OfType<
CSharpDirective
.Package>().First());
CommandTests\Run\RunTelemetryTests.cs (13)
72
var directives = ImmutableArray.Create<
CSharpDirective
>(
73
new
CSharpDirective
.Sdk(default) { Name = "Microsoft.NET.Sdk" },
74
new
CSharpDirective
.Sdk(default) { Name = "Microsoft.NET.Sdk.Web", Version = "1.0.0" }
88
var directives = ImmutableArray<
CSharpDirective
>.Empty;
101
var directives = ImmutableArray.Create<
CSharpDirective
>(
102
new
CSharpDirective
.Package(default) { Name = "Newtonsoft.Json", Version = "13.0.1" },
103
new
CSharpDirective
.Package(default) { Name = "Microsoft.Extensions.DependencyInjection" }
117
var directives = ImmutableArray.Create<
CSharpDirective
>(
118
new
CSharpDirective
.Project(default) { Name = "../lib/Library.csproj" },
119
new
CSharpDirective
.Project(default) { Name = "../common/Common.csproj" }
133
var directives = ImmutableArray.Create<
CSharpDirective
>(
134
new
CSharpDirective
.Property(default) { Name = "TargetFramework", Value = "net8.0" },
135
new
CSharpDirective
.Property(default) { Name = "Nullable", Value = "enable" }