Repository navigation
Load analyzer satellite assemblies - #1223
Conversation
Analyzers support localized strings for titles, messages, descriptions, etc. through the `LocalizableString` types. The localized strings will generally end up in a set of "satellite" assemblies ending in .resources.dll, one per culture. For example, if your analyzer is in an assembly "MyAnalyzer" and you provided localized strings for French (e.g., the fr-FR culture) then the build will typically produce bin\Debug\MyAnalyzer.dll and bin\Debug\fr-FR\MyAnalyzer.resources.dll. However, we currently have no way to find these satellite assemblies when the CLR asks for them via the `AppDomain.AssemblyResolve` event, so we never actually output localized strings from analyzers. The fix is to simply look for the assemblies in culture-specific directories next to the analyzer.
|
@srivatsn @shyamnamboodiripad @mavasani @heejaechang @jmarolf @JohnHamby Could you take a look, please? |
|
Tests? |
|
|
There was a problem hiding this comment.
Should we overwrite the directory path only if this directory actually exists: Path.Combine(directoryPath, requestedAssemblyIdentity.CultureName); ? This we way we can fallback to the loadedAssembly directory if no such sub-folder exists.
There was a problem hiding this comment.
Additionally, is it also worth looking for sub-folder with name: "CultureInfo.GetCultureInfo(requestedAssemblyIdentity.CultureName)?.LCID"?
There was a problem hiding this comment.
But why would we fall back?
There was a problem hiding this comment.
On the LCID thing - will the CLR assembly resolution for normal contexts pick up a Japanese resource if it was in the 1041 directory for example? If so, yes we should look for the LCID directory - otherwise I don't think there'll be a scenario where the user will expect it.
There was a problem hiding this comment.
No, it will not automatically look in a 1041 directory. The probing logic is described here:
https://msdn.microsoft.com/en-us/library/15hyw9x3(v=vs.100).aspx
|
👍 |
|
For the sake of good design and testability, we need to separate the concept of an The |
Extract out the logic used by `AnalyzerFileReference.InMemoryAssemblyLoader` to guess where a given assembly might be located, and add a couple of unit tests.
|
After several attempts, I've decided there's no good way to really separate |
|
@jmarolf I've added tests. |
|
@tmeschter thanks! 👍 |
Load analyzer satellite assemblies
…sults Group and sort NuGet Dependency results
Analyzers support localized strings for titles, messages, descriptions,
etc. through the
LocalizableStringtypes. The localized strings willgenerally end up in a set of "satellite" assemblies ending in
.resources.dll, one per culture. For example, if your analyzer is in an
assembly "MyAnalyzer" and you provided localized strings for French
(e.g., the fr-FR culture) then the build will typically produce
bin\Debug\MyAnalyzer.dll and bin\Debug\fr-FR\MyAnalyzer.resources.dll.
However, we currently have no way to find these satellite assemblies
when the CLR asks for them via the
AppDomain.AssemblyResolveevent, sowe never actually output localized strings from analyzers. The fix is to
simply look for the assemblies in culture-specific directories next to
the analyzer.