Document how to access reference assemblies from Roslyn
- Dominant language
- No language data
- Stars
- 4.8k
- Forks
- 6.1k
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 370
Description
**Describe the new topic**
- Explain why this topic is needed.
One pitfall when using Roslyn is how to find assemblies to reference.
In simple cases on .Net Framework and recent versions of .Net Core (2.0+, I think), referencing runtime assemblies can work (e.g. `MetadataReference.CreateFromFile(typeof(object).Assembly.Location)`).
In more complicated cases, I believe the right solution is to use `DependencyContext`, following this guide: https://github.com/dotnet/core/issues/2082#issuecomment-442713181. But because that is far from obvious, I believe it should be documented in a much more prominent location than a comment on a GitHub issue.
- Suggest a location in the Table of Contents.
Somewhere in [".NET Compiler Platform SDK"](https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/). Possibly under "Tutorials"?
- Write an abstract. In one **short** paragraph, describe what this topic will cover.
It should explain why reference assemblies are useful (probably linking to the article suggested in https://github.com/dotnet/docs/issues/2638, if it exists) and then describe how to take advantage of them by using ``, `Microsoft.Extensions.DependencyModel` and `DependencyContext` together with Roslyn `Compilation`.
- Create an outline for the new topic. We'll help review the outline and approve it before anyone writes a topic.
* Intro to reference assemblies when it comes to Roslyn.
* How to reference runtime assemblies. (?)
* How to reference reference assemblies.
**Help us make content visible**
- Tell us what search terms you used and how you searched docs.
The people that should be directed to this potential document are those that find that their Roslyn Compilation does not work (e.g. they get an error when loading the emitted assembly, because it was not actually emitted: https://github.com/dotnet/roslyn/issues/27783#issuecomment-397164483). If they look more closely, they find diagnostic errors such as "CS0012: The type 'Object' is defined in an assembly that is not referenced": https://github.com/dotnet/roslyn/issues/27783#issuecomment-397496206.
(The linked issue is just one, but I've seen others have this issue, e.g. https://github.com/dotnet/core/issues/2082.)
So I think it would be great if this article showed up when searching for these errors. And also some more general queries, like "roslyn references".
cc: @BillWagner
Contributor guide
Assessment
This issue has not been assessed yet.