fixes #6683 We cannot cast the object type before checking it and in case the object is wrong, the filter cannot be processed and the user needs info about his mistake that he can fix this. - also some code style fixes by MSVC