Skip to content

Commit

Permalink
Merge pull request #309 from microsoft/consumeDocsFromMetadataRepo
Browse files Browse the repository at this point in the history
Consume API docs from win32metadata
  • Loading branch information
AArnott committed Jun 25, 2021
2 parents 690e31d + 5d452d7 commit 778ebaa
Show file tree
Hide file tree
Showing 24 changed files with 278 additions and 1,140 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<MetadataVersion>10.2.84-preview</MetadataVersion>
<ApiDocsVersion>0.1.4-alpha</ApiDocsVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3" PrivateAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.10.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.216" PrivateAssets="all" />
Expand Down
7 changes: 0 additions & 7 deletions Microsoft.Windows.CsWin32.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.CsWin32.Tests", "test\Microsoft.Windows.CsWin32.Tests\Microsoft.Windows.CsWin32.Tests.csproj", "{0129FE6E-3480-408A-BF40-9E6343CDB06C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScrapeDocs", "src\ScrapeDocs\ScrapeDocs.csproj", "{EB7D0834-4236-408F-B172-64FB45FF643A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win32MetaGeneration", "src\Win32MetaGeneration\Win32MetaGeneration.csproj", "{6638957D-09ED-47C1-86B9-5D2DFD0FE625}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerationSandbox.Tests", "test\GenerationSandbox.Tests\GenerationSandbox.Tests.csproj", "{7E8A5179-F94C-410F-8BBE-FDAAA95A19C3}"
Expand All @@ -55,10 +53,6 @@ Global
{0129FE6E-3480-408A-BF40-9E6343CDB06C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0129FE6E-3480-408A-BF40-9E6343CDB06C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0129FE6E-3480-408A-BF40-9E6343CDB06C}.Release|Any CPU.Build.0 = Release|Any CPU
{EB7D0834-4236-408F-B172-64FB45FF643A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EB7D0834-4236-408F-B172-64FB45FF643A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EB7D0834-4236-408F-B172-64FB45FF643A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EB7D0834-4236-408F-B172-64FB45FF643A}.Release|Any CPU.Build.0 = Release|Any CPU
{6638957D-09ED-47C1-86B9-5D2DFD0FE625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6638957D-09ED-47C1-86B9-5D2DFD0FE625}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6638957D-09ED-47C1-86B9-5D2DFD0FE625}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -78,7 +72,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{E3E96466-44B6-41AF-BBC8-9D30183ED8A9} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
{0129FE6E-3480-408A-BF40-9E6343CDB06C} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
{EB7D0834-4236-408F-B172-64FB45FF643A} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
{6638957D-09ED-47C1-86B9-5D2DFD0FE625} = {9E154A29-1796-4B85-BD81-B6A385D8FF71}
{7E8A5179-F94C-410F-8BBE-FDAAA95A19C3} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
{744BE74F-8C4A-49E8-9683-52D987224285} = {36CCE840-6FE5-4DB9-A8D5-8CF3CB6D342A}
Expand Down
1 change: 0 additions & 1 deletion ext/sdk-api
Submodule sdk-api deleted from 4c1b7b
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "5.0.202",
"version": "5.0.301",
"rollForward": "patch",
"allowPrerelease": false
}
Expand Down
52 changes: 0 additions & 52 deletions src/Microsoft.Windows.CsWin32/ApiDetails.cs

This file was deleted.

35 changes: 24 additions & 11 deletions src/Microsoft.Windows.CsWin32/Docs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,45 @@ namespace Microsoft.Windows.CsWin32
using System.IO;
using System.Reflection;
using MessagePack;
using ScrapeDocs;
using Microsoft.Windows.SDK.Win32Docs;

internal class Docs
{
private static readonly Dictionary<string, Docs> DocsByPath = new Dictionary<string, Docs>(StringComparer.OrdinalIgnoreCase);

private readonly Dictionary<string, ApiDetails> apisAndDocs;

private Docs(Dictionary<string, ApiDetails> apisAndDocs)
{
this.apisAndDocs = apisAndDocs;
}

internal static Docs Instance { get; } = Create();

internal bool TryGetApiDocs(string apiName, [NotNullWhen(true)] out ApiDetails? docs) => this.apisAndDocs.TryGetValue(apiName, out docs);

private static Docs Create()
internal static Docs Get(string docsPath)
{
using Stream? docsStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ThisAssembly.RootNamespace + ".apidocs.msgpack");
if (docsStream is null)
lock (DocsByPath)
{
////return new Docs(new Dictionary<string, ApiDetails>());
throw new Exception("Documentation not found.");
if (DocsByPath.TryGetValue(docsPath, out Docs? existing))
{
return existing;
}
}

using FileStream docsStream = File.OpenRead(docsPath);
var data = MessagePackSerializer.Deserialize<Dictionary<string, ApiDetails>>(docsStream);
return new Docs(data);
var docs = new Docs(data);

lock (DocsByPath)
{
if (DocsByPath.TryGetValue(docsPath, out Docs? existing))
{
return existing;
}

DocsByPath.Add(docsPath, docs);
return docs;
}
}

internal bool TryGetApiDocs(string apiName, [NotNullWhen(true)] out ApiDetails? docs) => this.apisAndDocs.TryGetValue(apiName, out docs);
}
}

0 comments on commit 778ebaa

Please sign in to comment.