2 types derived from CSharpDirective
dotnet (2)
Commands\Run\VirtualProjectBuildingCommand.cs (2)
1755
public sealed class Shebang(in ParseInfo info) :
CSharpDirective
(info)
1760
public abstract class Named(in ParseInfo info) :
CSharpDirective
(info)
78 references to CSharpDirective
dotnet (46)
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)
78
var
directive = directives[i];
79
if (directive is
CSharpDirective
.Package p &&
Commands\Run\FileBasedAppSourceEditor.cs (9)
30
public ImmutableArray<
CSharpDirective
> Directives
79
public void Add(
CSharpDirective
directive)
85
private TextChange DetermineAddChange(
CSharpDirective
directive)
89
if (directive is
CSharpDirective
.Named named &&
90
Directives.OfType<
CSharpDirective
.Named>().FirstOrDefault(d => NamedDirectiveComparer.Instance.Equals(d, named)) is { } toReplace)
97
CSharpDirective
? addAfter = null;
98
foreach (
var
existingDirective in Directives)
214
public void Remove(
CSharpDirective
directive)
222
private static int DetermineTrailingLengthToRemove(
CSharpDirective
directive)
Commands\Run\RunTelemetry.cs (8)
142
public static int CountSdks(ImmutableArray<
CSharpDirective
> directives)
150
var sdkDirectives = directives.OfType<
CSharpDirective
.Sdk>().Count();
160
public static int CountPackageReferences(ImmutableArray<
CSharpDirective
> directives)
168
return directives.OfType<
CSharpDirective
.Package>().Count();
176
public static int CountProjectReferences(ImmutableArray<
CSharpDirective
> directives)
184
return directives.OfType<
CSharpDirective
.Project>().Count();
212
public static int CountAdditionalProperties(ImmutableArray<
CSharpDirective
> directives)
219
return directives.OfType<
CSharpDirective
.Property>().Count();
Commands\Run\VirtualProjectBuildingCommand.cs (25)
166
public ImmutableArray<
CSharpDirective
> Directives
457
if (Directives.Any(static d => d is
CSharpDirective
.Project))
699
.Where(static d => d is not
CSharpDirective
.Shebang)
1137
ImmutableArray<
CSharpDirective
> directives,
1145
var sdkDirectives = directives.OfType<
CSharpDirective
.Sdk>();
1146
var propertyDirectives = directives.OfType<
CSharpDirective
.Property>();
1147
var packageDirectives = directives.OfType<
CSharpDirective
.Package>();
1148
var projectDirectives = directives.OfType<
CSharpDirective
.Project>();
1343
Debug.Assert(processedDirectives + directives.OfType<
CSharpDirective
.Shebang>().Count() == directives.Length);
1390
static void WriteImport(TextWriter writer, string project,
CSharpDirective
.Sdk sdk)
1422
public static ImmutableArray<
CSharpDirective
> FindDirectives(SourceFile sourceFile, bool reportAllErrors, DiagnosticBag diagnostics)
1424
var deduplicated = new HashSet<
CSharpDirective
.Named>(NamedDirectiveComparer.Instance);
1425
var builder = ImmutableArray.CreateBuilder<
CSharpDirective
>();
1451
var info = new
CSharpDirective
.ParseInfo
1457
builder.Add(new
CSharpDirective
.Shebang(info));
1472
var context = new
CSharpDirective
.ParseContext
1485
if (
CSharpDirective
.Parse(context) is { } directive)
1582
public static SourceText? RemoveDirectivesFromFile(ImmutableArray<
CSharpDirective
> directives, SourceText text)
1593
var
directive = directives[i];
1600
public static void RemoveDirectivesFromFile(ImmutableArray<
CSharpDirective
> directives, SourceText text, string filePath)
1689
internal abstract class CSharpDirective(in
CSharpDirective
.ParseInfo info)
1905
internal sealed class NamedDirectiveComparer : IEqualityComparer<
CSharpDirective
.Named>
1911
public bool Equals(
CSharpDirective
.Named? x,
CSharpDirective
.Named? y)
1921
public int GetHashCode(
CSharpDirective
.Named obj)
dotnet.Tests (32)
CommandTests\Run\FileBasedAppSourceEditorTests.cs (19)
27
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
41
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
60
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
80
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
98
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
124
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
160
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
186
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
210
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
233
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
253
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
281
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
312
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
337
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
359
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
385
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
414
(static editor => editor.Add(new
CSharpDirective
.Package(default) { Name = "MyPackage", Version = "1.0.0" }),
443
editor.Remove(editor.Directives.OfType<
CSharpDirective
.Package>().First());
444
editor.Remove(editor.Directives.OfType<
CSharpDirective
.Package>().First());
CommandTests\Run\RunTelemetryTests.cs (13)
71
var directives = ImmutableArray.Create<
CSharpDirective
>(
72
new
CSharpDirective
.Sdk(default) { Name = "Microsoft.NET.Sdk" },
73
new
CSharpDirective
.Sdk(default) { Name = "Microsoft.NET.Sdk.Web", Version = "1.0.0" }
87
var directives = ImmutableArray<
CSharpDirective
>.Empty;
100
var directives = ImmutableArray.Create<
CSharpDirective
>(
101
new
CSharpDirective
.Package(default) { Name = "Newtonsoft.Json", Version = "13.0.1" },
102
new
CSharpDirective
.Package(default) { Name = "Microsoft.Extensions.DependencyInjection" }
116
var directives = ImmutableArray.Create<
CSharpDirective
>(
117
new
CSharpDirective
.Project(default) { Name = "../lib/Library.csproj" },
118
new
CSharpDirective
.Project(default) { Name = "../common/Common.csproj" }
132
var directives = ImmutableArray.Create<
CSharpDirective
>(
133
new
CSharpDirective
.Property(default) { Name = "TargetFramework", Value = "net8.0" },
134
new
CSharpDirective
.Property(default) { Name = "Nullable", Value = "enable" }