-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
71 additions
and
16 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/Passingwind.Abp.ElsaModule.ElsaExtensions/CSharpEditorOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Passingwind.Abp.ElsaModule; | ||
|
||
public class CSharpEditorOptions | ||
{ | ||
public bool EnableCodeAnalysis { get; set; } | ||
public bool EnableCompletion { get; set; } = true; | ||
public bool EnableHoverInfo { get; set; } = true; | ||
public bool EnableSignatures { get; set; } = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 30 additions & 12 deletions
42
src/Passingwind.CSharpScript/CSharpScriptMetadataReferenceResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,54 @@ | ||
using System; | ||
/* | ||
* https://github.com/dotnet-script/dotnet-script/blob/master/src/Dotnet.Script.DependencyModel.Nuget/NuGetMetadataReferenceResolver.cs | ||
*/ | ||
|
||
using System; | ||
using System.Collections.Immutable; | ||
using System.Reflection; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.Scripting; | ||
|
||
namespace Passingwind.CSharpScriptEngine; | ||
|
||
public class CSharpScriptMetadataReferenceResolver : MetadataReferenceResolver | ||
/// <summary> | ||
/// A <see cref="MetadataReferenceResolver"/> decorator that handles | ||
/// references to NuGet packages in scripts. | ||
/// </summary> | ||
public class NuGetMetadataReferenceResolver : MetadataReferenceResolver | ||
{ | ||
public static CSharpScriptMetadataReferenceResolver Instance { get; } = new CSharpScriptMetadataReferenceResolver(ScriptMetadataResolver.Default); | ||
public static NuGetMetadataReferenceResolver Instance { get; } = new NuGetMetadataReferenceResolver(ScriptMetadataResolver.Default); | ||
|
||
private readonly ScriptMetadataResolver _resolver; | ||
private readonly MetadataReferenceResolver _metadataReferenceResolver; | ||
|
||
public CSharpScriptMetadataReferenceResolver(ScriptMetadataResolver resolver) | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NuGetMetadataReferenceResolver"/> class. | ||
/// </summary> | ||
/// <param name="metadataReferenceResolver">The target <see cref="MetadataReferenceResolver"/>.</param> | ||
public NuGetMetadataReferenceResolver(MetadataReferenceResolver metadataReferenceResolver) | ||
{ | ||
_resolver = resolver; | ||
_metadataReferenceResolver = metadataReferenceResolver; | ||
} | ||
|
||
public override bool Equals(object? other) => _resolver.Equals(other); | ||
public override bool Equals(object? other) | ||
{ | ||
return _metadataReferenceResolver.Equals(other); | ||
} | ||
|
||
public override int GetHashCode() => _resolver.GetHashCode(); | ||
public override int GetHashCode() | ||
{ | ||
return _metadataReferenceResolver.GetHashCode(); | ||
} | ||
|
||
public override ImmutableArray<PortableExecutableReference> ResolveReference(string reference, string? baseFilePath, MetadataReferenceProperties properties) | ||
{ | ||
// #r nuget: | ||
if (reference.StartsWith("nuget", StringComparison.OrdinalIgnoreCase)) | ||
if (reference.StartsWith("nuget", StringComparison.OrdinalIgnoreCase) || reference.StartsWith("sdk", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
// HACK We need to return something here to "mark" the reference as resolved. | ||
// https://github.com/dotnet/roslyn/blob/master/src/Compilers/Core/Portable/ReferenceManager/CommonReferenceManager.Resolution.cs#L838 | ||
return ImmutableArray<PortableExecutableReference>.Empty.Add(MetadataReference.CreateFromFile(typeof(CSharpScriptMetadataReferenceResolver).GetTypeInfo().Assembly.Location)); | ||
return ImmutableArray<PortableExecutableReference>.Empty.Add( | ||
MetadataReference.CreateFromFile(typeof(NuGetMetadataReferenceResolver).GetTypeInfo().Assembly.Location)); | ||
} | ||
|
||
return _resolver.ResolveReference(reference, baseFilePath, properties); | ||
return _metadataReferenceResolver.ResolveReference(reference, baseFilePath, properties); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters