Skip to content

Instantly share code, notes, and snippets.

@natemcmaster
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natemcmaster/3f1b61cb7bf3bc81ea73 to your computer and use it in GitHub Desktop.
Save natemcmaster/3f1b61cb7bf3bc81ea73 to your computer and use it in GitHub Desktop.
Coding Guidelines

Entity Framework - Coding Guidelines

For contributors.

C# 6.0

We use C# 6.0 features to make our code more readable and refactor friendly.

[NotNull] and Check.NotNull()

Resharper code cleanup

Platform-sensitivity

  • Home: Look for both USERPROFILE (Windows) and HOME (everything else).
  • New line literals: Use Environment.NewLine and not \n or \r\n.
  • @"" line breaks: Use intentionally when line breaks CRLF is unimportant. This captures the code's line break (CRLF or LF) which may vary depending on git settings. This is related to the previous item.
  • File paths: Use Path.Combine or Path.DirectorySeparatorChar when possible. If you must, use a forward-slash because Windows is more forgiving than OS X/Linux.
  • Least common denominator: we prefer APIs that work on .NET Framework, .NET Core, and Mono to using #ifdef for different runtimes

Configuration

  • Don't hard code configuration settings that may need to change for different machines e.g. passwords, IP addresses, or absolute file paths. For example, (localdb)\\MSLocalDB is not guaranteed to exist. Make DB configurable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment