1+ ```` instructions
12# Sharpy.Core
23
34Standard library with Pythonic APIs for .NET. Location: `src/Sharpy.Core/`
@@ -22,22 +23,23 @@ Standard library with Pythonic APIs for .NET. Location: `src/Sharpy.Core/`
2223
2324## Adding a Builtin Function
2425
25- Add to ` partial class Exports ` (split across files):
26- ``` csharp
27- // NewFunction.cs
28- namespace Sharpy .Core ;
29-
30- public static partial class Exports
31- {
32- public static TResult NewFunction <T , TResult >(T input ) => .. .;
33- }
34- ```
26+ 1. **Add to `partial class Exports`** (split across files):
27+ ```csharp
28+ // NewFunction.cs
29+ namespace Sharpy.Core;
3530
36- Then:
37- ``` bash
38- python3 -c " print(new_function(...))" # Verify expected behavior
39- dotnet test --filter " FullyQualifiedName~NewFunctionTests"
40- ```
31+ public static partial class Exports
32+ {
33+ public static TResult NewFunction<T, TResult>(T input) => ...;
34+ }
35+ ```
36+ 2. **Verify expected behavior against Python:**
37+ ```bash
38+ python3 -c "print(new_function(...))"
39+ ```
40+ 3. **Add tests** in `Sharpy.Core.Tests/NewFunctionTests.cs`
41+ 4. **Test against Python** to verify behavior matches
42+ 5. **Document** in language reference if needed
4143
4244## Python-style Indexing Pattern
4345
@@ -73,28 +75,24 @@ dotnet test --filter "FullyQualifiedName~DictTests"
7375```
7476
7577**CRITICAL:** Always verify behavior against `python3 -c "..."` first. Fix bugs, don't change test expectations.
76- ```
77- 3. **Add tests** in `Sharpy.Core.Tests/NewFunctionTests.cs`
78- 4. **Test against Python** to verify behavior matches
79- 5. **Document** in language reference if needed
8078
81- ### Adding a New Collection Method
79+ ## Adding a New Collection Method
8280
83811. **Add method to partial class** (e.g., in `Partial.List/`)
84- 2. **Follow Python semantics** - check Python documentation
82+ 2. **Follow Python semantics** — check Python documentation
85833. **Add comprehensive tests**
86844. **Test edge cases** (empty, single-element, etc.)
87855. **Update documentation** if it's a public API
8886
89- ### Implementing an Operator Protocol
87+ ## Implementing an Operator Protocol
9088
91891. **Define interface** (e.g., `INewOperator.cs`)
92902. **Implement on relevant types**
93913. **Add operator overload** if appropriate
94924. **Test with multiple types**
95935. **Document protocol** in specs
9694
97- ### Fixing a Bug
95+ ## Fixing a Bug
9896
99971. **Write a test that reproduces the bug:**
10098 ```csharp
@@ -114,77 +112,15 @@ dotnet test --filter "FullyQualifiedName~DictTests"
114112
115113## Performance Considerations
116114
117- - ** Minimize allocations** - Reuse collections where possible
118- - ** Use struct for small value types** - ` Index ` , ` Slice `
119- - ** Lazy evaluation** - Use iterators instead of materializing lists
120- - ** Leverage .NET BCL** - Don't reinvent optimized data structures
121-
122- ## Dependencies
123-
124- - ** .NET 9.0/10.0** - BCL and runtime
125- - ** System.Collections.Generic** - Underlying collection types
126- - ** System.Linq** - Query operations
115+ - **Minimize allocations** — Reuse collections where possible
116+ - **Use struct for small value types** — `Index`, `Slice`
117+ - **Lazy evaluation** — Use iterators instead of materializing lists
118+ - **Leverage .NET BCL** — Don't reinvent optimized data structures
127119
128120## Related Documentation
129121
130122- **Main README:** `README.md` (repository root)
131123- **Core Tests Guide:** `.github/instructions/Sharpy.Core.Tests/HOW_TO_CONTRIBUTE.instructions.md`
132- - ** Type System Spec:** ` docs/specs/type_system.md `
133- - ** Builtins Reference:** ` docs/specs/builtins.md `
134-
135- ## Example: Adding a New List Method
136-
137- Let's add ` list.insert_all(index, items) ` to insert multiple items at once:
138-
139- ### 1. Implementation
140- ``` csharp
141- // In Partial.List/List.Mutation.cs
142- public void InsertAll (int index , IEnumerable < T > items )
143- {
144- var actualIndex = index < 0 ? _inner .Count + index : index ;
145- if (actualIndex < 0 ) actualIndex = 0 ;
146- if (actualIndex > _inner .Count ) actualIndex = _inner .Count ;
147-
148- _inner .InsertRange (actualIndex , items );
149- }
150- ```
151-
152- ### 2. Tests
153- ``` csharp
154- // In Sharpy.Core.Tests/Partial.ListTests/ListTests.Mutation.cs
155- [Fact ]
156- public void TestInsertAll_InMiddle ()
157- {
158- var list = new List <int > { 1 , 2 , 5 , 6 };
159- list .InsertAll (2 , new [] { 3 , 4 });
160- Assert .Equal (new [] { 1 , 2 , 3 , 4 , 5 , 6 }, list );
161- }
162-
163- [Fact ]
164- public void TestInsertAll_NegativeIndex ()
165- {
166- var list = new List <int > { 1 , 4 , 5 };
167- list .InsertAll (- 2 , new [] { 2 , 3 });
168- Assert .Equal (new [] { 1 , 2 , 3 , 4 , 5 }, list );
169- }
170-
171- [Fact ]
172- public void TestInsertAll_Empty ()
173- {
174- var list = new List <int > { 1 , 2 };
175- list .InsertAll (1 , Array .Empty <int >());
176- Assert .Equal (new [] { 1 , 2 }, list );
177- }
178- ```
179-
180- ### 3. Verify
181- ``` bash
182- dotnet test --filter " FullyQualifiedName~TestInsertAll"
183- ```
184-
185- ## Getting Help
124+ - **Language Specification:** `docs/language_specification/`
186125
187- - Check Python documentation for expected behavior
188- - Review existing implementations for patterns
189- - Run tests frequently to catch issues early
190- - Consult type system documentation for type-related questions
126+ ````
0 commit comments