CSharpEditor
1.1.2
A C# source code editor with syntax highlighting, intelligent code completion and real-time compilation error checking
|
A C# source code editor for Avalonia. More...
Public Types | |
enum | AccessTypes { AccessTypes.ReadWrite, AccessTypes.ReadOnlyWithHistoryAndErrors, AccessTypes.ReadOnly } |
Describes the actions that the user can perform on the code. More... | |
Public Member Functions | |
Editor () | |
Public constructor. This is only provided for compatibility with Avalonia (see issue #2593). Please use Editor.Create instead. More... | |
async Task | SetText (string text) |
Sets the text of the document. More... | |
async Task | SetText (SourceText text) |
Sets the text of the document. More... | |
bool | SynchronousBreak (BreakpointInfo info) |
A function to handle breakpoints in synchronous methods. Pass this as an argument to Compile(Func<BreakpointInfo, bool>, Func<BreakpointInfo, Task<bool>>). To prevent deadlocks, this function will have no effect if called from the UI thread. More... | |
async Task< bool > | AsynchronousBreak (BreakpointInfo info) |
A function to handle breakpoints in asynchronous methods. Pass this as an argument to Compile(Func<BreakpointInfo, bool>, Func<BreakpointInfo, Task<bool>>). More... | |
async Task<(Assembly Assembly, CSharpCompilation Compilation)> | Compile (Func< BreakpointInfo, bool > synchronousBreak=null, Func< BreakpointInfo, Task< bool >> asynchronousBreak=null) |
Compile the source code to an Assembly. More... | |
async Task< CSharpCompilation > | CreateCompilation () |
Compile the source code to a CSharpCompilation. Note that breakpoints will be disabled. More... | |
void | Save () |
Add the current text of the document to the save history (if enabled) and invoke the SaveRequested event. More... | |
Static Public Member Functions | |
static async Task< Editor > | Create (string initialText="", string preSource="", string postSource="", IEnumerable< CachedMetadataReference > references=null, CSharpCompilationOptions compilationOptions=null, string guid=null, Shortcut[] additionalShortcuts=null) |
Create a new Editor instance. More... | |
Public Attributes | |
SyntaxHighlightingModes | SyntaxHighlightingMode => this.EditorControl.SyntaxHighlightingMode |
The current syntax highlighting mode. More... | |
bool | ShowLineChanges => this.EditorControl.ShowLineChanges |
A boolean value indicating whether changed lines are highlighted on the left side of the control. More... | |
bool | ShowScrollbarOverview => this.EditorControl.ShowScrollbarOverview |
A boolean value indicating whether a summary of the changed lines, errors/warning, search results, breakpoints and the position of the caret should be shown over the vertical scrollbar. More... | |
int | AutosaveInterval => this.AutoSaver.MillisecondsInterval |
The timeout between consecutive autosaves, in milliseconds. More... | |
int | CompilationTimeout => this.CompilationErrorChecker.MillisecondsInterval |
The timeout for automatic compilation after the user stops typing, in milliseconds. More... | |
Properties | |
EventHandler< EventArgs > | TextChanged |
Event raised when the document text is changed. More... | |
string | PreSource [get] |
Source code to be prepended to the text of the document when compiling it. More... | |
string | PostSource = "" [get] |
Source code to be appended after the text of the document when compiling it. More... | |
string | Text [get] |
The source code of the document as a string. More... | |
SourceText | SourceText [get] |
The source code of the document as a SourceText. More... | |
string | FullSource [get] |
Full source code, including the PreSource, the Text, and the PostSource. More... | |
AccessTypes | AccessType [get, set] |
Determines whether the text of the document can be edited by the user. More... | |
CSharpCompilationOptions | CompilationOptions [get] |
Compilation options used to compile the source code. More... | |
string | Guid [get] |
A unique identifier for the document being edited. More... | |
string | SaveDirectory [get] |
The full path to the directory where the autosave file and the save history for the current document are kept. More... | |
string | AutoSaveFile [get] |
The full path to the autosave file. More... | |
bool | KeepSaveHistory = true [get] |
A boolean value indicating whether a history of the saved versions of the document is kept. More... | |
bool | AutoOpenSuggestions = true [get] |
A boolean value indicating whether the suggestion panel should open automatically while the user is typing. More... | |
bool | AutoOpenParameters = true [get] |
A boolean value indicating whether the parameter list tooltip should open automatically while the user is typing. More... | |
bool | AutoFormat = true [get] |
A boolean value indicating whether the source text should be formatted automatically while the user is typing. More... | |
ImmutableList< MetadataReference > | References [get] |
The list of MetadataReferences for which the compiled assembly will have bindings. More... | |
bool | IsReferencesButtonEnabled [get, set] |
A boolean value indicating whether the button allowing the user to add or remove assembly references is enabled or not. More... | |
TextSpan | Selection [get, set] |
Gets or sets the selected text span. More... | |
Events | |
EventHandler< SaveEventArgs > | SaveRequested |
Event raised when the user uses the keyboard shortcut or pressed the button to save the document. More... | |
EventHandler< SaveEventArgs > | Autosave |
Event raised when the document is automatically saved. More... | |
EventHandler< CompilationEventArgs > | CompilationCompleted |
Event raised when a background compilation of the document completes. More... | |
A C# source code editor for Avalonia.
Definition at line 43 of file Editor.axaml.cs.
|
strong |
Describes the actions that the user can perform on the code.
Definition at line 138 of file Editor.public.cs.
CSharpEditor.Editor.Editor | ( | ) |
Public constructor. This is only provided for compatibility with Avalonia (see issue #2593). Please use Editor.Create instead.
Definition at line 133 of file Editor.axaml.cs.
async Task<bool> CSharpEditor.Editor.AsynchronousBreak | ( | BreakpointInfo | info | ) |
A function to handle breakpoints in asynchronous methods. Pass this as an argument to Compile(Func<BreakpointInfo, bool>, Func<BreakpointInfo, Task<bool>>).
info | A BreakpointInfo object containing information about the location of the breakpoint and the current value of local variables. |
Definition at line 452 of file Editor.public.cs.
async Task<(Assembly Assembly, CSharpCompilation Compilation)> CSharpEditor.Editor.Compile | ( | Func< BreakpointInfo, bool > | synchronousBreak = null , |
Func< BreakpointInfo, Task< bool >> | asynchronousBreak = null |
||
) |
Compile the source code to an Assembly.
synchronousBreak | The function to handle synchronous breakpoints. If this is null , these breakpoints will be skipped. If you want to enable the default UI for breakpoints, use SynchronousBreak(BreakpointInfo) (or a function that calls it after performing additional operations). |
asynchronousBreak | The function to handle asynchronous breakpoints. If this is null , these breakpoints will be skipped. If you want to enable the default UI for breakpoints, use AsynchronousBreak(BreakpointInfo) (or a function that calls it after performing additional operations). |
null
if the compilation fails, as well as a CSharpCompilation that also contains information about any compilation errors.Definition at line 563 of file Editor.public.cs.
|
static |
Create a new Editor instance.
initialText | The initial text of the editor. |
preSource | The source code that should be prepended to the text of the document when compiling it. |
postSource | The source code that should be appended to the text of the document when compiling it. |
references | A list of MetadataReferences for which the compiled assembly will have bindings. Make sure to include an appropriate DocumentationProvider, if you would like documentation comments to appear in code completion windows. If this is null , references to all of the assemblies loaded in the current AppDomain will be added. |
compilationOptions | The compilation options used to compile the code. If this is null , a new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary) will be used. |
guid | A unique identifier for the document being edited. If this is null , a new System.Guid is generated. If the same identifier is used multiple times, the save history of the document will be available, even if the application has been closed between different sessions. |
additionalShortcuts | Additional application-specific shortcuts (for display purposes only - you need to implement your own logic). |
Definition at line 328 of file Editor.public.cs.
async Task<CSharpCompilation> CSharpEditor.Editor.CreateCompilation | ( | ) |
Compile the source code to a CSharpCompilation. Note that breakpoints will be disabled.
Emit
an assembly.Definition at line 701 of file Editor.public.cs.
void CSharpEditor.Editor.Save | ( | ) |
Add the current text of the document to the save history (if enabled) and invoke the SaveRequested event.
Definition at line 729 of file Editor.public.cs.
async Task CSharpEditor.Editor.SetText | ( | SourceText | text | ) |
Sets the text of the document.
text | The new text of the document. |
Definition at line 394 of file Editor.public.cs.
async Task CSharpEditor.Editor.SetText | ( | string | text | ) |
Sets the text of the document.
text | The new text of the document. |
Definition at line 384 of file Editor.public.cs.
bool CSharpEditor.Editor.SynchronousBreak | ( | BreakpointInfo | info | ) |
A function to handle breakpoints in synchronous methods. Pass this as an argument to Compile(Func<BreakpointInfo, bool>, Func<BreakpointInfo, Task<bool>>). To prevent deadlocks, this function will have no effect if called from the UI thread.
info | A BreakpointInfo object containing information about the location of the breakpoint and the current value of local variables. |
true
if further occurrences of the same breakpoint should be ignored; false
otherwise.Definition at line 405 of file Editor.public.cs.
int CSharpEditor.Editor.AutosaveInterval => this.AutoSaver.MillisecondsInterval |
The timeout between consecutive autosaves, in milliseconds.
Definition at line 260 of file Editor.public.cs.
int CSharpEditor.Editor.CompilationTimeout => this.CompilationErrorChecker.MillisecondsInterval |
The timeout for automatic compilation after the user stops typing, in milliseconds.
Definition at line 265 of file Editor.public.cs.
bool CSharpEditor.Editor.ShowLineChanges => this.EditorControl.ShowLineChanges |
A boolean value indicating whether changed lines are highlighted on the left side of the control.
Definition at line 250 of file Editor.public.cs.
bool CSharpEditor.Editor.ShowScrollbarOverview => this.EditorControl.ShowScrollbarOverview |
A boolean value indicating whether a summary of the changed lines, errors/warning, search results, breakpoints and the position of the caret should be shown over the vertical scrollbar.
Definition at line 255 of file Editor.public.cs.
SyntaxHighlightingModes CSharpEditor.Editor.SyntaxHighlightingMode => this.EditorControl.SyntaxHighlightingMode |
The current syntax highlighting mode.
Definition at line 245 of file Editor.public.cs.
|
getset |
Determines whether the text of the document can be edited by the user.
Definition at line 161 of file Editor.public.cs.
|
get |
A boolean value indicating whether the source text should be formatted automatically while the user is typing.
Definition at line 240 of file Editor.public.cs.
|
get |
A boolean value indicating whether the parameter list tooltip should open automatically while the user is typing.
Definition at line 235 of file Editor.public.cs.
|
get |
A boolean value indicating whether the suggestion panel should open automatically while the user is typing.
Definition at line 230 of file Editor.public.cs.
|
get |
The full path to the autosave file.
Definition at line 220 of file Editor.public.cs.
|
get |
Compilation options used to compile the source code.
Definition at line 205 of file Editor.public.cs.
|
get |
Full source code, including the PreSource, the Text, and the PostSource.
Definition at line 126 of file Editor.public.cs.
|
get |
A unique identifier for the document being edited.
Definition at line 210 of file Editor.public.cs.
|
getset |
A boolean value indicating whether the button allowing the user to add or remove assembly references is enabled or not.
Definition at line 277 of file Editor.public.cs.
|
get |
A boolean value indicating whether a history of the saved versions of the document is kept.
Definition at line 225 of file Editor.public.cs.
|
get |
Source code to be appended after the text of the document when compiling it.
Definition at line 97 of file Editor.public.cs.
|
get |
Source code to be prepended to the text of the document when compiling it.
Definition at line 80 of file Editor.public.cs.
|
get |
The list of MetadataReferences for which the compiled assembly will have bindings.
Definition at line 270 of file Editor.public.cs.
|
get |
The full path to the directory where the autosave file and the save history for the current document are kept.
Definition at line 215 of file Editor.public.cs.
|
getset |
Gets or sets the selected text span.
Definition at line 304 of file Editor.public.cs.
|
get |
The source code of the document as a SourceText.
Definition at line 114 of file Editor.public.cs.
|
get |
The source code of the document as a string.
Definition at line 102 of file Editor.public.cs.
|
addremove |
Event raised when the document text is changed.
Definition at line 62 of file Editor.public.cs.
EventHandler<SaveEventArgs> CSharpEditor.Editor.Autosave |
Event raised when the document is automatically saved.
Definition at line 52 of file Editor.public.cs.
EventHandler<CompilationEventArgs> CSharpEditor.Editor.CompilationCompleted |
Event raised when a background compilation of the document completes.
Definition at line 57 of file Editor.public.cs.
EventHandler<SaveEventArgs> CSharpEditor.Editor.SaveRequested |
Event raised when the user uses the keyboard shortcut or pressed the button to save the document.
Definition at line 47 of file Editor.public.cs.