Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Find IDocumentProvider using a more-laborious process
Browse files Browse the repository at this point in the history
- `Type.GetType(string)` requires an assembly-qualified name and we don't know the assembly

nit:
- reflect recent change to `dotnet-getdocument`'s `Resources.resx` file in its designer file
  • Loading branch information
dougbu committed Oct 11, 2018
1 parent 5cd8697 commit d2d253d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/GetDocumentInsider/Commands/GetDocumentCommandWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,23 @@ public static bool TryProcess(GetDocumentCommandContext context, IServiceProvide

try
{
var serviceType = Type.GetType(serviceName, throwOnError: true);
Type serviceType = null;
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
serviceType = assembly.GetType(serviceName, throwOnError: false);
if (serviceType != null)
{
break;
}
}

if (serviceType == null)
{
// As part of the aspnet/Mvc#8425 fix, make this an error unless the file already exists.
Reporter.WriteWarning(Resources.FormatServiceNotFound(serviceName));
return true;
}

var method = serviceType.GetMethod(methodName, new[] { typeof(TextWriter), typeof(string) });
var service = services.GetRequiredService(serviceType);

Expand Down
14 changes: 14 additions & 0 deletions src/GetDocumentInsider/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/GetDocumentInsider/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,7 @@
<data name="MissingEntryPoint" xml:space="preserve">
<value>Assembly '{0}' does not contain an entry point.</value>
</data>
<data name="ServiceNotFound" xml:space="preserve">
<value>Unable to find service type '{0}' in loaded assemblies.</value>
</data>
</root>
4 changes: 2 additions & 2 deletions src/dotnet-getdocument/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d2d253d

Please sign in to comment.