Skip to content

Commit 9b1179f

Browse files
Update docs, fix MacOSX GitLFS submodule issue
1 parent 44b229c commit 9b1179f

File tree

3 files changed

+9
-128
lines changed

3 files changed

+9
-128
lines changed

README.md

Lines changed: 9 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This repository contains:
1717
- Configuration and guidelines for automated linting of C# projects.
1818
- Standardized internal C# utility classes to be reused across SixLabors projects (like `Guard`, `MathF`, and `HashCode`)
1919
- `SixLabors.snk` to support strong-name signing of SixLabors assemblies
20-
- Centralized msbuild configuration and utilities for SixLabors projects (*Coming soon*)
20+
- Centralized msbuild configuration and utilities for SixLabors projects
2121

2222
It is designed to be installed as a [git submodule](https://blog.github.com/2016-02-01-working-with-submodules/) into Six Labors solutions.
2323

@@ -79,135 +79,16 @@ git submodule update --init --recursive
7979
git submodule foreach git pull origin master
8080
```
8181

82-
### Wiring up the Linting Tools
82+
### Linting Tools
8383

84-
There are three tools contained within the submodule that will help to automatically promote and enforce coding standards and consistancy:
84+
There are three tools contained within the submodule that will help to automatically promote and enforce coding standards and consistency:
8585
- [.gitattributes](https://git-scm.com/docs/gitattributes)
8686
- [.editorconfig](https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2017)
87-
- [StyleCop Analyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers)
88-
89-
### Gitattributes
90-
`.gitattributes` files are used to do things like specify separate merge strategies for individual files or directories in your project, tell Git how to diff non-text files, or have Git filter content before you check it into or out of Git. The default attributes are configured to safely allow cross platform development.
91-
92-
>**Note: `.gitattributes` relies on a [physical file path hierarchy](https://git-scm.com/docs/gitattributes) to work so after installing or updating the submodule you need to copy the `.gitattributes` file to the solution root before adding to Visual Studio.**
93-
94-
#### EditorConfig
95-
96-
Settings in `.editorconfig` files enable you to maintain consistent coding styles and settings in a codebase, such as indent style, tab width, end of line characters, encoding, and more, regardless of the editor or IDE you use. For example, when coding in C#, if your codebase has a convention to prefer that indents always consist of five space characters, documents use UTF-8 encoding, and each line always ends with a CR/LF, you can configure an `.editorconfig` file to do that.
97-
98-
Adding an `.editorconfig` file to your project or codebase does not convert existing styles to the new ones. For example, if you have indents in your file that are formatted with tabs, and you add an `.editorconfig` file that indents with spaces, the indent characters are not automatically converted to spaces. However, any new lines of code are formatted according to the `.editorconfig` file. Additionally, if you format the document using <kbd>Ctrl+K, Ctrl+E</kbd>), the settings in the `.editorconfig` file are applied to existing lines of code.
99-
100-
>**Note: `.editorconfig` relies on a [physical file path hierarchy](https://editorconfig.org/#file-location) to work so after installing or updating the submodule you need to copy the `.editorconfig` file to the solution root before adding to Visual Studio.**
101-
102-
To add an `.editorconfig` file to your solution open the solution in Visual Studio. Select the solution node and right-click.
103-
104-
From the menu bar, choose **Project > Add Existing Item**, or press <kbd>Shift+Alt+A</kbd>.
105-
106-
The Add Existing Item dialog box opens. Use this to navigate to your new **shared-infrastructure** folder and select the `.editorconfig` file.
107-
108-
An `.editorconfig` file appears in Solution Explorer, and it opens in the editor.
109-
110-
![EditorConfig file in solution explorer.](images/editorconfig-in-solution-explorer.png)
111-
112-
#### StyleCop Analyzers
113-
114-
StyleCop Analyzers are Roslyn Analyzer that contain an implementation of the StyleCop rules using the .NET Compiler Platform. Where possible, code fixes are also provided to simplify the process of correcting violations.
115-
116-
StyleCopAnalyzers can be installed using the NuGet command line or the NuGet Package Manager in Visual Studio 2019.
117-
118-
Install using the command line:
119-
120-
``` bash
121-
Install-Package StyleCop.Analyzers
122-
```
123-
124-
Installing via the package manager:
125-
126-
![stylecop analyzers-via-nuget](images/stylecop-analyzers-via-nuget.png)
127-
128-
Once the Nuget package is installed you will should add the following configuration files to the **Solution Items** folder you created when installing the `.editorconfig` file so you can easily view the contents.
129-
130-
- `SixLabors.ruleset`
131-
- `SixLabors.Tests.ruleset`
132-
- `stylecop.json`
133-
134-
These files tell StyleCop what rules to enforce and will have to be manually added to each project. **right-click > Edit [YOUR_PROJECT_NAME].csproj**
135-
136-
``` xml
137-
<!--Use the 'SixLabors.Tests.ruleset' for your test projects-->
138-
<PropertyGroup>
139-
<CodeAnalysisRuleSet>..\..\shared-infrastructure\SixLabors.ruleset</CodeAnalysisRuleSet>
140-
</PropertyGroup>
141-
142-
<ItemGroup>
143-
<AdditionalFiles Include="..\..\shared-infrastructure\stylecop.json" />
144-
</ItemGroup>
145-
```
146-
147-
An up-to-date list of which StyleCop rules are implemented and which have code fixes can be found [here](https://dotnetanalyzers.github.io/StyleCopAnalyzers/).
148-
149-
### Using internal C# utility classes
150-
151-
To include internals like `Guard.cs`, `MathF`, and `HashCode` into your project you should add configuration like the following to your `.csproj`:
152-
153-
``` xml
154-
<!--
155-
https://apisof.net/
156-
+===================+=======+==========+=====================+=============+=================+====================+==============+=========+============|
157-
| SUPPORTS | MATHF | HASHCODE | EXTENDED_INTRINSICS | SPAN_STREAM | ENCODING_STRING | RUNTIME_INTRINSICS | CODECOVERAGE | HOTPATH | CREATESPAN |
158-
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
159-
| >=netcoreapp3.1 | Y | Y | Y | Y | Y | Y | Y | Y | Y |
160-
| netcoreapp2.1 | Y | Y | Y | Y | Y | N | Y | N | Y |
161-
| netcoreapp2.0 | Y | N | N | N | N | N | Y | N | Y |
162-
| netstandard2.1 | Y | Y | N | Y | Y | N | Y | N | Y |
163-
| netstandard2.0 | N | N | N | N | N | N | Y | N | N |
164-
| netstandard1.3 | N | N | N | N | N | N | N | N | N |
165-
| net472 | N | N | Y | N | N | N | Y | N | N |
166-
+===================+=======+==========+=====================+=============+=================+====================+==============+=========|============|
167-
-->
168-
169-
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','netcoreapp3.1'))">
170-
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
171-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
172-
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
173-
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
174-
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
175-
<DefineConstants>$(DefineConstants);SUPPORTS_RUNTIME_INTRINSICS</DefineConstants>
176-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
177-
<DefineConstants>$(DefineConstants);SUPPORTS_HOTPATH</DefineConstants>
178-
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
179-
</PropertyGroup>
180-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
181-
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
182-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
183-
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
184-
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
185-
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
186-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
187-
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
188-
</PropertyGroup>
189-
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.0'">
190-
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
191-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
192-
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
193-
</PropertyGroup>
194-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
195-
<DefineConstants>$(DefineConstants);SUPPORTS_MATHF</DefineConstants>
196-
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
197-
<DefineConstants>$(DefineConstants);SUPPORTS_SPAN_STREAM</DefineConstants>
198-
<DefineConstants>$(DefineConstants);SUPPORTS_ENCODING_STRING</DefineConstants>
199-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
200-
<DefineConstants>$(DefineConstants);SUPPORTS_CREATESPAN</DefineConstants>
201-
</PropertyGroup>
202-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
203-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
204-
</PropertyGroup>
205-
<PropertyGroup Condition="'$(TargetFramework)' == 'net472'">
206-
<DefineConstants>$(DefineConstants);SUPPORTS_EXTENDED_INTRINSICS</DefineConstants>
207-
<DefineConstants>$(DefineConstants);SUPPORTS_CODECOVERAGE</DefineConstants>
208-
</PropertyGroup>
209-
```
87+
- [StyleCop Analyzers](https://github.com/DotNetAnalyzers/StyleCopAnalyzers)
88+
89+
These tools are automatically installed into your solution by referencing the `.props` and `.targets` files found in the [/msbuild](/msbuild) folder.
21090

211-
And add the `SharedInfrastructure.shproj` as a project dependency.
91+
### MsBuild
92+
93+
Within the aforementioned folder there are separate `.props` and `.targets` files designed for shared, src, and test scenarios. These files control the build process and are responsible for automatically referencing all the required projects for versioning, linting and testing. An example use case and installation can be found at the [ImageSharp](https://github.com/SixLabors/ImageSharp) repository.
21294

213-
*Note:* This might change as soon as we include shared msbuild infrastructure elements (`.props` and `.targets`)
-7.58 KB
Binary file not shown.
-69.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)