-
Notifications
You must be signed in to change notification settings - Fork 20
Conversation
Having app.UseDeveloperExceptionPage as the last middleware won't catch any exception. See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-2.2#the-developer-exception-page
This fixes GitHubScannerTests.ICanHasDotnetRepository and GitHubScannerTests.RepoDoesNotExist
Also replace the retired Serilog.Sinks.ColoredConsole and Serilog.Sinks.LiterateConsole with Serilog.Sinks.Console
Logs were appearing twice in the console.
Also use the IMiddleware interface for RedirectWwwMiddleware
This way the xunit test runner is not confused. Idea for parallelization from https://stackoverflow.com/questions/32702969/how-to-make-xunit-to-run-a-theory-parallel/34828001#34828001
71d42ed
to
efbe61c
Compare
2533bd3
to
4bfb5ec
Compare
This is a necessary step to convert the project to .NET Core
Scanning a GitHub repository now supports the following syntax: Username/Repository@Reference with the last part "@reference" being optional. This allows to scan a repository for a given tag, branch or specific commit with its SHA1.
This solves the case of "Not a .NET Library" being only available in pre-release such as Microsoft.NETFramework.ReferenceAssemblies. Before this commit it would diagnose Microsoft.NETFramework.ReferenceAssemblies as "Not Found". After this commit, it is correctly diagnosed as "Not a .NET Library".
4bfb5ec
to
d1e5ecd
Compare
This fixes ReSharper/Rider warnings
They now share a common implementation (EmbeddedResourceRepository) and are not static anymore
And use await using for IAsyncDisposable
d1e5ecd
to
3bc9e7f
Compare
|
||
try | ||
await using var context = _contextFactory(); | ||
var packageStatistic = await context.PackageStatistics.FindAsync(new object[] {package.PackageName}, cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer atomic. I used the MERGE
command as it guaranteed (from my understanding) atomic insert/update of that record. With this change two threads could update the same statistic record and only the last in wins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I addressed this issue in 49561db. I used FlexLabs.EntityFrameworkCore.Upsert as EF Core does not handle upsert out of the box.
By increasing the EF Core log level to information (.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Information)
) and enabling sensitive data logging (optionsBuilder.EnableSensitiveDataLogging();
) we can see how FlexLabs.Upsert works:
With SQLite:
-- Executing DbCommand [Parameters=[@p0='Newtonsoft.Json' (Nullable = false) (Size = 15), @p1='1' (DbType = String), @p2='Supported' (Nullable = false) (Size = 9), @p3='1' (DbType = String)], CommandType='Text', CommandTimeout='30']
INSERT INTO "PackageStatistics" AS "T" ("Name", "Count", "LatestSupportType") VALUES (@p0, @p1, @p2) ON CONFLICT ("Name") DO UPDATE SET "Count" = ( "T"."Count" + @p3 )
With SQL Server:
-- Executing DbCommand [Parameters=[@p0='Newtonsoft.Json' (Nullable = false) (Size = 450), @p1='1', @p2='Supported' (Nullable = false) (Size = 4000), @p3='1'], CommandType='Text', CommandTimeout='30']
MERGE INTO [PackageStatistics] WITH (HOLDLOCK) AS [T] USING ( VALUES (@p0, @p1, @p2) ) AS [S] ([Name], [Count], [LatestSupportType]) ON [T].[Name] = [S].[Name] WHEN NOT MATCHED BY TARGET THEN INSERT ([Name], [Count], [LatestSupportType]) VALUES ([Name], [Count], [LatestSupportType]) WHEN MATCHED THEN UPDATE SET [Count] = ( [T].[Count] + @p3 );
@0xced I haven't forgotten about this and will get to doing a full review. I did a quick scan and only one thing stood out to me so far (added a comment) |
EF Core does not support upsert out of the box, see dotnet/efcore#4526 But Artiom Chilaru created a NuGet package (FlexLabs.EntityFrameworkCore.Upsert) that handle upsert for PostgreSQL/Sqlite, SqlServer and MySQL.
Excellent, I’ll stop force-pushing small changes while you are reviewing. Would you consider using SQLite in production? I think for a simple two tables database (cache + stats) it would be well enough and cheaper than an SQL Server instance. Are you currently using an Azure SQL Database? Is it costly? |
The default handler properly handle authenticated redirects
This improves performance and also helps staying within the GitHub rate limit: https://developer.github.com/v3/#staying-within-the-rate-limit
I have pushed a few more improvements. We could probably shave a few more milliseconds when scanning GitHub repositories if octokit/octokit.net#2151 gets merged and a new release of Octokit is released. |
Also make the return type explicit with Task<ActionResult<GetResultResponse>>
@0xced Thank you for this contribution. Unfortunately we've decided to shutter the site. The traffic has decreased significantly since .NET Core 3.1 was released (and previous 2.0). The ecosystem as a whole has transitioned over and the majority of use cases now work. |
Here's a pull request porting ICanHasDotnetCore to .NET Core 3 with a few side improvements. I have tried to break things in isolated commits so in case you don't want to merge it altogether you can cherry-pick commits of interest.
Here are the most important changes:
This change makes it super easy to develop with SQLite instead of SQL Server (I did all the work on macOS using JetBrains Rider). To develop on SQLite, just add this in
appsettings.Development.json
:And maybe you could even use SQLite in production and save money on an SQL Server instance?
Updated the web project to work with Node.js 12 and Gulp 4. I also added a new Scan A NuGet package tab to get the dependency graph of a NuGet package without having to upload a file.
And here are less important changes:
ArgumentNullException