Repository navigation
chore: Bump Imposter from 0.1.11 to 0.2.23 - #883
Conversation
--- updated-dependencies: - dependency-name: Imposter dependency-version: 0.2.23 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
🚀 Benchmark ResultsDetails
Details
Details
Details
Details
Details
|
….23 (#883) by dependabot[bot]
….23 (#883) by dependabot[bot]
Updated Imposter from 0.1.11 to 0.2.23.
Release notes
Sourced from Imposter's releases.
0.2.23
Fixes
typeof(Outer<>.Inner), got an imposter that referred to the containing type's type parameters without declaring them (CS0246). The imposter now declares them, outermost first, followed by the target's own type parameters, with their constraints, soOuter<T>.Inner<U>getsInnerImposter<T, U>. A closed registration such astypeof(Outer<int>.Inner)keeps its own imposter and can sit beside the open one. The generics docs cover it with an executable example.0.2.22
Fixes
@class,@eventor@object, was written bare in the imposter and failed to compile. Such names are now escaped wherever generated code uses them.allows ref struct(#365, closes #356). Two interfaces' methods with the same signature, where only one type parameter allows ref structs, got two implicit implementations (CS0111, CS0425). They're now implemented explicitly, like methods whose constraints differ in other ways.IService<IServiceImposter>generatedclass IServiceImposter<IServiceImposter>(CS0694). The imposter keeps its name, and the type parameter takes another one in generated code.Documentation
Maintenance
0.2.21
Fixes
System,Collections,Generic,Tasks,Imposter,Abstractionsor your own namespace, or the nameglobal, got an imposter that failed to compile (CS0234, CS0400, CS0432). The imposter now renames only the type parameter itself in those types, and leaves namespaces and theglobal::alias as they are.0.2.20
Fixes
Type parameters named
var,_,recordorpartial(#357, closes #319). A target or method type parameter with one of these names made the imposter fail to compile:varand_turned the generated locals and discards into the type parameter;recordor, from C# 14,partialread as a record or a partial member.Such a type parameter now takes another name in generated code, one that no type parameter, parameter or member beside it uses. You still write the imposter and its setups with your own type arguments, as before.
Maintenance
inarguments withinin every place that forwards them (#352, closes #322), and the generator dropped some dead code and duplicated logic (#351, #353, #355). The generated imposters behave the same.0.2.19
Fixes
Currentproperty and aCurrent()method, got an imposter that failed with CS0102. These members now take apart names on the imposter, like same-kind members already did. The target's own member names are unchanged.Get<GetDelegate>,Get<IGetMethodImposterBuilder>andGet<GetMethodImposterCollection>(CS0694, CS1503), andGet<Builder>orGet<Adapter>(CS0102). The method's generated types and nested classes now take other names in that case.0.2.18
Fixes
System.Actionshadowed by a type namedSystem), or an event declared with a non-delegate type, made the generator report IMP005 and drop that target's imposter. With a Debug build of the generator, every imposter of the project was dropped. Such an event is now left out of the imposter, the compiler's own error stays the one to fix, and the rest of the imposter is generated.0.2.17
Fixes
typeof(IRepository<int>)now generates the open type's imposter,IRepositoryImposter<T>, as IMP006 and the docs already said:Imposter()extension was declared forIRepository<int>.putInTheSameNamespace: false, a closed registration's imposter now goes into the open type's namespace, such asImposters.Sample.IRepository_T_instead ofImposters.Sample.IRepository_int_.typeof(Outer<int>.Inner)generates as before and no longer reports IMP006.IRepo<GetDelegate>, whose type parameter has the name of a type the imposter generates, failed to compile. Those types are now renamed, as they already were for a member of that name.0.2.16
Fixes
IFooandIfoomade the generator fail with CS8785, and no imposter of the project was generated. Roslyn compares generated file names ignoring case, so the two files clashed. Such targets' files now get a hash of the target's name in their file name, as generic targets' files already do. Every other file keeps its name.Performance
0.2.15
Performance
Get_1()clear of other setup names. Most targets have no numbered setup, so it now does that only when one needs it. Generating 400 methods allocates 1.3% less (2.78 MB); the generated code is unchanged.0.2.14
Performance
null, and checked it on each set that reached it. The setter already calls the base setter itself, so that parameter and check are gone. Behaviour is unchanged.0.2.13
Fixes
dynamicand takes aref dynamic(#308, closes #307). An event such asdelegate dynamic DynHandler(dynamic x, ref dynamic y)failed to compile (CS0019, CS8716). It now compiles.Performance
dynamictypes no longer use the runtime binder (#308, closes #307). An imposter keptdynamicarguments, results and values asdynamic, so its own calls with them were dynamic call sites, bound by Microsoft.CSharp's runtime binder on first use. That covered matching a setup and formatting a verification message. It now keeps them asobject, and those calls bind when the imposter compiles. What you write against keepsdynamic:Arg<dynamic>in setups andRaised, and theReturns,Callback,Throwsand indexer delegates.0.2.12
Fixes
Methods of two interfaces that differ only in
objectanddynamic(#303, closes #301). Two interfaces'Use(object)andUse(dynamic), orUse(List<object>)andUse(List<dynamic>), have the same signature at runtime. The imposter didn't treat them as colliding and failed with CS0111. They're now implemented apart and set up through their interfaces' setup views.Members with
dynamictypes (#306, closes #304). These failed to compile because adynamicargument binds the call at runtime:dynamic(CS8716);dynamicparameter, value or key, with its base implementation (CS1971, CS1976, CS1977, CS1972);dynamic(CS1975);dynamicparameter (CS1962).Generated code now passes
dynamicvalues between its own members asobject. Setups (Arg<dynamic>,Returns, callbacks) keepdynamic.Diagnostics
int*,int*[]ordelegate*<int, void>, generated an imposter with dozens of compile errors and no explanation. Such a target now reports IMP013 and gets no imposter.0.2.11
Features
where T : allows ref struct(C# 13) no longer reports IMP009. A value ofTmay be aref struct, so the imposter passes it through, whatever the type argument:imposter.Measure<Gauge>(Arg<int>.Any()).Returns((value, scale) => value.Level * scale).Returns,CallbackandThrows, and the base implementation, get the value. A result of typeTcomes only from aReturnsdelegate or the base implementation.This completes #201. Still IMP009, and documented in Limitations:
in;inorref readonlykey and a base getter;Fixes
void Use()next tovoid Use<T>()got numbered setups, soimposter.Use<int>()didn't compile; it had to beimposter.Use_1<int>(). Such overloads now keep their names.Use<T>(T)andUse<U>(U), or a method hiding an inherited one under another type parameter name, failed with CS0111. They're now set up apart, through their interfaces' setup views.0.2.10
Features
ref structtype (#297, part of #201). A key of a ref struct type, passed by value, no longer reports IMP009. An imposter can't keep or match a ref struct key, so it passes the key through:imposter[Arg<int>.Any()].Getter().Returns((row, locator) => row + locator.Offset).Returns,CallbackandThrows, and the base implementation, get the key.imposter.Indexer()orimposter.Indexer_1(). Its interface's setup view declares the same method.Still IMP009 (see Limitations):
in;inorref readonlykey and a base getter;0.2.9
Features
Members with a custom
ref structtype, part of #201. These no longer report IMP009. An imposter can't keep or match a ref struct, so it only passes one between the caller and your delegates:Returns,CallbackandThrows, and the base implementation, get the argument, by reference forrefandout.Read_1.Returnstakes only a delegate, as inReturns(size => new Slot(size)).default.Raisepasses it on to the callbacks and the handlers, andRaisedmatches the other arguments.Returnstakes only a delegate.Setter()takes no criteria, andCalledcounts every set.default.Returnstakes only the delegate that gets the keys.Calledleave the value out.default.Still IMP009 (see Limitations):
inorref readonlykey and a base getter;Fixes
Generated types named like another member (#293, closes #289). The imposter declares types named after each member, such as
ICurrentPropertyBuilderorGetDelegate. Two cases made the imposter fail with CS0102:FooandFooCallback.The member whose types clash now names them after another unique name. Its setup keeps its name.
Event and indexer builder fields named like another member (#295, closes #294). A property named
_Changednext to an eventChanged, or_IndexerIndexernext to an indexer, failed with CS0102. Those fields now avoid the other members' names, as a property's already did.0.2.8
Features
scopedparameter that return a span or take one byreforout(#281, part of #201). These no longer report IMP009. The same goes for aparamsspan, which is scoped implicitly, and for an indexer with a span value and ascopedorparamskey. Generated code repeatsscopedwherever it declares the parameter again. C# doesn't inferscopedfor a lambda that leaves out its parameter types, so a lambda passed toReturnsfor such a member declares them:.Returns((scoped ReadOnlySpan<char> text) => ...).reforout, and spans of async events (#285, part of #201).Raisepasses areforoutspan by reference. For an async delegate,RaiseAsynctakes the array the span covers, and the handlers get a span over it.Still IMP009 (see Limitations): custom
ref structs, type parameters that allow ref structs, a span returned by reference, and a span an async event's delegate takes byref,outorref readonly.Fixes
reforoutparameter (#284, closes #282). Their imposters compile now. A handler's change to arefargument reaches the raiser, and anoutargument starts as the default.Internal
The generator's code was reorganised without changing what it generates:
EnsureConfigured, verification and constructor builders are shared (#279, closes #231);0.2.7
Features
Spans in properties, indexers and events (part of #201). These no longer report IMP009:
Span<T>orReadOnlySpan<T>(#224). The imposter keeps the value as the array of its elements, andReturnstakes that array.SpanArg<T>/ReadOnlySpanArg<T>.Raisedmatches them withSpanArg<T>/ReadOnlySpanArg<T>.Still IMP009 (see Limitations):
ref structs;reforout;scopedcases;New diagnostics
Each of these targets used to get an imposter that didn't compile, with no diagnostic. Now it reports an error and gets no imposter:
reforref readonly(#244, closes #216).allows ref structanti-constraint (#222, closes #218).Fixes
requiredmembers (#219, closes #215). Their imposters now compile and leave the required members at their defaults.Raisedkeep the delegate's nullable annotations (#265, closes #258). For anEventHandler,Raise(null, EventArgs.Empty)no longer warns CS8625.it(#245, closes #241). Its arguments criteria no longer fail with CS1061.IFooandIFoo<T>(#246, closes #242). TheirImposter()extension classes no longer collide.TException(#268, closes #264). The builders'Throws<TException>()no longer shadows it (CS0693).Changes to be aware of
Arg<object>for anobject?event parameter now warns. With nullable reference types enabled, passingArg<object>where the delegate's parameter isobject?(anEventHandler's sender, for example) warns CS8620, as it already did for methods. UseArg<object?>. The same applies to handler criteria for delegates such asFunc<object?, EventArgs, Task>.Internal
The generator's code was reorganised without changing what it generates. The snapshot tests confirm the output is byte-identical:
0.2.6
Features
Span parameters and returns (part of #201). Methods that take
Span<T>orReadOnlySpan<T>(by value,in,ref readonly,reforout), or return one by value, no longer report IMP009:SpanArg<T>andReadOnlySpanArg<T>(Is(elements),Is(elements, comparer),Is(predicate),Any());OutSpanArg<T>andOutReadOnlySpanArg<T>foroutspans.ReturnsandCallbackreceive the span itself, by reference forrefandout.Returnstakes the array the span covers.Spans in properties, indexers and events, and custom
ref structs, still report IMP009 (see Limitations).Fixes
Count(int)andCount(in int)got setups with the same signature, and the imposter didn't compile:Count_1), on the imposter and in the setup views.ref,outorinparameters (#212, closes #211).ReturnsAsync,ThrowsAsyncand the default result of such methods didn't compile (CS1988).Docs
0.2.5
Performance
Diagnostics
private protectedmembers of another assembly) now reports IMP008 instead of generating an imposter that can't compile (#173, closes #148).Span<T>,ReadOnlySpan<T>or anotherref structin their signature now reports IMP009, naming the member and the type, instead of generating code with compile errors. The limitation is documented on the Limitations page (#202, closes #132).Fixes
NullReferenceExceptioninside the imposter. Such calls now run the base implementation or return defaults (see Limitations).initaccessors generated ordinary setters that didn't compile.protectedor otherwise restricted accessor are overridden legally, and accessors the project can't override are left alone.inindexer parameters with base implementations (#168, closes #140);inparameters (#170, closes #169);ref readonlyparameters (#172, closes #167).T?,string?and nullable constraint annotations, soReturns((string?)null)compiles with nullable warnings as errors.invocationBehaviororimposter(#188, closes #184);callback,handler,task,pendingTasks) or the event builder's members (#187, closes #186; #191, closes #189);Handler,Item1,Restand other names C# reserves for tuple elements (#199, closes #190);_callbacksorDefaultResultGenerator(#194, closes #192);otherorhash(#197, closes #195);Equalson an indexer orAson a generic method (#200, closes #198).Internal
masterbefore merging (#203, closes #160).0.2.4
Fixes
HttpMessageHandler(#145, closes #118). Overrides copied the member's declared accessibility, so aprotected internalmember from another assembly was overridden asprotected internal(CS0507), andinternalorprivate protectedvirtual members were overridden although the project cannot see them. Overrides now useprotectedin that case, and members and constructors the project cannot access are skipped.HttpMessageHandlercan now be impersonated. A class whose constructors are all inaccessible reports IMP004.sealedhad no setup or verification API, and calls always ran the real override. Behaviour change: such methods now behave like the class's other virtual methods.ToString,EqualsandGetHashCodeoverrides keep their real behaviour.decimal? d = 1.5m,E? e = E.B),NaNand infinities were copied into the imposter's constructors as code that did not compile.arguments(#137, closes #105);methodDisplayNameorCalled(#144, closes #107);Environment,CountorException(#136, closes #108).inparameters (#134, closes #106). The generated imposter failed with CS1615.Internal
tests/Imposter.Tests/GeneratedFiles/<Roslyn version>/up to date, so generator changes show up as diffs in pull requests (#139, closes #116).0.2.3
Fixes
IMPOSTER_LOGnow works from the NuGet package (#135, closes #113). The package did not make the property visible to the generator, so setting it had no effect. The log is also more useful now:Imposter()extensions are generated;Set
IMPOSTER_LOG=trueand build with-v:dto see theIMPLOG001lines (see Getting Started).Keyword-named type parameters (#119, closes #109). Type parameters such as
@classor@inwere written without the@, so the generated file did not compile.Async event callbacks run before handlers (#120, closes #110). Behaviour change:
RaiseAsyncnow runs theCallback(...)callbacks before the subscribed handlers, the same order asRaise. Before, it awaited the handlers first.Event verification messages name the event once (#124, closes #111). A failed subscription verification printed the event name twice. Message text change: update tests that assert on the exact text.
New diagnostic
typeof(IRepository<User>)generates the same generic imposter astypeof(IRepository<>); the type arguments have no effect. The generator now warns and suggests the open registration. WithTreatWarningsAsErrors, switch to the open registration or suppress IMP006.Package
Internal
0.2.2
Fixes
[GenerateImposter]by the name as written. When every attribute in a project went through an alias (using Generate = Imposter.Abstractions.GenerateImposterAttribute;, or aglobal usingalias), no imposter was generated. Newer compilers were not affected.Performance
[GenerateImposter], so its cost grows linearly instead of with the square of the attribute count. With 800 attributes, it drops from about 480 ms and 138 MB per run to about 3 ms and 2 MB.0.2.1
Fixes
IFoo<int>andIFoo_int_both gotIFoo_int_Imposter.g.cs. Roslyn then dropped every file of the generator, so no imposter was generated for the project (warning CS8785).Sample.IFooImposter.g.csare unchanged._, now end with a short stable hash, e.g.Sample.IRepository_TEntity_Imposter.6b1618b2.g.cs.0.2.0
Fixes
Generic method calls no longer slow down over time (#61, closes #60). An unconfigured call to a generic method stored a new imposter that could never match, and every later call scanned all of them. After a few thousand calls, each call cost about 0.5 ms. A miss now returns an imposter that is not stored, and the lookup is a plain loop instead of a LINQ chain.
Indexer keys are compared with
EqualityComparer<T>.Default(#63, closes #62). The generated indexer arguments compared keys with==. That caused two problems:==(CS0019).Equals, so the default indexer behaviour could not read back a value stored under an equal key.Async methods are recognised on netstandard2.0 and .NET Framework (#65, closes #64).
Task,Task<T>andValueTask<T>were only recognised when they came fromSystem.Runtime,System.Private.CoreLibormscorlib. On netstandard2.0, and forValueTask<T>on .NET Framework, the builders lackedReturnsAsync/ThrowsAsync. Task types are now detected by name and namespace.Cancelled builds no longer report a generator crash (#75, closes #74). A build cancelled while an imposter was being generated reported IMP005. The IDE then kept a result without the imposter until the next edit. Cancellation now propagates.
Generated file names no longer depend on attribute order (#77, closes #76). Two targets with the same name in different namespaces got
IFooImposter.g.csandIFooImposter_1.g.csin processing order, so reordering the attributes swapped the files. Each file is now named after its fully qualified target, e.g.Sample.IFooImposter.g.cs, orImposters.Sample.IFooImposter.g.csfor the dedicated namespace.Performance
NormalizeWhitespace.Changes to generated output
EmitCompilerGeneratedFiles, they now appear under the new names.Commits viewable in compare view.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebasewill rebase this PR@dependabot recreatewill recreate this PR, overwriting any edits that have been made to it@dependabot show <dependency name> ignore conditionswill show all of the ignore conditions of the specified dependency@dependabot ignore this major versionwill close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor versionwill close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependencywill close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)