Skip to content

Repair XREF gen tool - #671

Closed
guardrex wants to merge 4 commits into
mainfrom
guardrex/xref-gen-tool-repair
Closed

guardrex wants to merge 4 commits into
mainfrom
guardrex/xref-gen-tool-repair

Conversation

@guardrex

@guardrex guardrex commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #670

CORSPROXY was being used with an open access link (https://corsproxy.io/?{ENCODED URL}) to hit up the API docs web API for exact ms.assetid values to determine the XREF links ...

var encodedUrl = WebUtility.UrlEncode($"https://learn.microsoft.com/en-us{result.Url}?view={dotNetVersion}");
using var request = new HttpRequestMessage(HttpMethod.Get, $"https://corsproxy.io/?{encodedUrl}");

Now, CORSPROXY only allows use of their API/NuGet pkg, which requires the API key to be in the app. This is a Blazor WebAssembly app, so it can't keep a secure key. Therefore, I'm going to just hack up a little Regex here to form the links on the fly. Testing seems ok locally, and we'll see how it goes. Please message me any bugs/errors that the build system throws from XREF links generated by the tool. If that occurs, I'll seek to improve the tool's logic.

UPDATE ... Copilot really went ALL IN with the ReplaceGenericArity method here. 😄 That should deal with the type placeholders for API like Dictionary<TKey, TValue>, which should resolve to a link of <xref:...Dictionary%602> (not %601 for a single type). Again, we'll see how things go. Proxying was best because it would get the actual link descriptor from the API docs system without having to jump through hoops. If this manual approach doesn't work out down the road, I'm going to try and find a CORSPROXY alternative.

@guardrex guardrex self-assigned this Sep 22, 2026

This comment was marked as resolved.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: guardrex <1622880+guardrex@users.noreply.github.com>

This comment was marked as low quality.

@guardrex
guardrex requested review from tdykstra and wadepickett and removed request for tdykstra and wadepickett September 22, 2026 14:47
@guardrex

Copy link
Copy Markdown
Contributor Author

@ilonatommy @oroztocil @dariatiurina ... Are any of you free for a quick approval here? I'll be chatting with DR soon about how we'll get docs PR approvals. Until then ... hopefully just for a day or two ... I'll need a little help getting docs PRs wrapped up and merged.

}
}

builder.Append($"%60{arity}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for generic methods as well? Isn't the convention there to use two backticks rather than one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be right about it failing in that case. Copilot generated the method, and I'm just trying to quickly get the tool back online.

I'll check on how the API Browser expects the links for generic methods and get back to you.


if (result.ItemType == "Constructor")
{
result.Link = Regex.Replace(result.DisplayName, @"\(.*\)", ".%23ctor%2A");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this produce the correct string for a constructor? Isn't there an extra name in the result? (copilot flagged this before in the PR)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Copilot is incorrect. Consider ControllerBase's ctor. It shows up as ...

image

Therefore, I don't think it has an extra name in the result. Funny thing is that we have ZERO live ctors cross-linked in our almost 900 articles at this time, so I don't have a live example to check to know 100% for sure.

Correction: We do have live ctors ... my first filter didn't catch them. I've confirmed it: There are no double names in the links. For example ...

<xref:Microsoft.Extensions.Localization.ResourceManagerStringLocalizer.%23ctor%2A?displayProperty=nameWithType>

... at ...

https://learn.microsoft.com/en-us/aspnet/core/breaking-changes/5/localization-pubternal-apis-removed?view=aspnetcore-10.0#affected-apis

... correctly resolves to a cross-link that loads the API Browser to the ctor at ...

https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.localization.resourcemanagerstringlocalizer.-ctor?view=net-11.0-pp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the explanation.

@guardrex

Copy link
Copy Markdown
Contributor Author

I'm going to close this and look for anther public CORS proxy service.

When I checked HttpLogEnricher, I found this ...

image

... but the tool produced ...

image

@guardrex guardrex closed this Sep 24, 2026
@guardrex
guardrex deleted the guardrex/xref-gen-tool-repair branch September 24, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repair XREF gen tool

4 participants