Types/OpenPackage.Part/ReadCSharp.ps1
|
<# .SYNOPSIS Reads Part Content as CSharp .DESCRIPTION Reads Package Part Content as CSharp code #> [Reflection.AssemblyMetadata( # This should automatically apply to .cs files 'FilePattern', '\.cs$' )] param( # An optional input object # If provided, content will be read from this object. # If not provided, content will be read from this part. [Alias('Input')] [PSObject]$InputObject = $null, # Any options used to read the data. [Alias('Options')] [Collections.IDictionary]$Option = [Ordered]@{} ) if (-not $this.ReadText) { return } $partString = $this.ReadText($inputObject, $option) $null = Add-Type -AssemblyName Microsoft.CodeAnalysis.CSharp -PassThru if ('Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree' -as [Type]) { $partString | Add-Member NoteProperty SyntaxTree ( [Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree]::ParseText($partString) ) -Force -PassThru } else { $partString } |