All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Performed a number of internal refactorings, including a slight performance improvement with
Verify()(issue #408)
- Addressed issue with refactoring to target generic names directly (issue #409)
- Added expectation overloads for
paramsmethods and indexers (issue #268) - Added suppressors for
CA2000andCA2025(issue #396)
outparameters using aref structnow works (issue #407)
- Pushed the final 10.0.0 release
- Updated the generated expectations API (issue #394)
- Removed
DisableVerificationflag fromRockContext(issue #393)
- Fixed generated code for property setter expectation logic (issue #392)
- Made all explicit implementations in shim members cast to the type of the explicit implementation (issue #389 and issue #390)
- Mocks no longer includes
[UnscopedRef](issue #391) - No longer generating
[MemberNotNullWhen]on mock types (issue #395)
- Made
Verify()throw an exception if expectations were set and an instance was never made (issue #382 and issue #367) - Refined symbol search for refactoring (issue #384)
- Added more syntax node support for
AddRockAttributeRefactoring(issue #378) - Added
DisableVerificationflag toRockContextto allow developers to temporarily disable verification (issue #377)
- Changed
Expectationsto not callVerify()if the mock threw a code generated exception (issue #377)
- Created a refactoring to simplify
[Rock]creation (issue #361 and issue #369) - Added a suppressor for
CA2012when aValueTaskis passed toReturnValue(issue #354) - Added
RockContextto group expectation instances together and automatically callVerify()(issue #365)
- Made a number of minor internal refactorings that made compile-time code generation consume slightly less memory (issue #358 and issue #367)
- Restructured package to separate analyzers and runtime types (issue #339)
- Interfaces with non-public members that have a default implementation are no longer considered for mocking (issue #364)
- Generated constructors calling a base constructor attributed with
[SetsRequiredMembers]will now have that attribute as well (issue #368) - Shim types now include generic type parameter names (issue #374)
- Shim types with an
initproperty now work with no issues (issue #373)
- Handlers for methods with
reforoutparameters and parameters with default values are now generated correctly (issue #350) - Events in interfaces that contain members with default implementations are now handled correctly in shim types (issue #349)
- Members using generic types with different type parameters are now generated correctly (issue #351)
- Hiding members that are different only by type parameter constraints will now work (issue #352)
- Non-public types used with parameters or return types now work correctly (issue #345)
[RockPartial]allows the user to define the name of the expectations type (issue #342)
- Type parameters constrained with
allows ref structare now supported (issue #331) - Added more parameter information when an
ExpectationExceptionoccurs (issue #338)
- Closed generics are no longer valid types to mock (issue #318)
- The following attributes were removed:
RockCreateAttribute,RockCreateAttribute<>,RockMakeAttribute, andRockMakeAttribute<>(issue #324) - Improved handling of
ref structtypes (issue #170) - Improved handling of pointer and special types (issue #330)
scopedis no longer added to aparamsargument (issue #328)- Parameters for base member invocations now make all names literal (issue #334)
- "Caller" attributes are no longer emitted with parameters that have optional values and the method is explicitly implemented (issue #332)
- Static virtual members on interfaces will not be processed (issue #337)
- Special types (
ArgIterator,RuntimeArgumentHandle,TypedReference) used as parameter or return types are now handled (issue #329) - Nested generic types are now handled correctly (issue #333)
- Members that hide other members are now handled correctly (issue #336)
- Addressed a rare naming issue with projects referencing Rocks and each other (issue #340)
- Added a diagnostic to warn about mocking closed generic types (issue #326)
- Added collection expression support for
EquatableArray<>(issue #327) - Created a new attribute,
RockAttribute, and obsoleted the existingRockCreateAttributeandRockMakeAttributeas a warning (issue #323)
- Minor project changes: removed GitHub source linking, embedded debug information, and added NuGet auditing (issue #321)
- Nullable types within type definitions are now constrained correctly (issue #320)
- Rare naming collisions with the generated expectations class and property names are resolved (issue #288)
- Generated code is now excluded from code coverage (issue #312)
- Non-public member descriptions are now found (issue #317)
- Open generics are now supported (e.g.
[RockCreate(typeof(IService<>))]) (issue #287) - Changed how handlers were managed in a mock (issue #302)
- Made minor updates to improve performance (issue #298)
- Added support for
scopedparameters (issue #304) - Removed the member descriptions in generated code, and replaced with run-time discovery (issue #307)
- Final release for 8.0.0
- Moved diagnostic reporting to an analyzer (issue #289)
- Prevented expectations from being set after a mock was created (issue #294)
- Mock types with explicit and non-explicit properties/indexers now generate correct code (issue #299)
- Ignored a warning when a make was generated and
[MemberNotNullWhen]existed (issue #297) - Added generics to event extension methods when needed (issue #295)
- Fixed a variable naming issue in the member expectation handlers (issue #296)
- Made internal refactors for member discovery (issue #235)
- Changed mock creation to eliminate casts and use attributes to initiate mock code generation (issue #283)
sealedmembers on interfaces are no longer included in the mock type (issue #284)
- Updated projects to use .NET 8.
- No longer emitting
[Nullable]or[NullableContext]attributes (issue #273) - Using a type with nullable types will now create a valid file name (issue #275)
- Fixed an issue with parameters marked with
[AllowNull]and haddefaultas the default value (issue #279) - Overriding methods that change the name of generic parameters are now handled correctly (issue #280)
- Non-virtual static members in interfaces are no longer included in the mock (issue #276)
- Calling base members in the mock will use the parameter name to ensure the correct base member is invoked (issue #278)
- Internal abstract members with unreferenceable names are now handled correctly (issue #277)
- References that have aliases will now be used in Rocks during mock generation (issue #281)
- Created overloads for member expectation setup when the parameters have optional values (issue #264)
- Changed diagnostics so their location is on the
Rock.Create()orRock.Make()invocation (issue #270) - Altered diagnostic creation for obsolete type usage (issue #267)
- Removed diagnostic docs that were no longer relevant (issue #272)
- Made all package references in Rocks private (issue #266)
- Corrected how generic methods are handled in the mock (issue #269)
- Fixed how methods are matches with nullability differences in arrays (issue #271)
- Ensured members that have
[DoesNotReturn]generate code with no returns (issue #175)
- Put the "auto-generated" comment in the generated code (issue #260)
- Adding separate checks for obsolete usage (issue #249)
- Duplicate constructors will prevent a type from being mocked (issue #256)
- Fixed a type name when an explicit property setter extension method is made (issue #229)
- Fixed a type name when an explicit event is declared in the mock (issue #238)
- Added unmanaged constraints to type parameters for projected pointer types (issue #242)
- Constraints on type parameters that are inaccessible will prevent a mock from being created (issue #237)
- Mockable members that are considered obsolete will prevent a mock from being created (issue #240)
- Methods that hide mockable methods are no longer generated (issue #239)
- Addressed when explicit interface implementations should occur in shims (issue #231)
- Correctly detecting when duplicate method signatures exist on the same type (issue #232)
- Abstract members that match an existing non-virtual member will prevent a mock from being made (issue #247)
- Added the null forgiving operator for shim members (issue #246)
- Updated type generation for
Tasktypes in makes to use a FQN (issue #248) - Expanded the search for obsolete type usage (issue #250)
- Handled another issue with duplicate members on a type (issue #251)
- Changed the file name to reduce collisions (issue #219)
- Members with more than 16 parameters are now handled correctly (issue #234)
ConditionalAttributeinstances are no longer emitted (issue #233)- Attributes with a
return:target are now emmitted correctly (issue #230) - Non-accessible types are now considered to determine a member's visibility (issue #213)
- Base properties that are hid and have different accessors are new explicitly implemented (issue #227)
- Default values for optional parameters are no longer being emitted for explicit implementations (issue #225)
- Exact matches for methods on an interface are no longer duplicated (issue #226)
- Handled a case where a type parameter value led to matching members (issue #217)
- Fixed an issue with pointer projected types based on a type parameter (issue #215)
- Addressed an issue when a
notnullconstraint was not being emitted (issue #204)
- Change the internals of Rocks to use read-only models for mock generation (issue #212)
- If an exception is thrown in
Callback(), theVerify()call now works as expected (issue #220) - When
Verify()fails, the resulting exception message now contains the correct member information (issue #221) - Added XML documentation and changed the visibility on some members that were not used in generated code (issue #138)
- Changed the name of the exception
MockExceptiontoNoReturnValueException(issue #223) - Enforced dispose rules on
RockRepository(issue #222)
- Created the final release (issue #218)
- Indexers with an
initcan now be set up withConstructorProperties, and properties and indexers with aninitcan be set up with expectations (issue #197)
- All direct casts now use
Unsafe.As<>()(issue #198)
protected internalproperties and indexers with different visibilities on theget,set, orinitnow works correctly (issue #216)- Named tuple elements no longer cause an issue in the mock (issue #214)
- Projected types using an open generic type are now generated correctly (issue #211)
- Members that are hidden by accessible static members are now removed (issue #206)
- Methods on classes with generics that have
classorstructconstraints are now emitted on the mock (issue #210) - Projected delegates now have constraints added (issue #202)
- Parameters with generic types and a
defaultoptional value are now generated correctly (issue #200) - Enum value references in optional arguments are handled correctly (issue #209)
- Visibility differences in properties are handled correctly (issue #203 and issue #207)
- Default values for optional parameters like
double.PositiveInfinitywill no longer print out the infinity symbol (issue #208) - Internal members that are not visible will not be included in the mock (issue #199)
- Generated shim types to handle DIM invocations have been updated to remove a couple of errors (issue #188)
- If Rocks encounters the
AsyncIteratorStateMachineAttribute, it will not generate its description in the mock (issue #185) - Async iterators are now handled correctly (issue #191)
- Members that use obsolete types will flag the type to mock as unmockable (issue #182)
- Constraints are generated correctly, based on the type to mock (issue #186)
- Support for types with hidden members have been improved (issue #187)
- Types that have
internal abstractmembers are now flagged as being unmockable (issue #181) - Parameters that do not have nullable annotation and have a
nulloptional value are now handled correctly (issue #192) - Only one of these constraints is now added to the generated mock:
unmanaged,notnull,class, orstruct(issue #180) - Generated delegates for projected types now use SHA to create the hash code (issue #194)
- Types that use C# keywords for parameters (e.g.
string @namespace) are now handed by Rocks (issue #184) - Parameter names will no longer collide with variables created by Rocks (issue #183)
- Constraints on generic parameters from methods are now carried to the extension methods used for setting expectations (issue #179)
- For makes, any
Task<>orValueTask<>return types are marked with the null-forgiving operator when the return type is not nullable. (issue #174) - For makes,
[AllowNull]now shows up on properties when the base property has it defined. (issue #174) - Constraint ordering has been fixed in certain cases (it was failing when there were
structand interface constraints) (issue #174) - Method matching now correctly handles cases where the either parameters or return types use generic type parameters. (issue #174)
- If an interface has static abstract members, Rocks will raise the
InterfaceHasStaticAbstractMembersDiagnostic(ROCK7). (issue #174)
- While this package technically targets .NET 6, this version is intended to target .NET 7.0 and C# 11-related features.
requiredandinitproperties can be set in theInstance()method via aConstructorPropertiestype (issue #162)
- Added the README.md file to the package (issue #168).
- Methods that have the
[DoesNotReturn]attribute are now mocked such that they will throwDoesNotReturnException. This addresses theCS8763warning (issue #169). - If the mock type is an interface and it contains methods that match accessible methods from the
objecttype (e.g.Equals(T? other)fromIEquatable<T>), the methods will be implemented in the mock explicitly. This addresses theCS0114andCS0108warnings (issue #169). - Properties with the
[AllowNull]attribute are now handled correctly. This addresses theCS8765warning (issue #169). - If a property expectation was not met, calling
Verify()was causingInvalidOperationExceptionto be thrown instead ofVerificationException. This is fixed (issue #171).
- Fixed issue with ref-like types (e.g.
Span<T>) being used for the return type of a method, or a getter of a property. - Fixed issue mocking a class with an accessible constructor that had
ref,out, and/orparamsparameter. - Fixed issue referencing types anywhere within the mock that was a nested type.
- Fixed issue with explicit implementation from a generic type was not emitted correctly.
- Fixed issue with types with members that "shadow" base members (think
IEnumerable<T>) - now one is being explicitly implemented. - Fixed issue where Rocks was allowing special types (e.g.
Delegate,ValueType,Enum) to be mocked, and they can't be. - Fixed issue When a base method is called because it is
virtualand no expectations were set, if method has aparamsparameter, it will now be called correctly. - Fixed issue with enums with negative values causing issues in attribute data.
- Fixed issue adding attributes to members when they were not able to be "seen" by the assembly.
- Fixed issue where methods had certain attributes that should not be included in the mock (
IteratorStateMachineAttribute,CompilerGeneratedAttribute, andAsyncStateMachine). - Fixed issue when projecting types for pointers, ref-like types, etc., from types to mock that were in the same namespace.