How to only include a single type in stub generation?
- How can i include a single type in my Assemblies1.stubx? The filters seem a bit strange to me. I couldn't get it to work.
<Stubs xmlns="http://schemas.microsoft.com/stubs/2008/"> <Assembly Name="CK" /> <StubGeneration> <TypeFilter ExcludedNamespace="C*"/> <TypeFilter SkipClasses="true" SkipObsolete="true" TypeName="CK.Models.IWebEnvironment"/> </StubGeneration> <MoleGeneration> <TypeFilter ExcludedNamespace="C*"/> <TypeFilter ExcludedNamespace="S*"/> </MoleGeneration> </Stubs>
I want to do this: .Where(t => t.Name == "IWebEnvironment")Suggestion: Place a small descirption in the default stubx file.- Edited byNikolai TillmannMSFT, OwnerThursday, October 01, 2009 3:49 PMspelling
- Edited byNikolai TillmannMSFT, OwnerThursday, October 01, 2009 3:48 PMspelling
Answers
- This issue is fixed in 0.18. Please reopen if you find another issue.
Jonathan "Peli" de Halleux - Give us your input about Pex!- Marked As Answer byPeliMSFT, OwnerThursday, October 29, 2009 4:04 AM
All Replies
- Got it:
<Stubs xmlns="http://schemas.microsoft.com/stubs/2008/"> <Assembly Name="CK" /> <StubGeneration> <TypeFilter TypeName="IWebEnvironment"/> </StubGeneration> <MoleGeneration Disable="true"> </MoleGeneration> </Stubs>
Was a bit frustrating though. - The reason the first approach did not work is that there is a bug when we generate the filter. Instance of a disjunction, we group the 'TypeFilter' as a conjunction.... so no types are generated. This issue will be fixed in the next release.
Are you suggesting a boiler plate filter (commented) in the initial stubx file?
Jonathan "Peli" de Halleux - Give us your input about Pex! - That would be nice. I was thinking of a descriptive text in xml comments at the top of the file. How are multiple filter entries applied anyway? Is it like NTFS ACLs top to bottom first match or top to bottom last match? One of those would make most sense to me as one could select very fine-grained. I would also recommend naming TypeName => IncludetypeName in order to be symmtrical to excludetypename.
- It is top to bottom first match. Do you get the intellisense from the XSD schema?
Jonathan "Peli" de Halleux - Give us your input about Pex! - Yes intellisense for schema is there. Just no documentation about the sematics. btw, top to bottom does not work:
<?xml version="1.0" encoding="utf-8" ?> <!-- This file is used by Microsoft.Stubs to generate stubs for all the interfaces in the assembly under test. --> <Stubs xmlns="http://schemas.microsoft.com/stubs/2008/"> <Assembly Name="CK" /> <StubGeneration> <TypeFilter TypeName="IWebEnvironment"/> <TypeFilter TypeName="UserServiceBase"/> </StubGeneration> <MoleGeneration Disable="true"> </MoleGeneration> </Stubs>
This produces an empty .designer.cs file. I now have split the stubx file into two files, one for each type. This works. How does the filter behave if none of the TypeFilter-Elements match? Is the type included or excluded?Suggesiton: Allow an "empty filter" ("*") for exclude or include to customize if everything is matched or not-matched by default. - As mentionned above, to-bottom does not work because of a bug in the way we combine the filters (conjunction vs disjunction). I'll beef up the schema intellisense.
Jonathan "Peli" de Halleux - Give us your input about Pex! - This issue is fixed in 0.18. Please reopen if you find another issue.
Jonathan "Peli" de Halleux - Give us your input about Pex!- Marked As Answer byPeliMSFT, OwnerThursday, October 29, 2009 4:04 AM


