Repository navigation
Merge TypesV3_Ps1Xml.cs with Types_Ps1Xml.cs #10575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ddc1849
1042dfb
53b465a
114dc29
d429a35
5618f73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3497,7 +3497,7 @@ public TypeTable(IEnumerable<string> typeFiles) : this(typeFiles, null, null) | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /// <summary> | ||||||||||||
| /// Load types.ps1xml, typesv3.ps1xml into the typetable. | ||||||||||||
| /// Load types.ps1xml into the typetable. | ||||||||||||
| /// </summary> | ||||||||||||
| /// <exception cref="System.Security.SecurityException"> | ||||||||||||
| /// if caller doesn't have permission to read the PowerShell registry key | ||||||||||||
|
|
@@ -3515,16 +3515,14 @@ public static TypeTable LoadDefaultTypeFiles() | |||||||||||
| public static List<string> GetDefaultTypeFiles() | ||||||||||||
| { | ||||||||||||
| string typesFilePath = string.Empty; | ||||||||||||
| string typesV3FilePath = string.Empty; | ||||||||||||
|
|
||||||||||||
| var psHome = Utils.DefaultPowerShellAppBase; | ||||||||||||
| if (!string.IsNullOrEmpty(psHome)) | ||||||||||||
| { | ||||||||||||
| typesFilePath = Path.Combine(psHome, "types.ps1xml"); | ||||||||||||
| typesV3FilePath = Path.Combine(psHome, "typesv3.ps1xml"); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| return new List<string>() { typesFilePath, typesV3FilePath }; | ||||||||||||
| return new List<string>() { typesFilePath }; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /// <summary> | ||||||||||||
|
|
@@ -4493,7 +4491,9 @@ private bool ProcessIsBuiltIn(string filePath, ConcurrentBag<string> errors, out | |||||||||||
| } | ||||||||||||
| else if (string.Equals(Path.Combine(psHome, "typesv3.ps1xml"), filePath, StringComparison.OrdinalIgnoreCase)) | ||||||||||||
| { | ||||||||||||
| ProcessTypeData(filePath, errors, TypesV3_Ps1Xml.Get()); | ||||||||||||
| // Workaround for a scenario where we get the 'typesv3.ps1xml' file name from public API. | ||||||||||||
| // Now all types from 'typesv3.ps1xml' is in 'types.ps1xml' so we load 'types.ps1xml'. | ||||||||||||
| ProcessTypeData("types.ps1xml", errors, Types_Ps1Xml.Get()); | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There GetOrAdd() is used. (But it will slow down) I'd prefer a breaking change (gray area) and get rid typesv3.ps1xml (and then types.ps1xml as James asked). It looks like very rarely edge case.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think merging those two source files and eliminating
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My thought is that it opens a way for future optimizations.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just took a look at the code in PowerShell/src/System.Management.Automation/engine/TypeTable.cs Lines 2698 to 2702 in 36bc894
The
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried the compiled artifact and get the error. If PowerShell Committee conclusion will be to have a workaround I will discover another workaround but I hope we will agree to remove. |
||||||||||||
| result = true; | ||||||||||||
| } | ||||||||||||
| else if (string.Equals(Path.Combine(psHome, "GetEvent.types.ps1xml"), filePath, StringComparison.OrdinalIgnoreCase)) | ||||||||||||
|
|
||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is used by
public TypeTable(IEnumerable<string> typeFiles). This is a public API and this change is potentially a breaking change if thetypeFilespassed to that public constructor containstypes3.ps1xml.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added new commit to partially address the breaking.
After that I hope the breaking change will be in gray area.
The only scenario that we cannot fix is to load 'typesv3.ps1xml' file without 'types.ps1xml'. This scenario is incredible.