Add NotNull checks.
Handle IsCustomAttributeDefined when Env is null.