Добавил коллектор для % покрытия тестами#1
Conversation
…Dotnet-Core/test-data-generator into add-coverage-collector
Начал добавлять тесты
…Dotnet-Core/test-data-generator into add-coverage-collector
|
@codex посмотришь еще раз mr после последних коммитов? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var count = faker.Random.Int(2, 5); | ||
| var dictionaryType = typeof(Dictionary<,>).MakeGenericType(keyType!, valueType!); | ||
| var dictionary = (IDictionary)Activator.CreateInstance(dictionaryType)!; | ||
| var dictionary = (IDictionary)CreateEmptyDictionary(type, keyType!, valueType!)!; | ||
|
|
There was a problem hiding this comment.
Casting generated dictionaries to non-generic IDictionary breaks added types
The generator now treats SortedDictionary<,> and ConcurrentDictionary<,> as supported, but the instance created in CreateEmptyDictionary is immediately cast to IDictionary. These concrete types do not implement the non-generic IDictionary interface, so requesting a SortedDictionary<TKey,TValue> or ConcurrentDictionary<TKey,TValue> will throw InvalidCastException at line 29 instead of returning a populated dictionary.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (dictionaryInstance is ConcurrentDictionary<object, object> concurrentDict) | ||
| { | ||
| var key = GenerateKey(keyType!, context); | ||
| if (key is null) | ||
| { | ||
| safety++; | ||
| continue; | ||
| } | ||
|
|
||
| var val = context.Resolve(valueType!); | ||
|
|
||
| if (!dictionary.Contains(key)) | ||
| { | ||
| dictionary.Add(key, val); | ||
| } | ||
|
|
||
| safety++; | ||
| FillConcurrent(concurrentDict, keyType!, valueType!, context, count); | ||
| value = concurrentDict; | ||
| return true; | ||
| } | ||
| else | ||
| { | ||
| var dictionary = (IDictionary)dictionaryInstance; | ||
| FillDictionary(dictionary, keyType!, valueType!, context, count); |
There was a problem hiding this comment.
Avoid casting ConcurrentDictionary to non-generic IDictionary
The new ConcurrentDictionary path never matches real ConcurrentDictionary<TKey,TValue> instances because dictionaryInstance is ConcurrentDictionary<object, object> cannot succeed for closed generics with other type arguments. When the pattern fails, the code falls through to the else branch and casts the concurrent dictionary to IDictionary, which it does not implement, resulting in an InvalidCastException whenever a concurrent dictionary is generated. The detection should use the generic type definition (e.g., typeof(ConcurrentDictionary<,>).IsAssignableFrom(instance.GetType())) or operate through IDictionary<,> instead of the non-generic IDictionary cast.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Codex Review: Didn't find any major issues. Breezy!
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
No description provided.