Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

I improve @Jaex's idea a little bit. My problem with his solution is the error thrown by the solution explorer. It is not very clean.

So you have a file Client.cs with your class as partial:

public partial class Client {
    // your awesome code comes here
}

In another file ClientKeys.cs with your class as partial, you will add your keys:

public partial class Client {
    private const string SecretKey = "WRITE_HERE_YOUR_API_Key";
}

Now, we won't ask git to ignore this file. Lets commit and push this:

git add ./ClientKeys.cs
git commit -m "Create a safety hideout for my keys"
git push origin master

Finally, we are going to ask him to ignore any update on this file:

git update-index --assume-unchanged ./ClientKeys.cs

Now you can come back to your code and replace WRITE_HERE_YOUR_API_Key with your own private api key. This modification wont be follow by Git, so you can commit/push freely. Your solution explorer will stay warning free.

You can see my use of this implementation here.

source

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.