-
Notifications
You must be signed in to change notification settings - Fork 5
Calculate closures correctly #309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamhathcock
wants to merge
15
commits into
dev
Choose a base branch
from
adam/web-3379-c-sdk-needs-to-correctly-calculate-closures
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
06d6d41
Maybe really fixes closures
adamhathcock d4d844d
fornat
adamhathcock 6476762
add ai generated tests
adamhathcock 3cb6304
fix tests
adamhathcock 58e278d
fix tests
adamhathcock e806056
Merge branch 'main' into adam/web-3379-c-sdk-needs-to-correctly-calcu…
adamhathcock c99bbfb
Merge branch 'dev' into adam/web-3379-c-sdk-needs-to-correctly-calcul…
adamhathcock 4d3a28b
added test with correct number of closures?
adamhathcock 32a916c
Merge remote-tracking branch 'origin/adam/web-3379-c-sdk-needs-to-cor…
adamhathcock 89df4d2
Merge remote-tracking branch 'origin/dev' into adam/web-3379-c-sdk-ne…
adamhathcock 448bf2c
closures are self contained. don't increment on attached properties
adamhathcock 670c076
format
adamhathcock 70e7ddb
MergeClosure should reuse if exists, not just set
adamhathcock 653a64a
add not null on a method
adamhathcock 5b92a85
removed ValidateNullOrWhiteSpace
adamhathcock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Coding standards, domain knowledge, and preferences that AI should follow | ||
|
||
## C# Coding Standards | ||
|
||
- Use the csharpier formatter for formatting C# code. | ||
- Use the .editorconfig file for code style settings. | ||
- Always use `var` when the type is obvious from the right side of the assignment. | ||
- Always add braces for `if`, `else`, `for`, `foreach`, `while`, and `do` statements, even if they are single-line statements. | ||
|
||
## Testing | ||
|
||
- Use xUnit for unit testing. | ||
- Use FluentAssertions for assertions in tests. | ||
- Use Moq for mocking dependencies in tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Git Commit Instructions | ||
|
||
To ensure high-quality and consistent commits, please follow these guidelines: | ||
|
||
1. **Format your code** | ||
- Run the `csharpier` formatter on all C# files before committing. | ||
- Ensure your code adheres to the `.editorconfig` settings. | ||
|
||
2. **Write clear commit messages** | ||
- Use the present tense ("Add feature" not "Added feature"). | ||
- Start with a short summary (max 72 characters), followed by a blank line and a detailed description if necessary. | ||
|
||
3. **Test your changes** | ||
- Run all unit tests before committing. | ||
- Add or update xUnit tests as needed. | ||
- Use FluentAssertions for assertions and Moq for mocking in tests. | ||
|
||
4. **Review your changes** | ||
- Double-check for accidental debug code or commented-out code. | ||
- Ensure only relevant files are staged. | ||
|
||
Thank you for helping maintain code quality! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
namespace Speckle.Sdk.Serialisation.V2.Send; | ||
|
||
public static class ClosureMath | ||
{ | ||
public static void IncrementClosures(this Dictionary<Id, int> current, IEnumerable<KeyValuePair<Id, int>> child) | ||
{ | ||
foreach (var closure in child) | ||
{ | ||
if (current.TryGetValue(closure.Key, out var count)) | ||
{ | ||
current[closure.Key] = Math.Max(closure.Value, count) + 1; | ||
} | ||
else | ||
{ | ||
current[closure.Key] = closure.Value + 1; | ||
} | ||
} | ||
} | ||
|
||
public static void MergeClosures(this Dictionary<Id, int> current, IEnumerable<KeyValuePair<Id, int>> child) | ||
{ | ||
foreach (var closure in child) | ||
{ | ||
if (current.TryGetValue(closure.Key, out var count)) | ||
{ | ||
current[closure.Key] = Math.Max(closure.Value, count); | ||
} | ||
else | ||
{ | ||
current[closure.Key] = closure.Value; | ||
} | ||
} | ||
} | ||
|
||
public static void IncrementClosure(this Dictionary<Id, int> current, Id id) | ||
{ | ||
if (current.TryGetValue(id, out var count)) | ||
{ | ||
current[id] = count + 1; | ||
} | ||
else | ||
{ | ||
current[id] = 1; | ||
} | ||
} | ||
|
||
public static void MergeClosure(this Dictionary<Id, int> current, Id id) | ||
{ | ||
if (current.TryGetValue(id, out var count)) | ||
{ | ||
current[id] = count; | ||
} | ||
else | ||
{ | ||
current[id] = 1; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.