60 instantiations of ConfigSource
aspire (4)
Configuration\ConfigSourceService.cs (4)
164var source = new ConfigSource 246var binding = new ConfigSource 445var identity = new ConfigSource 537var identity = new ConfigSource
Aspire.Cli.Tests (56)
Backchannel\AppHostConnectionResolverTests.cs (1)
27await TestConfigSourceServices.SaveBindingAsync(new ConfigSource
Commands\AgentInitCommandTests.cs (1)
265new ConfigSource { Repository = "https://git.example/configuration", Path = "aspire.config.json", AppliedVersion = "version-1" },
Commands\ConfigSourceCommandTests.cs (7)
27private static readonly ConfigSource s_source = new() 303await TestConfigSourceServices.SaveBindingAsync(new() 489new ConfigSource { Repository = "https://parent.example/configuration", Path = "parent.json", AppliedVersion = "parent-version" }, 570var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 657var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 697var selectedSource = new ConfigSource 899await TestConfigSourceServices.SaveBindingAsync(new ConfigSource
Configuration\ConfigSourceServiceGitTests.cs (18)
49var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 90var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 143var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 170await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 384var source = new ConfigSource { Repository = workspace.Path, Path = path }; 408var source = new ConfigSource { Repository = repository.FullName, Path = path }; 436var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 468new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, 499new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, workspace.CreateDirectory("cache").FullName, TestContext.Current.CancellationToken)); 509new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, workspace.CreateDirectory("cache").FullName, TestContext.Current.CancellationToken)); 523var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 554new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = reference }, 572new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = expectedCommit }, 584var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 604var pinned = await client.CheckAsync(new() { Repository = source.Repository, Path = source.Path, Ref = original.Commit }, 630new() { Repository = workspace.Path, Path = AspireConfigFile.FileName, Ref = reference }, 651new() { Repository = workspace.Path, Path = AspireConfigFile.FileName }, workspace.CreateDirectory("cache").FullName, TestContext.Current.CancellationToken)); 671var source = new ConfigSource
Configuration\ConfigSourceServiceTests.cs (27)
46await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 137var globalSource = new ConfigSource 144var ignoredSource = new ConfigSource { Repository = s_appliedSource.Repository, Path = "ignored.json", AppliedVersion = "ignored-version" }; 254await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 339await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 502private static readonly ConfigSource s_source = new() 507private static readonly ConfigSource s_appliedSource = new() 578var source = new ConfigSource 596new ConfigSource { Repository = repository, Path = s_source.Path }.Validate(); 605new ConfigSource { Repository = repository.FullName, Path = s_source.Path }.Validate(); 624Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = repository, Path = s_source.Path }.Validate()); 633Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = repository, Path = s_source.Path }.Validate()); 647Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = s_source.Repository, Path = path }.Validate()); 659new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = reference }.Validate(); 678Assert.Throws<ConfigSourceException>(() => new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = reference }.Validate()).Message); 689var expected = new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" }; 723Assert.Equivalent(detected ? new ConfigSource { Repository = ConfigSourceService.MicrosoftRepository, Path = AspireConfigFile.FileName } : null, 785Assert.Equivalent(accepted ? new ConfigSource { Repository = ConfigSourceService.MicrosoftRepository, Path = AspireConfigFile.FileName } : null, 1041await TestConfigSourceServices.SaveBindingAsync(new ConfigSource 1084new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, AppliedVersion = "version-2" }, 1181await TestConfigSourceServices.SaveBindingAsync(new() 1295var changed = new ConfigSource 1439var invalid = new ConfigSource { Repository = repository, Path = s_source.Path, Ref = gitRef, AppliedVersion = "version-1" }; 1585service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = "other.json" })); 1587service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" })); 1589service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" }), 1590service.GetCacheDirectory(new() { Repository = s_source.Repository, Path = s_source.Path, Ref = "main" }));
TestServices\TestConfigSourceServices.cs (2)
55await SaveBindingAsync(new ConfigSource 116var source = new ConfigSource
85 references to ConfigSource
aspire (38)
Commands\InitCommand.cs (1)
162var configSource = await ConfigSources.SelectForInitializationAsync(configurationDirectory, parseResult, cancellationToken);
Commands\NewCommand.cs (3)
528var configSource = await ConfigSources.ResolveAndAcquireConfigSourceAsync(parseResult, cancellationToken); 647private async Task<CommandResult> CreateFromSourceAsync(TemplateSource source, ConfigSource? configSource, ParseResult parseResult, CancellationToken cancellationToken) 685private async Task<CommandResult> CompleteTemplateAsync(TemplateResult templateResult, ConfigSource? configSource, ParseResult parseResult, CancellationToken cancellationToken)
Configuration\AspireConfigFile.cs (2)
65[JsonPropertyName(ConfigSource.SectionName)] 68public ConfigSource? ConfigSource { get; set; }
Configuration\ConfigSource.cs (4)
38public static bool HasSameIdentity(ConfigSource first, ConfigSource second) 103internal sealed record ConfigSourceMetadata(ConfigSource Source, string Commit, string Version, DateTimeOffset FetchedAt); 106ConfigSource Source, string Commit, string Version, DateTimeOffset CheckedAt, string[]? ComparedAppliedVersions);
Configuration\ConfigSourceService.cs (27)
145public async Task<ConfigSource?> ResolveAndAcquireConfigSourceAsync(ParseResult parseResult, CancellationToken cancellationToken) 164var source = new ConfigSource 200public async Task<ConfigSource?> SelectForInitializationAsync( 206if (configuration is not null && TryGetValue(configuration, [ConfigSource.SectionName], out _)) 215public async Task MaterializeAsync(ConfigSource source, DirectoryInfo projectDirectory, CancellationToken cancellationToken) 222private async Task ApplySnapshotAsync(ConfigSource source, ConfigSourceSnapshot snapshot, string path, CancellationToken cancellationToken) 233if (ReadBinding(configuration) is { } current && !ConfigSource.HasSameIdentity(current, source)) 246var binding = new ConfigSource 253configuration[GetKey(configuration, ConfigSource.SectionName)] = JsonSerializer.SerializeToNode(binding, JsonSourceGenerationContext.Default.ConfigSource); 302var sources = new List<ConfigSource>(); 313var source = await ReadBindingAsync(configPath, cancellationToken); 366internal async Task<ConfigSource?> ReadBindingAsync(string configPath, CancellationToken cancellationToken) 387private static ConfigSource? ReadBinding(JsonObject? config) 393var sourceProperty = config.FirstOrDefault(p => p.Key.Equals(ConfigSource.SectionName, StringComparison.OrdinalIgnoreCase)); 415internal string GetCacheDirectory(ConfigSource source) 421internal async Task<ConfigSourceSnapshot> AcquireAsync(ConfigSource source, bool force, CancellationToken cancellationToken) 445var identity = new ConfigSource 498private async Task<ConfigSourceCheckMetadata> CheckVersionAsync(IReadOnlyList<ConfigSource> sources, CancellationToken cancellationToken) 500var source = sources[0]; 518if (previous is null || previous.Source is null || !ConfigSource.HasSameIdentity(previous.Source, source) 537var identity = new ConfigSource 555private async Task<(string Commit, string Version, JsonObject Configuration)> AcquireRepositoryAsync(ConfigSource source, string directory, CancellationToken cancellationToken) 575if (configuration.Any(p => p.Key.Equals(ConfigSource.SectionName, StringComparison.OrdinalIgnoreCase) 576|| p.Key.StartsWith(ConfigSource.SectionName + ":", StringComparison.OrdinalIgnoreCase) 577|| p.Key.StartsWith(ConfigSource.SectionName + ".", StringComparison.OrdinalIgnoreCase))) 608private async Task<(string Commit, string Version)> CheckRepositoryAsync(ConfigSource source, string directory, CancellationToken cancellationToken) 631ConfigSource source, string directory, bool allowInteractive, CancellationToken cancellationToken)
JsonSourceGenerationContext.cs (1)
40[JsonSerializable(typeof(ConfigSource))]
Aspire.Cli.Tests (47)
Commands\ConfigSourceCommandTests.cs (11)
27private static readonly ConfigSource s_source = new() 570var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 591Assert.True(ConfigSource.HasSameIdentity(selectedSource, source) || ConfigSource.HasSameIdentity(s_source, source)); 657var selectedSource = new ConfigSource { Repository = s_source.Repository, Path = "selected.json", AppliedVersion = s_source.AppliedVersion }; 665Assert.True(ConfigSource.HasSameIdentity(selectedSource, source)); 697var selectedSource = new ConfigSource 721Assert.True(ConfigSource.HasSameIdentity(selectedSource, source)); 968ConfigSource? checkedSource = null; 1000Assert.True(ConfigSource.HasSameIdentity(s_source, checkedSource)); 1012Assert.True(ConfigSource.HasSameIdentity(s_source, source));
Configuration\ConfigSourceServiceGitTests.cs (10)
49var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 90var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 143var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 168TemporaryWorkspace workspace, IGitClient git, ConfigSource source, TimeProvider clock, CancellationToken token) 384var source = new ConfigSource { Repository = workspace.Path, Path = path }; 408var source = new ConfigSource { Repository = repository.FullName, Path = path }; 436var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 523var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 584var source = new ConfigSource { Repository = workspace.Path, Path = AspireConfigFile.FileName }; 671var source = new ConfigSource
Configuration\ConfigSourceServiceTests.cs (20)
58Assert.True(ConfigSource.HasSameIdentity(s_appliedSource, source)); 63Assert.True(ConfigSource.HasSameIdentity(s_appliedSource, source)); 137var globalSource = new ConfigSource 144var ignoredSource = new ConfigSource { Repository = s_appliedSource.Repository, Path = "ignored.json", AppliedVersion = "ignored-version" }; 159var operations = new ConcurrentQueue<ConfigSource>(); 163async Task RecordAsync(ConfigSource source, CancellationToken token) 213Assert.True(expectedSources.Zip(operations).All(pair => ConfigSource.HasSameIdentity(pair.First, pair.Second))); 267void Record(ConfigSource source) 502private static readonly ConfigSource s_source = new() 507private static readonly ConfigSource s_appliedSource = new() 578var source = new ConfigSource 586Assert.Equal(equal, ConfigSource.HasSameIdentity(s_appliedSource, source)); 587Assert.Equal(equal, ConfigSource.HasSameIdentity(source, s_appliedSource)); 689var expected = new ConfigSource { Repository = s_source.Repository, Path = s_source.Path, Ref = "preview" }; 721var selected = await service.ResolveAndAcquireConfigSourceAsync(ParseConsent(detected ? true : null), CancellationToken.None); 1171Assert.True(ConfigSource.HasSameIdentity(s_appliedSource, second.Metadata.Source)); 1295var changed = new ConfigSource 1425var source = await service.SelectForInitializationAsync(project, ParseConsent(true), CancellationToken.None); 1428Assert.True(ConfigSource.HasSameIdentity(s_source, source)); 1439var invalid = new ConfigSource { Repository = repository, Path = s_source.Path, Ref = gitRef, AppliedVersion = "version-1" };
TestServices\TestConfigSourceServices.cs (6)
19public static async Task SaveBindingAsync(ConfigSource source, DirectoryInfo projectDirectory, CancellationToken cancellationToken) 44this IGitClient git, ConfigSource source, string directory, CancellationToken cancellationToken, TimeProvider? clock = null) 52this IGitClient git, ConfigSource source, string directory, CancellationToken cancellationToken, TimeProvider? clock = null) 96public Func<ConfigSource, CancellationToken, Task<(string Version, JsonObject Configuration)>> ReadConfiguration { get; set; } 98public Func<ConfigSource, CancellationToken, Task<string>> InspectConfiguration { get; set; } 116var source = new ConfigSource