Skip to content

Add docs for Microsoft.Extensions.DependencyModel.Library and subclasses #8327

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

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using Microsoft.Extensions.DependencyModel;

namespace CompilationLibrarySnippets
{
static class CompilationLibrarySnippets
{
public static void SnippetPrintLibraries()
{
//<SnippetPrintLibraries>
foreach (CompilationLibrary lib in DependencyContext.Default.CompileLibraries)
{
Console.WriteLine($"Library: {lib.Name} {lib.Version}");
Console.WriteLine($"Type: {lib.Type}");
Console.WriteLine("Reference paths:");

foreach (string path in lib.ResolveReferencePaths())
{
Console.WriteLine(path);
}
}
//</SnippetPrintLibraries>
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace CompilationLibrarySnippets
{
class Program
{
static void Main()
{
CompilationLibrarySnippets.SnippetPrintLibraries();
}
}
}
80 changes: 53 additions & 27 deletions xml/Microsoft.Extensions.DependencyModel/CompilationLibrary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,22 @@
</Base>
<Interfaces />
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
<summary>Represents a compile time library dependency in a dependency manifest.</summary>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks

A compile time library dependency is a library used to compile an application. It can be a [reference assembly](/dotnet/standard/assembly/reference-assemblies) or an implementation assembly. You can use the <xref:Microsoft.Extensions.DependencyModel.DependencyContext.CompileLibraries> property to get the list of compile time library dependencies for a dependency context. This is useful when you need to dynamically compile code (for example, using Roslyn Emit API) referencing the same dependencies as your main application.

## Examples

The following example shows how to display the list of libraries used to compile the current application. Include `<PreserveCompilationContext>true</PreserveCompilationContext>` in your project file to run this example.

:::code language="csharp" source="~/snippets/csharp/Microsoft.Extensions.DependencyModel/CompilationLibrary/Overview/CompilationLibrarySnippets.cs" id="SnippetPrintLibraries":::

]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
Expand Down Expand Up @@ -45,15 +59,19 @@
<Parameter Name="serviceable" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="type">To be added.</param>
<param name="name">To be added.</param>
<param name="version">To be added.</param>
<param name="hash">To be added.</param>
<param name="assemblies">To be added.</param>
<param name="dependencies">To be added.</param>
<param name="serviceable">To be added.</param>
<summary>To be added.</summary>
<param name="type">The library's type.</param>
<param name="name">The library's name.</param>
<param name="version">The library's version.</param>
<param name="hash">The library package's hash.</param>
<param name="assemblies">The library's assemblies.</param>
<param name="dependencies">The library's dependencies.</param>
<param name="serviceable">Whether the library is serviceable.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Extensions.DependencyModel.CompilationLibrary"/> class using the specified library properties.</summary>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="type" />, or <paramref name="name" />, or <paramref name="version" /> is <see langword="null" /> or an empty string.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="dependencies" /> or <paramref name="assemblies" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName=".ctor">
Expand Down Expand Up @@ -83,17 +101,21 @@
<Parameter Name="hashPath" Type="System.String" />
</Parameters>
<Docs>
<param name="type">To be added.</param>
<param name="name">To be added.</param>
<param name="version">To be added.</param>
<param name="hash">To be added.</param>
<param name="assemblies">To be added.</param>
<param name="dependencies">To be added.</param>
<param name="serviceable">To be added.</param>
<param name="path">To be added.</param>
<param name="hashPath">To be added.</param>
<summary>To be added.</summary>
<param name="type">The library's type.</param>
<param name="name">The library's name.</param>
<param name="version">The library's version.</param>
<param name="hash">The library package's hash.</param>
<param name="assemblies">The library's assemblies.</param>
<param name="dependencies">The library's dependencies.</param>
<param name="serviceable">Whether the library is serviceable.</param>
<param name="path">The library package's path.</param>
<param name="hashPath">The library package's hash path.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Extensions.DependencyModel.CompilationLibrary"/> class using the specified library properties and path.</summary>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="type" />, or <paramref name="name" />, or <paramref name="version" /> is <see langword="null" /> or an empty string.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="dependencies" /> or <paramref name="assemblies" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Assemblies">
Expand All @@ -114,8 +136,8 @@
<ReturnType>System.Collections.Generic.IReadOnlyList&lt;System.String&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the list of assemblies for this library.</summary>
<value>The list of assemblies for this library.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -138,9 +160,11 @@
</ReturnValue>
<Parameters />
<Docs>
<summary>To be added.</summary>
<returns>To be added.</returns>
<summary>Gets the collection of absolute reference paths for this library.</summary>
<returns>The collection of absolute reference paths for this library.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.InvalidOperationException">
Library location is not found.</exception>
</Docs>
</Member>
<Member MemberName="ResolveReferencePaths">
Expand Down Expand Up @@ -171,10 +195,12 @@
</Parameter>
</Parameters>
<Docs>
<param name="customResolvers">To be added.</param>
<summary>To be added.</summary>
<returns>To be added.</returns>
<param name="customResolvers">The array of custom assembly resolvers.</param>
<summary>Gets the collection of absolute reference paths for this library using specified custom resolvers.</summary>
<returns>The collection of absolute reference paths for this library.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.InvalidOperationException">
Library location is not found.</exception>
</Docs>
</Member>
</Members>
Expand Down
108 changes: 64 additions & 44 deletions xml/Microsoft.Extensions.DependencyModel/Library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</Base>
<Interfaces />
<Docs>
<summary>To be added.</summary>
<summary>Represents a library dependency in a dependency manifest.</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
Expand Down Expand Up @@ -44,13 +44,13 @@
<Parameter Name="serviceable" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="type">To be added.</param>
<param name="name">To be added.</param>
<param name="version">To be added.</param>
<param name="hash">To be added.</param>
<param name="dependencies">To be added.</param>
<param name="serviceable">To be added.</param>
<summary>To be added.</summary>
<param name="type">The library's type.</param>
<param name="name">The library's name.</param>
<param name="version">The library's version.</param>
<param name="hash">The library package's hash.</param>
<param name="dependencies">The library's dependencies.</param>
<param name="serviceable">Whether the library is serviceable.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Extensions.DependencyModel.Library"/> class using the specified library properties.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand Down Expand Up @@ -80,16 +80,20 @@
<Parameter Name="hashPath" Type="System.String" />
</Parameters>
<Docs>
<param name="type">To be added.</param>
<param name="name">To be added.</param>
<param name="version">To be added.</param>
<param name="hash">To be added.</param>
<param name="dependencies">To be added.</param>
<param name="serviceable">To be added.</param>
<param name="path">To be added.</param>
<param name="hashPath">To be added.</param>
<summary>To be added.</summary>
<param name="type">The library's type.</param>
<param name="name">The library's name.</param>
<param name="version">The library's version.</param>
<param name="hash">The library package's hash.</param>
<param name="dependencies">The library's dependencies.</param>
<param name="serviceable">Whether the library is serviceable.</param>
<param name="path">The library package's path.</param>
<param name="hashPath">The library package's hash path.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Extensions.DependencyModel.Library"/> class using the specified library properties and path.</summary>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="type" />, or <paramref name="name" />, or <paramref name="version" /> is <see langword="null" /> or an empty string.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="dependencies" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName=".ctor">
Expand Down Expand Up @@ -118,17 +122,21 @@
<Parameter Name="runtimeStoreManifestName" Type="System.String" />
</Parameters>
<Docs>
<param name="type">To be added.</param>
<param name="name">To be added.</param>
<param name="version">To be added.</param>
<param name="hash">To be added.</param>
<param name="dependencies">To be added.</param>
<param name="serviceable">To be added.</param>
<param name="path">To be added.</param>
<param name="hashPath">To be added.</param>
<param name="runtimeStoreManifestName">To be added.</param>
<summary>To be added.</summary>
<param name="type">The library's type.</param>
<param name="name">The library's name.</param>
<param name="version">The library's version.</param>
<param name="hash">The library package's hash.</param>
<param name="dependencies">The library's dependencies.</param>
<param name="serviceable">Whether the library is serviceable.</param>
<param name="path">The library package's path.</param>
<param name="hashPath">The library package's hash path.</param>
<param name="runtimeStoreManifestName">The library's runtime store manifest name.</param>
<summary>Initializes a new instance of the <see cref="T:Microsoft.Extensions.DependencyModel.Library"/> class using the specified library properties, path and runtime store manifest.</summary>
<remarks>To be added.</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="type" />, or <paramref name="name" />, or <paramref name="version" /> is <see langword="null" /> or an empty string.</exception>
<exception cref="T:System.ArgumentNullException">
<paramref name="dependencies" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="Dependencies">
Expand All @@ -149,8 +157,8 @@
<ReturnType>System.Collections.Generic.IReadOnlyList&lt;Microsoft.Extensions.DependencyModel.Dependency&gt;</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the list of dependencies of this library.</summary>
<value>The list of dependencies of this library.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -173,8 +181,8 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the hash of the package, if this library is a package.</summary>
<value>The hash of the package, if this library is a package.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -197,8 +205,8 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the relative path to the library package hash file, if this library is a package.</summary>
<value>The relative path to the library package hash file, if this library is a package.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -220,8 +228,8 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the library name.</summary>
<value>The library name.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -244,8 +252,8 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the relative path to package assets, if this library is a package.</summary>
<value>The relative path to package assets, if this library is a package.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand Down Expand Up @@ -291,8 +299,8 @@
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets a value that indicates whether this library can be serviced, if this library is a package.</summary>
<value><c>true</c> if this library can be serviced; otherwise, <c>false</c></value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand All @@ -314,9 +322,21 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<remarks>To be added.</remarks>
<summary>Gets the type of this library.</summary>
<value>The type of this library.</value>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks

The common library type values are:

- `package` - NuGet package
- `project` - Project reference
- `referenceassembly` - Reference assembly

]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Version">
Expand All @@ -337,8 +357,8 @@
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>To be added.</summary>
<value>To be added.</value>
<summary>Gets the version of this library.</summary>
<value>The version of this library.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
Expand Down
Loading