Read the following question which explains TCMs like tcm:x-xx-v0 are created when items are checked out.
However when Ive tested using a simple C# TBB:
log.Debug("Executing C# template"); Item item = package.GetByName(Package.ComponentName); Component component = (Component)engine.GetObject(item); var versions = component.GetVersions().Cast<Component>().OrderByDescending(v => v.RevisionDate); var ids = string.Join(",", versions.Select(c => c.Id.ToString()).ToList()); var vs = string.Join(",", versions.Select(c => c.Id.Version).ToList()); log.Debug(ids); log.Debug(vs);
And checked out a component I see the following in the Template Builder log:
Debugging was started in process 'TcmTemplateDebugHost' with id 18688 CSharpSourceTemplate: Executing C# template CSharpSourceTemplate: tcm:346-403444-v2,tcm:346-403444,tcm:346-403444-v1 CSharpSourceTemplate: 2,-1,1
I'm assuming the TcmUri.ToString() strips the "-1" off, but even the Version isn't "0", its "-1" - which is inline with the API docs:
Either a non-negative version number or IdNull when version is not specified.
So at what point is a TCM like tcm:x-xx-v0 actually retrievable or exposed?
UPDATE Given Atila's comment below, I'll provide a little context - we've recently upgraded to DD4T 2 TBBs and we've noticed that the *Generate dynamic page" TBB will generate JSON with a TCM ending"v0" for components in presentations on the page that are checked out.
I wrote my smaller TBB to investigate what was going on.
UPDATE So its seems that if you get component versions via GetVersions() you're checked out component is version "-1" and a full TCM doesn't contain any version info.
However if you ask for a checked-out Component's Id directly (say adding log.Debug(component.Id.ToString()); to the above, the TCM will contain a "v0".
DD4T uses tcmComponent.Id.ToString(); which is why we where seeing the "v0" emitted into the JSON for a checked out component.
Is it odd that DD4T doesn't remove this given its not needed on the CD-side?