Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
README.md70 linesDownload Raw Back to ComInterop
1# ComInterop2 3The ComInterop code shipped in PowerShell comes from [dotnet/runtime](https://github.com/dotnet/runtime) with _a considerable amount of refactoring work_ to make it work properly with PowerShell.4 5> **NOTE: Do not modify the ComInterop code unless for fixing a bug. We want to keep minimal diffs when comparing with the .NET 5.0 ComInterop code base.**6 7There are 3 sources of the ComInterop code as our references:8 91. [The .NET Framework version](https://github.com/IronLanguages/main/tree/ipy-2.7-maint/Runtime/Microsoft.Dynamic/ComInterop).10   The code was archived in 2012.11 122. [The .NET 5.0 version](https://github.com/dotnet/runtime/tree/master/src/libraries/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/ComInterop).13   It was merged into .NET 5.0 in May 2020 through the PR [dotnet/runtime#33060](https://github.com/dotnet/runtime/pull/33060).14   It's based on the .NET Framework version code with quite amount of refactoring work.15 163. [The legacy ComInterop code from Windows PowerShell](https://github.com/PowerShell/PowerShell/tree/v7.0.0/src/System.Management.Automation/engine/ComInterop).17   The legacy code has always been in the repository, but it was excluded from compilation.18   It was based on the .NET Framework version code with a considerable amount of refactoring work to make it work properly with Windows PowerShell.19 20## Code Refreshing21 22The ComInterop code was refreshed and enabled in compilation in PowerShell 7.1, August 2020.23It was done manually by:24 25- A careful **three-way comparison** across all the code sources listed above:26  - Compare (3) to (1) to get the PowerShell specific changes27  - Compare (2) to (1) to get the .NET 5.0 changes28 29- Applying the PowerShell specific changes from (3) to (2), with necessary further refactoring30 31- A careful review of the new PowerShell specific changes applied to (2), again using the three-way comparison:32  - Compare the refreshed ComInterop code with (3) to get the differences33  - Analyze the differences to make sure they are either the pure .NET 5.0 changes over the .NET Framework code,34    or the refactoring changes that is necessary to apply the PowerShell specific changes.35 36## Code Layout Changes37 38The major changes in code layout are recorded below.39 40### Removed Source Files41 42The following source files that existed in (1) and (3) were removed in (2):43 44```none45ComDispIds.cs46ComEventSink.cs47ComEventSinkProxy.cs48ComParamDesc.cs49ComType.cs50ComTypeLibInfo.cs51ComTypeLibMemberDesc.cs52TypeLibInfoMetaObject.cs53```54 55I examined them all and it was mainly a clean-up work done in .NET 5.0:56 57- The code in `ComParamDesc.cs`, `ComType.cs`, `ComTypeLibInfo.cs`, `ComTypeLibMemberDesc.cs` and `TypeLibInfoMetaObject.cs`58  are not used or not needed, and thus removed.59- The code in `ComDispIds.cs`, `ComEventSink.cs` and `ComEventSinkProxy.cs` were moved or refactored to different files.60 61### New Source Files62 63Some source files were refactored and moved to the `System.Runtime.InteropServices` namespace in .NET 5.0,64they can be found [here](https://github.com/dotnet/runtime/tree/master/src/libraries/Common/src/System/Runtime/InteropServices).65In PowerShell, the corresponding source files are placed under `engine\ComInterop\InteropServices`.66 67Additionally, `ComEventsSink.Extended.cs` and `Variant.Extended.cs` under `engine\ComInterop` are new in .NET 5.0.68Combined with the files `ComEventsSink.cs` and `Variant.cs` under `engine\ComInterop\InteropServices`,69they are the refactored replacement of the old `ComEventSink.cs`, `ComEventSinkProxy.cs` and `Variant.cs` files in .NET Framework.70