Skip to content

Xref Gen tool updates #443

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 1 commit into from
Jan 13, 2025
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
48 changes: 33 additions & 15 deletions BlazorWebAssemblyXrefGenerator/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,33 @@
@using System.Text.RegularExpressions
@inject IHttpClientFactory ClientFactory

<div style="margin-bottom:15px">
<h1>Namespace/Member</h1>
<input id="searchText" @bind="searchText" class="form-control" aria-label="Search Text" />
<button type="button" @onclick="GetSearchResults" class="btn btn-primary">Search</button>
<button type="button" class="btn btn-secondary" onclick="document.getElementById('searchText').value=''">Clear</button>
</div>

<h1>Links</h1>
<EditForm Model="Model" OnSubmit="GetSearchResults" FormName="SearchForm">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Search</h3>
</div>
<div class="panel-body">
<div class="form-group">
<p>Provide a namespace, class, member, or <code>/dotnet/api/...</code> relative link.</p>
<InputText id="searchText" @bind-Value="Model!.SearchText" aria-label="Search Text" onfocus="this.value=''" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Search</button>
<button type="button" class="btn btn-secondary" onclick="document.getElementById('searchText').value=''">Clear</button>
</div>
</div>
</div>
</EditForm>

@if (SearchResultItems?.Results?.Count() > 0)
{
<ol>
<ol style="margin-top:20px">
@foreach (var result in SearchResultItems.Results.Select((x, i) => new { Data = x, Index = i }))
{
<li style="margin-bottom:5px">
<div style="font-size:1.4em;color:green;font-weight:bold">@result.Data.DisplayName</div>
<div><b>Item Type:</b> @result.Data.ItemType</div>
<div><b>Description:</b> @result.Data.Description</div>
<div style="width:90%"><b>Description:</b> @result.Data.Description</div>
<div><input id="m@(result.Index)0" value="<xref:@result.Data.Link>"></div>
<div><input id="m@(result.Index)1" value="<xref:@result.Data.Link?displayProperty=fullName>"></div>
<div><input id="m@(result.Index)2" value="<xref:@result.Data.Link?displayProperty=nameWithType>"></div>
Expand All @@ -41,21 +50,25 @@
@message

@code {
private string? searchText;
[SupplyParameterFromForm]
private FormModel? Model { get; set; }

private SearchResults? SearchResultItems { get; set; }
public string? message;

protected override void OnInitialized() => Model ??= new();

public async Task GetSearchResults()
{
message = string.Empty;
var apiClient = ClientFactory.CreateClient("APIClient");

if (string.IsNullOrEmpty(searchText) || apiClient == null)
if (string.IsNullOrEmpty(Model?.SearchText) || apiClient == null)
{
return;
}

SearchResultItems = await apiClient.GetFromJsonAsync<SearchResults>($"api/apibrowser/dotnet/search?api-version=0.2&search={searchText}");
SearchResultItems = await apiClient.GetFromJsonAsync<SearchResults>($"api/apibrowser/dotnet/search?api-version=0.2&search={Model.SearchText}");

if (SearchResultItems?.Results != null)
{
Expand All @@ -79,9 +92,14 @@
message = "Request failed.";
}

searchText = string.Empty;
Model.SearchText = string.Empty;

StateHasChanged();
//StateHasChanged();
}

public class FormModel
{
public string? SearchText { get; set; } = string.Empty;
}

public class SearchResults
Expand Down
2 changes: 1 addition & 1 deletion BlazorWebAssemblyXrefGenerator/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ a, .btn-link {

input {
margin-bottom: 5px;
width: 100%
width: 90%
}

.btn-primary {
Expand Down
Loading