jasperfx / baseline Goto Github PK
View Code? Open in Web Editor NEWGrab bag of generic utilities and extension methods for .Net development
License: Apache License 2.0
Grab bag of generic utilities and extension methods for .Net development
License: Apache License 2.0
Super helpful, like to have it more generally
We had a crazy detailed mechanism for logging conversion problems and errors in FubuCore. Do something similar here? Baseline's model is substantially simpler, so maybe it's not really necessary.
Performance and concurrency FTW
Declared: https://github.com/JasperFX/Baseline/blob/master/LICENSE.txt
Should be: https://github.com/JasperFx/baseline/blob/master/LICENSE
(no .txt)
Also affects your other NuGet packages.
When starting the stream we are required to tie it to a certain type. Would be nice to be able to pass in a custom string and there by classifying (naming) the stream and not tie it to a certain concrete type/model.
Or is it really used for anything internally? On the way out, I get that a type could be needed, when e.g. consuming a stream with snapshots, but then I will be needed to specify a target type anyway, no?
That would allow us to use the stream state for versioning, meta etc. and consume the related events as pure events to a stream and not care about models.
Alternatively, not require a certain type being stored and the be able to pass custom meta that can be attached to the stream and acquired via FetchStreamState
I notice that there's a nuget package reference in the Baseline.csproj
While there's also source code of ImTools copied directly in the BaselineTypeDiscovery project.
As Marten depends on both baseline and BaselineTypeDiscovery, if I manage the dependencies with paket , VS gets stuck:
The type 'VEntry' in 'E:\NUGET_PACKAGES\imtools\4.0.0\contentFiles\cs\netstandard2.0\ImTools\ImTools.cs'
conflicts with the imported type 'VEntry' in 'Baseline, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null'.
C# Version: 10.0
.NET: 6.0.9
Lamar: 8.0.1
Docker: mcr.microsoft.com/dotnet/aspnet:6.0-alpine
Assume the following program. It's a simple, quite empty command line application with hosting, logging and lamar configured.
When running .NET 6 in an Alpine docker container, by default, the globalization invariant mode is active. You can read more about the topic here.
Update: Any .net 6 docker runtime has this mode now preconfigured. This is a breaking change in .net 6.
Program.cs
using Lamar;
using Lamar.Microsoft.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Serilog.Settings.Configuration;
namespace MyApp;
public static class Program
{
public static async Task<int> Main(string[] args)
{
Log.Logger = SetupDefaultLoggerConfiguration(new LoggerConfiguration()).CreateBootstrapLogger();
try
{
return await CreateHostBuilder().RunCommandLineApplicationAsync<App>(args);
}
catch (Exception ex)
{
Log.Fatal(ex, "An error occurred: {Error}", ex.Message);
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
private static void ConfigureApp(HostBuilderContext host, IConfigurationBuilder config)
{
config.AddJsonFile("appsettings.json", optional: true)
.AddEnvironmentVariables();
}
private static void ConfigureContainer(HostBuilderContext host, ServiceRegistry services)
{
services.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions(ServiceLifetime.Transient);
});
}
private static void ConfigureLogger(HostBuilderContext host, LoggerConfiguration config)
{
SetupDefaultLoggerConfiguration(config).ReadFrom.Configuration(host.Configuration,
nameof(Serilog),
ConfigurationAssemblySource.UseLoadedAssemblies);
}
private static LoggerConfiguration SetupDefaultLoggerConfiguration(LoggerConfiguration configuration) =>
configuration
.MinimumLevel.Verbose()
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Console();
private static IHostBuilder CreateHostBuilder() => new HostBuilder()
.ConfigureAppConfiguration(ConfigureApp)
.UseLamar(ConfigureContainer)
.UseSerilog(ConfigureLogger);
}
Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /app
COPY ./*.csproj /app/
RUN dotnet restore
FROM build as publish
WORKDIR /app
COPY . .
RUN dotnet publish . -c Release -o /app/.dist
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS runtime
WORKDIR /app
COPY --from=publish /app/.dist /app/
ENTRYPOINT ["/app/MyApp"]
The expected behaviour is, that the application runs as usual and successfully registers all services matching the assembly scanner.
The application immediately crashes on assembly scanning. See the following stacktrace for more information:
Exception thrown: 'System.Globalization.CultureNotFoundException' in System.Private.CoreLib.dll
An exception of type 'System.Globalization.CultureNotFoundException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information.'
Stack trace:
> at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
> at BaselineTypeDiscovery.CallingAssembly.GetStackTraceInEnglish()
> at BaselineTypeDiscovery.CallingAssembly.Find()
> at Lamar.Scanning.Conventions.AssemblyScanner.TheCallingAssembly()
> at MyApp.Program.<>c.<ConfigureContainer>b__2_0(IAssemblyScanner scan) in C:\code\MyApp\Program.cs:line 42
> at Lamar.ServiceRegistry.Scan(Action`1 scan)
> at MyApp.Program.ConfigureContainer(HostBuilderContext host, ServiceRegistry services) in C:\code\MyApp\Program.cs:line 40
> at Lamar.Microsoft.DependencyInjection.HostBuilderExtensions.<>c__DisplayClass1_0.<UseLamar>b__0(HostBuilderContext context, IServiceCollection services)
> at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
> at Microsoft.Extensions.Hosting.HostBuilder.Build()
> at Microsoft.Extensions.Hosting.HostBuilderExtensions.<RunCommandLineApplicationAsync>d__1`1.MoveNext()
Hey, I finally heard back from the people in the NuGet Ivory tower ๐ผ. They say the solution to resolving this annoying NuGet issue with Baseline
is to delist the Baseline
packages that contain the error. The crux of the issue is an empty id
string in the "dependencies" part of the NuGet .nuspec
as shown below:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>Baseline</id>
<version>0.5.0.3</version>
<title>Baseline</title>
<authors>Jeremy D. Miller, Brandon Behrens, Andrew Kharlamov</authors>
<owners>Jeremy D. Miller, Chad Myers, Joshua Arnold, Joshua Flanagan</owners>
<licenseUrl>https://github.com/JasperFX/Baseline/blob/master/LICENSE.txt</licenseUrl>
<projectUrl>https://github.com/JasperFX/Baseline</projectUrl>
<description>Grab bag of generic utilities and extension methods for .Net development</description>
<dependencies>
<dependency id="" version="" />
</dependencies>
</metadata>
</package>
Anyway, I've tried very hard to convince the NuGet team that they need to fix this issue because it really turns out to be their problem but they just now closed my issue: NuGet/NuGetGallery#4494. Their response is to ask the package author to delist the specific NuGet package versions that are affected by the "empty id string" dependency.
So, let's try it and maybe we can finally put this damn issue to rest. If it fails, I'll be back in their front yard.
The following Baseline
versions that need to be delisted are:
0.5.0.3
0.5.0.4
0.5.0.6
0.5.0.7
Thanks,
Brian
/cc @jeremydmiller @CoreyKaylor
For reference, the past issues that others have encountred this issue are: here, here, and here.
Not doing this until we have a demonstrated need for it, but FubuCore's old model binding did and we might wanna keep compatibility.
Any reason not to pull over the LinqExtensions from Marten into Baseline?
Speed baby, speed!
Some of the tests on Jasper are failing due to conversions not using invariant culture. Tracked the parsing logic here.
CallingAssembly.findAssembly() uses a stack trace to find the calling assembly. Stack traces have namespaces in them. The code assumes the namespace matches the assembly name. If the calling assembly's assembly name does not match the namespace, it won't be found.
OK yeah, why would anyone do this? It was really just an intermediate step in some refactoring where I discovered this. So it will go away for me. I really just wanted to make sure I was understanding this correctly, as it sucked up a few hours. Thanks! :-)
https://github.com/JasperFx/baseline/blob/master/src/BaselineTypeDiscovery/CallingAssembly.cs#L75
Actually We are migrating from StructureMap to Lamar,
During the changes we noticed that a new API was introduced BaseLineTypeDiscovery.
At first sight the call to AssemblyFinder.FindAssemblies(...) doesn't seem to change, but we also noticed that it take too much time to return the result. bellow the calling code
static string[] namespaces = new[] { "OurProject" };
public static IEnumerable<Assembly> GetOurProjectAssemblies()
{
return AssemblyFinder.FindAssemblies(
x => namespaces.Contains(x.FullName.Split(".").First())
);
}
When debugging BaseLine source code, I found that the Topological Sort using the Visitor Pattern takes too much time.
Another performance issue, the filter is applied until the end of the process. If the filter were applied at the beginning the number of the assemblies will drop drastically and the process will be fast.
Thank you,
Looking at the source for the documentation, it looks like it should be available to read at the Github Pages URL http://jasperfx.github.io/baseline, but I'm currently getting a 404. Is there are different address I should be using instead?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.