Skip to content

Conversation

@daxian-dbw
Copy link
Member

Resolving #2343

Updating with the latest .NET Core preview packages causes some regressions:

  1. Latest System.Runtime.Loader.AssemblyLoadContext causes a regression in PSAssemblyLoadContext. The regression has been fixed on PS side.
  2. With .NET Core 1.0.0 RTM, dotnet.exe doesn't verify the existence of assemblies that are built from the local projects when check the TPA deps assemblies, and thus we are able to remove IL assemblies after crossgen. However, the latest dotnet.exe checks the existence of locally built assemblies, so IL assemblies cannot be removed anymore.
  3. The new dotnet.exe loads IL assemblies in precedence, instead of NI assemblies. The symptom is that you will find PowerShellAssemblyLoadContext.dll is loaded by the default load context when both the IL and NI assemblies exist. But with RTM packages, PowerShellAssemblyLoadContext.ni.dll gets loaded by the default load context under the same circumstance. This doesn't affect us too much now because PowerShellAssemblyLoadContext handles the loading of other PS assemblies and it prefers NI over IL assemblies. However, when the legacy APIs are back and it's time to retire PSALC, our crossgen story will be broken if the default context prefer IL over NI. I will start a conversation with .NET Core team on this.
  4. Latest Microsoft.Win32.Registry will now raise PlatformNotSupportedException when you call any static members of it on UNIX. In PS code, we call some of its static properties when initializing some types (e.g. System.Management.Automation.Utils), and that caused PS to crash in UNIX. This is fixed.
  5. When working on #4, I found both Registry and Certificate providers are shown up in UNIX PS. They don't work in UNIX at all, and should not be exposed (until we have a UNIX implementation of Certificate provider someday). They are now excluded from compilation for UNIX PS.
  6. [System.Text.Encoding]::Default is available via reflection at runtime (exposed by System.Private.CoreLib), but it's not exposed in the reference contract of System.Text.Encoding, and thus we cannot use it in PS Code. This mismatch causes a redirection test to fail. The test is fixed to skip Encoding.Default for now. I will check with .NET Core team to clarify this mismatch.
  7. The exclusion of 'Certificate' provider causes some failures on UNIX PS, because some tests are using Cert:\ to test the error behavior when not using a FileSystemProvider drive. The tests are fixed.

…the latest dotnet.exe checks the existence of all TPA assemblies, including those built from the local projects
… especially the code that would run in TypeInitializer.

This is because with the latest .NET Core packages (1.1.0 preview), calling static members from 'Microsoft.Win32.Registry' will raise 'PlatformNotSupportedException'.
…y don't work on UNIX platform.

With this change, 'Registry' and 'Certificate' providers won't be compiled for UNIX PS.
@msftclas
Copy link

Hi @daxian-dbw, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!


It looks like you're a Microsoft contributor (Dongbo Wang). If you're full-time, we DON'T require a Contribution License Agreement. If you are a vendor, please DO sign the electronic Contribution License Agreement. It will take 2 minutes and there's no faxing! https://cla.microsoft.com.

TTYL, MSBOT;

@daxian-dbw
Copy link
Member Author

@andschwa @vors @lzybkr @mirichmo Could you please review this PR?

Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed it all; just had no comments. Thanks for fixing the whitespace in the project.json files 😄

@daxian-dbw
Copy link
Member Author

@andschwa Thanks Andy! It's quite easy to fix indentations in VIM, just gg=G 😄

@@ -1,3 +1,4 @@
#if !UNIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to do this within the project.json, but it looks like project.json does not support conditional inclusion and exclusion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. You can only exclude a file per target framework.

private string[] _exclude = new string[0];
}

#if !UNIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see comments added explaining why it is excluded. It'll help us determine when it is appropriate to remove these ifdefs. This comment applies to all the new "#if !UNIX" additions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added comments to the instances that I think there might be a confusion. For rest of the #if !UNIX it's very obvious that the enclosing code doesn't apply to UNIX platform, and I think they are self-explained :)

// Retrieves group policy settings based on the preference order provided:
// Dictionary<string, object> settings = GetGroupPolicySetting("Transcription", Registry.LocalMachine, Registry.CurrentUser);

// Calling static members of 'Registry' on UNIX will raise 'PlatformNotSupportedException'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly what I am looking for on the other #if !UNIX additions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is an example where I think it might raise confusion, so I added comments.

# runtime via reflection. However,it isn't exposed in the reference contract of
# 'System.Text.Encoding', and therefore we cannot use 'Encoding.Default' in our
# code. So we need to skip this encoding in the test.
continue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you set a variable that controls whether the It in this loop is skipped? It'll satisfy the tracked skipping requirement that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks!

…ad of ignoring it, so that we can keep track of this encoding issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants