Fix crossgen2 skipped methods NullReferenceException (dotnet/coreclr#27028)
* Fix crossgen2 skipped methods NullReferenceException
https://github.com/dotnet/coreclr/pull/26756 introduced skipping methods based on filtering criteria, publishing empty code for methods which are skipped.
`ShouldSkipCompilation` reads properties on types and methods and can trigger type loads and thus throw `TypeLoadException`. Currently when that happens, we will not publish empty code for the method and hit the catch in `ComputeDependencyNodeDependencies`. Later when the node is scanned for dependencies, it is in a zombie state with `_methodCode` still null.
Move the `ShouldSkipCompilation` check under the `CompileMethodInternal` try/catch which will appropriately call `PublishEmptyCode` if there's a `TypeSystemException`.
Commit migrated from https://github.com/dotnet/coreclr/commit/
56a97e6dc5d6ac7d413edf6ca8ab28fa77b1f255