public async Task GenerateAndSaveIfChangedAsync(ContentVersion version, IContentSource contentSource) { if (contentSource is null) { throw new ArgumentNullException(nameof(contentSource)); } var existing = await GetExistingVersionAsync() .ConfigureAwait(false); if (existing?.Version != version?.Version || existing?.ReleaseDate?.ToString(CultureInfo.InvariantCulture) != version?.ReleaseDate?.ToString(CultureInfo.InvariantCulture)) { if (!Directory.Exists(_options.Location)) { Directory.CreateDirectory(_options.Location); } File.WriteAllText(GetFullFileName(), Generate(version, await contentSource.GetAllContentItemsAsync(_options.DefaultCultureCode, null) .ConfigureAwait(false))); } }