GithubHelp home page GithubHelp logo

jasperfx / baseline Goto Github PK

View Code? Open in Web Editor NEW
108.0 108.0 21.0 5.84 MB

Grab bag of generic utilities and extension methods for .Net development

License: Apache License 2.0

C# 99.94% Batchfile 0.02% PowerShell 0.02% Shell 0.02%

baseline's People

Contributors

bitbonk avatar coreykaylor avatar cothman avatar hawxy avatar jamesfarrer avatar jeremydmiller avatar matneyx avatar mysticmind avatar romanx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

baseline's Issues

Model binding report for diagnostics?

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.

License link in NuGet.org is wrong

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.

Non typed stream

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

Unable to install version 1.4 from Nuget

image
I tried installing Marten from NuGet, the install did not succeed due to its dependency on baseline. When I tried installing baseline the error message, as shown above, was observed.

why are both ImTools nuget dependency and src code included ?

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'.

Globalization-Invariant mode not supported [.NET 6, Docker, Lamar 8.0.1]

C# Version: 10.0
.NET: 6.0.9
Lamar: 8.0.1
Docker: mcr.microsoft.com/dotnet/aspnet:6.0-alpine

Description

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"]

Expected Behaviour

The expected behaviour is, that the application runs as usual and successfully registers all services matching the assembly scanner.

Actual Behaviour

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()

Delist Bad NuGet Package Versions of Baseline

31702709-9f0898b8-b38d-11e7-81d7-4521ff1060ac

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.

Linq extensions

Any reason not to pull over the LinqExtensions from Marten into Baseline?

CallingAssembly.findAssembly Assumes Assembly Name Matches Namespace

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

Topological Sort taking too much time

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,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.