Skip to content

Commit 5cf98f8

Browse files
committed
Update project settings: normalize line endings, enhance .editorconfig, and add copilot instructions
1 parent bc09688 commit 5cf98f8

File tree

6 files changed

+178
-9
lines changed

6 files changed

+178
-9
lines changed

.editorconfig

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ root = true
66
# All Files
77
[*]
88
charset = utf-8
9-
end_of_line = crlf
10-
insert_final_newline = false
9+
end_of_line = lf
10+
insert_final_newline = true
1111
trim_trailing_whitespace = true
1212
indent_style = space
1313
indent_size = 4
1414

15+
csharp_wrap_parameters_style = chop_if_long
16+
csharp_wrap_before_declaration_lpar = false
17+
csharp_wrap_after_declaration_lpar = true
18+
csharp_wrap_before_declaration_rpar = true
19+
20+
csharp_place_method_attribute_on_same_line = never
21+
csharp_place_constructor_initializer_on_same_line = false
22+
csharp_wrap_before_first_type_parameter_constraint = true
23+
csharp_wrap_multiple_type_parameter_constraints_style = chop_always
24+
1525
# Configuration Files
1626
[*.{json,xml,props,targets,nuspec,resx,ruleset,config,yml}]
1727
indent_size = 2
@@ -23,4 +33,3 @@ trim_trailing_whitespace = false
2333
# Web Files
2434
[*.{htm,html,cshtml,js,ts,css,scss}]
2535
indent_size = 2
26-
insert_final_newline = true

.gitattributes

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Set default behavior to automatically normalize line endings.
33
###############################################################################
44
* text=auto
5+
* text eol=lf
56

67
###############################################################################
78
# Set default behavior for command prompt diff.
@@ -17,7 +18,7 @@
1718
#
1819
# Merging from the command prompt will add diff markers to the files if there
1920
# are conflicts (Merging from VS is not affected by the settings below, in VS
20-
# the diff markers are never inserted). Diff markers may cause the following
21+
# the diff markers are never inserted). Diff markers may cause the following
2122
# file extensions to fail to load in VS. An alternative would be to treat
2223
# these files as binary and thus will always conflict and require user
2324
# intervention with every merge. To do so, just uncomment the entries below
@@ -46,9 +47,9 @@
4647

4748
###############################################################################
4849
# diff behavior for common document formats
49-
#
50+
#
5051
# Convert binary document formats to text before diffing them. This feature
51-
# is only available from the command line. Turn it on by uncommenting the
52+
# is only available from the command line. Turn it on by uncommenting the
5253
# entries below.
5354
###############################################################################
5455
#*.doc diff=astextplain

NCode.ProjectSettings.Scaffold.sln.DotSettings

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderRegionName/@EntryValue">Copyright Preamble</s:String>
33
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">&#xD;
4-
Copyright @ $CURRENT_YEAR$ NCode Group&#xD;
4+
Copyright @ ${CurrentDate.Year} NCode Group&#xD;
55
&#xD;
66
Licensed under the Apache License, Version 2.0 (the "License");&#xD;
77
you may not use this file except in compliance with the License.&#xD;
@@ -16,4 +16,5 @@
1616
limitations under the License.&#xD;
1717
</s:String>
1818
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=NCode/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="NCode"&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="False" ArrangeTypeMemberAccessModifier="False" SortModifiers="False" RemoveRedundantParentheses="False" AddMissingParentheses="False" ArrangeBraces="False" ArrangeAttributes="False" ArrangeArgumentsStyle="False" ArrangeCodeBodyStyle="False" /&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;False&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;XAMLCollapseEmptyTags&gt;False&lt;/XAMLCollapseEmptyTags&gt;&lt;CSEnforceVarKeywordUsageSettings&gt;True&lt;/CSEnforceVarKeywordUsageSettings&gt;&lt;/Profile&gt;</s:String>
19-
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">NCode</s:String></wpf:ResourceDictionary>
19+
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">NCode</s:String>
20+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

NCode.ProjectSettings.Scaffold/NCode.ProjectSettings.Scaffold.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
10+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.102">
1111
<PrivateAssets>all</PrivateAssets>
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Copilot Instructions
2+
3+
## Test Project Conventions
4+
5+
### Unit Test Style
6+
7+
When writing or modifying unit tests in this project:
8+
9+
- **Do NOT use** `// Arrange`, `// Act`, `// Assert` comments in test methods
10+
- Use blank lines to separate the logical sections of a test instead of comments
11+
- Keep tests concise and readable without AAA comment annotations
12+
13+
### Example
14+
15+
```csharp
16+
[Fact]
17+
public void MyMethod_WhenCondition_ExpectedBehavior()
18+
{
19+
var input = "test";
20+
21+
var result = MyMethod(input);
22+
23+
Assert.Equal("expected", result);
24+
}
25+
```
26+
27+
## Code Style Conventions
28+
29+
### Collection Expressions
30+
31+
Use C# 12+ collection expressions instead of traditional array/collection initialization:
32+
33+
```csharp
34+
// Preferred
35+
byte[] data = [1, 2, 3, 4, 5];
36+
List<string> names = ["Alice", "Bob"];
37+
int[] empty = [];
38+
39+
// Avoid
40+
var data = new byte[] { 1, 2, 3, 4, 5 };
41+
var names = new List<string> { "Alice", "Bob" };
42+
var empty = Array.Empty<int>();
43+
```
44+
45+
### Constants for Literals
46+
47+
Use `const` for any literal values of any type instead of `var`:
48+
49+
```csharp
50+
// Preferred
51+
const string expected = "hello";
52+
const int count = 5;
53+
const char separator = ',';
54+
const double rate = 0.15;
55+
56+
// Avoid
57+
var expected = "hello";
58+
var count = 5;
59+
var separator = ',';
60+
var rate = 0.15;
61+
```
62+
63+
### UTF-8 String Literals
64+
65+
Use C# 11+ UTF-8 string literals (`u8` suffix) when working with byte arrays that represent valid UTF-8 text:
66+
67+
```csharp
68+
// Preferred
69+
var bytes = "Hello"u8.ToArray();
70+
var utf8Bytes = "café"u8.ToArray();
71+
var emojiBytes = "😀"u8.ToArray();
72+
73+
// Avoid
74+
byte[] bytes = [72, 101, 108, 108, 111];
75+
byte[] utf8Bytes = [0xC3, 0xA9]; // 'é' in UTF-8
76+
byte[] emojiBytes = [0xF0, 0x9F, 0x98, 0x80]; // 😀 in UTF-8
77+
```
78+
79+
Note: Use explicit byte arrays for invalid UTF-8 sequences or when testing error conditions.
80+
81+
## Code Quality
82+
83+
### ReSharper/IDE Warnings
84+
85+
Always fix ReSharper and IDE warnings/suggestions when modifying code. Common fixes include:
86+
87+
- Use collection expressions where applicable (but cast when needed for generic type inference, e.g., `(byte[])[1, 2, 3]` for `ReadOnlyMemory<T>` parameters)
88+
- Remove redundant type specifications
89+
- Use `const` for compile-time constant values
90+
- Ensure all record struct properties are accessed to avoid "never accessed" warnings
91+
92+
### xUnit Assertion Best Practices
93+
94+
Use the appropriate xUnit assertions for collection sizes instead of `Assert.Equal`:
95+
96+
```csharp
97+
// Preferred
98+
Assert.Empty(collection); // For count == 0
99+
Assert.Single(collection); // For count == 1
100+
101+
// Avoid
102+
Assert.Equal(0, collection.Count);
103+
Assert.Equal(1, collection.Count);
104+
```
105+
106+
For counts greater than 1, `Assert.Equal(expectedCount, collection.Count)` is acceptable.
107+
108+
### Test Organization with Regions
109+
110+
Organize unit tests within a test class using `#region` directives to group tests by the method or property under test:
111+
112+
```csharp
113+
public class MyClassTests
114+
{
115+
#region Constructor Tests
116+
117+
[Fact]
118+
public void Constructor_WithValidInput_CreatesInstance()
119+
{
120+
// test code
121+
}
122+
123+
[Fact]
124+
public void Constructor_WithNullInput_ThrowsException()
125+
{
126+
// test code
127+
}
128+
129+
#endregion
130+
131+
#region MyMethod Tests
132+
133+
[Fact]
134+
public void MyMethod_WhenCondition_ExpectedBehavior()
135+
{
136+
// test code
137+
}
138+
139+
#endregion
140+
141+
#region MyProperty Tests
142+
143+
[Fact]
144+
public void MyProperty_ReturnsExpectedValue()
145+
{
146+
// test code
147+
}
148+
149+
#endregion
150+
}
151+
```
152+
153+
Region naming conventions:
154+
- Use `Constructor Tests` for constructor tests
155+
- Use `{MethodName} Tests` for method tests (e.g., `Dispose Tests`)
156+
- Use `{PropertyName} Property Tests` for property tests (e.g., `Span Property Tests`)
157+
- Use `Generic Type Tests` for tests verifying generic type parameter behavior

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ Contains common settings, scripts, and files to scaffold C# projects for NCodeGr
2424
* v1.0.11 - Added setting for ContinuousIntegrationBuild
2525
* v1.0.12 - Removed setting for PackageProjectUrl
2626
* v1.0.13 - Moving CI build from appveyor to github actions
27+
* v1.0.14 - LF line endings and copilot settings

0 commit comments

Comments
 (0)