Skip to content

Commit

Permalink
fix double add for same assembly
Browse files Browse the repository at this point in the history
in GetAssembliesForRouting #21
  • Loading branch information
StardustDL committed Mar 14, 2021
1 parent 4f26ce4 commit a0e9eee
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: ./build.ps1 -e -t Deploy-Packages
- name: Deploy documents
uses: JamesIves/github-pages-deploy-action@4.0.0
uses: JamesIves/github-pages-deploy-action@4.1.0
with:
token: ${{ secrets.PA_TOKEN }}
branch: gh-pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
name: artifacts
path: ./dist
- name: Deploy documents
uses: JamesIves/github-pages-deploy-action@4.0.0
uses: JamesIves/github-pages-deploy-action@4.1.0
with:
token: ${{ secrets.PA_TOKEN }}
branch: gh-pages
Expand Down
6 changes: 6 additions & 0 deletions build/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public BuildContext(ICakeContext context)
}

Solution = SolutionType.All;

if (CommitMessage.Contains("[ui]"))
{
Solution = SolutionType.UI;
}

Solution = context.Argument("solution", "").ToLowerInvariant() switch
{
"all" => SolutionType.All,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public async Task<List<Assembly>> GetAssembliesForRouting(string path, bool recu

var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

HashSet<string> processed = new HashSet<string>();

List<Assembly> results = new List<Assembly>();

Queue<string> toLoad = new Queue<string>();
Expand All @@ -144,7 +146,12 @@ public async Task<List<Assembly>> GetAssembliesForRouting(string path, bool recu
{
cancellationToken.ThrowIfCancellationRequested();

toLoad.Enqueue(module.GetType().GetAssemblyName());
var name = module.GetType().GetAssemblyName();

if (processed.Add(name))
{
toLoad.Enqueue(name);
}

var pages = module.GetPageProvider(Host);

Expand All @@ -154,7 +161,10 @@ public async Task<List<Assembly>> GetAssembliesForRouting(string path, bool recu
{
cancellationToken.ThrowIfCancellationRequested();

toLoad.Enqueue(resource.Path);
if (processed.Add(resource.Path))
{
toLoad.Enqueue(resource.Path);
}
}
}
}
Expand Down Expand Up @@ -209,7 +219,12 @@ public async Task<List<Assembly>> GetAssembliesForRouting(string path, bool recu
{
cancellationToken.ThrowIfCancellationRequested();
if (refe.Name is not null)
toLoad.Enqueue(refe.Name);
{
if (processed.Add(refe.Name))
{
toLoad.Enqueue(refe.Name);
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Modulight.UI.Blazor/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
AdditionalAssemblies.Clear();

var results = await ClientModuleHost.GetAssembliesForRouting(context.Path, cancellationToken: context.CancellationToken);
AdditionalAssemblies.AddRange(results.Where(x => x != UIProvider.AppAssembly));
var filterdResults = new HashSet<Assembly>(results);
AdditionalAssemblies.AddRange(filterdResults.Where(x => x != UIProvider.AppAssembly));
}
}

0 comments on commit a0e9eee

Please sign in to comment.