I hereby claim:
- I am seeminglyscience on github.
- I am seeminglyscience (https://keybase.io/seeminglyscience) on keybase.
- I have a public key ASByLYoy3uC2073UIRtV7Wp4j0izqlOV_73_fJVoze_DJAo
To claim this, I am signing this object:
| import { EventEmitter } from 'events' | |
| var clr = require('clr'); | |
| var namespaces = clr.init({ assemblies: [ 'System.Management.Automation' ], global: false }); | |
| export function forEachClr (collection: any, callback: (item: any) => any) { | |
| let enumerator = collection.GetEnumerator(); | |
| while (enumerator.MoveNext()) callback(enumerator.Current) | |
| } |
| <# | |
| Simple script that forces all static methods of types made | |
| with PowerShell to be bound to the current runspace. If you | |
| are getting NullReference exceptions every now and then, this | |
| might fix it. | |
| I put this in my profile as a temporary workaround, I do not | |
| recommend adding this to a module. It uses a large amount of | |
| reflection and could be unpredictable. | |
| #> |
| using namespace System.Management.Automation.Language | |
| using namespace System.Collections.Generic | |
| using namespace System.Reflection | |
| # The current contents of the psm1 file would go here, including dot sourcing the class definition | |
| # files normally and exporting module members. | |
| # The rest can most likely be loaded into a function but I haven't tested it yet. It could also | |
| # use some cleaning up. | |
| $usingStatements = [List[UsingStatementAst]]::new() |
| # https://seeminglyscience.github.io/powershell/2017/04/13/cmdlet-creation-with-powershell | |
| using namespace System.Management.Automation | |
| using namespace System.Reflection | |
| [Cmdlet([VerbsDiagnostic]::Test, 'Cmdlet')] | |
| class TestCmdletCommand : PSCmdlet { | |
| [Parameter(ValueFromPipeline)] | |
| [object] | |
| $InputObject; |
I hereby claim:
To claim this, I am signing this object:
| if ($psEditor) { | |
| # Don't reference any files whose FullName match this regex. | |
| ${Exclude Files Regex} = '\\Release\\|\\\.vscode\\|build.*\.ps1|debugHarness\.ps1|\.psd1' | |
| # Get the PowerShellEditorServices assemblies. | |
| ${editor services assemblies} = [System.AppDomain]::CurrentDomain.GetAssemblies() | | |
| Where-Object Location -Match 'PowerShell.EditorServices.*.dll' | | |
| ForEach-Object -MemberName Location | |
| # Add some C# that essentially lets us add a hook to the event that is called when VSCode opens a file. | |
| Add-Type -Language CSharp -ReferencedAssemblies ${editor services assemblies} -WarningAction SilentlyContinue -TypeDefinition @' |