This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2) | |
{ | |
if (HasElements(list1)) | |
return list1; | |
if (HasElements(list2)) | |
return list2; | |
return null; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IReadOnlyCollection<string> FirstPopulatedList(List<string> list1, List<string> list2) | |
{ | |
if (HasElements(list1)) | |
return list1; | |
if (HasElements(list2)) | |
return list2; | |
return new List<string>(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Uri EnsureTrailingSlash(Uri uri) | |
{ | |
if (uri == null) | |
return null; | |
return new Uri(uri.ToString() + "/"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Uri EnsureTrailingSlash(Uri uri) | |
{ | |
return new Uri(uri.ToString() + "/"); | |
} | |
//OR | |
public static Uri EnsureTrailingSlash(Uri? uri) | |
{ | |
if(uri == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<SearchCodeResult> Search(SearchCodeRequest search) | |
{ | |
foreach (var repo in search.Repos) | |
{ | |
//do search stuff | |
} | |
} | |
class SearchCodeRequest{ | |
public IList<string>? Repos { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var azureServiceTokenProvider = new AzureServiceTokenProvider(); | |
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback)); | |
var secret = await keyVaultClient.GetSecretAsync("https://YOURKEYVAULT.azure.net/secrets/sqlAzure--AdminPassword").ConfigureAwait(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string DbPassword = "MySuperSecretPassword"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AzureServicesAuthConnectionString RunAs=App;AppId=YOURAPPID;TenantId=YOURTENANTID;AppKey=OPTIONALAPPKEY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. Create a file for both classes | |
//2. Replace the IKeyVaultAccessClient with a concrete keyvault implementation | |
//3. Add it to the builder: builder.Add(new ReplaceTokensConfigurationSource(configuration, logger, client)); | |
//4. Add secrets placeholder to the appsetings.json with the following pattern __secret__ | |
/// <summary> | |
/// A JSON configuration source that replaces values from JSON that are tokenized with a value from Azure Key Vault, | |
/// using the tokenized value as lookup key. | |
/// </summary> | |
public sealed class ReplaceTokensConfigurationProvider : ConfigurationProvider, IDisposable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using Microsoft.FSharp.Collections; | |
using Microsoft.FSharp.Core; | |
using NuKeeper.Abstractions.Inspections.Files; | |
using Paket; | |
namespace NuKeeper.Inspection.RepositoryInspection | |
{ |