| external help file | Module Name | online version | schema |
|---|---|---|---|
PSTextMate.dll-Help.xml |
TextMate |
2.0.0 |
Renders C# source code using TextMate grammars and returns a PSTextMate.Core.HighlightedText object. Use for previewing or formatting C# snippets and files.
Format-CSharp [-InputObject] <psobject> [-Theme <ThemeName>] [-LineNumbers] [<CommonParameters>]
This cmdlet has the following aliases, fcs
Format-CSharp renders C# input using the TextMate grammar for C#. Input can be provided as objects (strings) via the pipeline or by passing file contents.
The cmdlet produces a HighlightedText object suitable for rendering to console.
Use -Theme to select a visual theme and -LineNumbers to include line numbers in the output.
Example: highlight a C# snippet from the pipeline
"public class C { void M() {} }" | Format-CSharp
Example: format a file and include line numbers
Get-Content .\src\Program.cs -Raw | Format-CSharp -LineNumbers
Example: Pipe FileInfo objects
Get-ChildItem *.cs | Format-CSharp -Theme SolarizedDark
Accepts a string or object containing source code.
When receiving pipeline input, the cmdlet treats the value as source text.
For file processing, pass the file contents (for example with Get-Content -Raw).
FileInfo objects are also accepted
Type: PSObject
DefaultValue: ''
SupportsWildcards: false
Aliases:
- FullName
- Path
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''When specified, include line numbers in the rendered output to aid reference and diffs.
Type: SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Selects a TextMateSharp.Grammars.ThemeName to use when rendering. If omitted, the module default theme is used.
Type: TextMateSharp.Grammars.ThemeName
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Accepts any object that can be converted to or contains a code string; commonly a string produced by Get-Content -Raw or piped literal text.
Returns a HighlightedText object which contains the tokenized and styled representation of the input. This object is intended for rendering to consoles or for downstream processing.
This cmdlet uses TextMate grammars packaged with the module. For large files consider streaming the contents or increasing process memory limits.
See also Format-PowerShell and Format-Markdown for other language renderers.