PluginRegistry.inspect not returning PluginImplementation with pluginId

We got list of random gradle plugin classes and would like to find out pluginIds for those plugin classes and based on the available documentation, we are trying to use PluginRegistry inspect or maybeInspect methods and expecting these methods will return PluginImplementation with PluginId but actually returns PluginImplementation with PluginId as null.

Is this expected or do we need to anything else to get pluginId correct?

PluginContainer pluginContainer = project.plugins
PluginRegistry pluginRegistry = pluginContainer.pluginRegistry
PluginImplementation pluginImplementation = pluginRegistry.inspect (< Plugin Class >)

pluginImplementation.getPluginId() always returns null for both gradle provided standard plugins and for our custom plugin classes.

Please let us know in case we are missing anything else here or got any other good ways to find plugin Id from known list of gradle plugin classes.