You should be able to get size, but onedrive can be configured in different way depending on version and OS.
But it depends on how you set it up. If there is symlinks or junctions link for folder these will not be followed when getting size (since it can resolve into a loop and never end.)
On Win10, If "file on demand" is active. Then it will show the size of all files even if they are not synced to disk yet and are tagged as offline.