-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add unit tests for gladstone extension handling service. #78034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -28,7 +28,7 @@ private sealed class ExtensionFolder | |||
/// <summary> | |||
/// Lazily computed assembly loader for this particular folder. | |||
/// </summary> | |||
private readonly AsyncLazy<(IAnalyzerAssemblyLoaderInternal? assemblyLoader, Exception? extensionException)> _lazyAssemblyLoader; | |||
private readonly AsyncLazy<(IExtensionAssemblyLoader? assemblyLoader, Exception? extensionException)> _lazyAssemblyLoader; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to abstract out this type so we could test the varying things it could do with mocks.
@@ -43,52 +43,16 @@ public ExtensionFolder( | |||
_extensionMessageHandlerService = extensionMessageHandlerService; | |||
_lazyAssemblyLoader = AsyncLazy.Create(cancellationToken => | |||
{ | |||
#if NET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to the default impl of the extension loading service.
|
||
namespace Microsoft.CodeAnalysis.Extensions; | ||
|
||
/// <summary> | ||
/// Factory for creating instances of extension message handlers. | ||
/// </summary> | ||
internal interface IExtensionMessageHandlerFactory | ||
internal interface IExtensionMessageHandlerFactory : IWorkspaceService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
became a workspace service so we can override it in tests with our own version ot mock out exceptions it might through without actually loading assemblies and using reflection on them.
|
||
// Don't trap the error here. We want to validate that this crosses the ServiceHub boundary and is reported as | ||
// a real roslyn/gladstone error. | ||
string? fatalRpcErrorMessage = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the general pattern is that we capture if we're getting a fatal error (indicating a bug between gladstone and us), or an 'extension exception' (a supported part of the data contracts). The tests partition these to ensure we know what we should actually be throwing exceptions internally for, vs what we should be capturing and passing along as data.
Note: 'cancellation' is tested at all layers. As that is something we should throw (and not capture as an extnesion exception) but which should also not be a fatal rpc error.
No description provided.