Skip to content

Commit

Permalink
Merge branch 'nhibernate_source_generator'
Browse files Browse the repository at this point in the history
  • Loading branch information
cime committed Apr 20, 2021
2 parents 1bc9a94 + 5e3b390 commit f19040a
Show file tree
Hide file tree
Showing 21 changed files with 532 additions and 18 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@ jobs:

runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
env:
POSTGRES_USER: coresharp
POSTGRES_PASSWORD: coresharp
POSTGRES_DB: coresharp
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
dotnet-version: '5.0.x'
- name: Test with dotnet
run: dotnet test
- name: Build with dotnet
Expand Down
8 changes: 5 additions & 3 deletions CoreSharp.Breeze.Tests/BaseDatabaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ protected virtual Configuration CreateNHibernateConfiguration(Container containe
var persistenceModel = GetPersistenceModel(container, config);
return Fluently.Configure(config)
.Database(
MsSqlConfiguration.MsSql2012.ConnectionString(o => o
PostgreSQLConfiguration.PostgreSQL82.ConnectionString(o => o
.Database("coresharp")
.Server("(local)")
.TrustedConnection())
.Host("localhost")
.Username("coresharp")
.Password("coresharp")
.Port(5432))
)
//.AppendEventListeners<User>(container)
.SetDefaultProperties()
Expand Down
2 changes: 1 addition & 1 deletion CoreSharp.Breeze.Tests/BreezeDatabaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected virtual void FillDatabase(ISession session)
{
CompositeOrder = compositeOrder,
Product = products[(i + j) % 10],
Price = i * j,
Price = (int)(i * j),
Quantity = i + j
});
}
Expand Down
4 changes: 3 additions & 1 deletion CoreSharp.Breeze.Tests/CoreSharp.Breeze.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -20,6 +20,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Npgsql" Version="5.0.4" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions CoreSharp.Common.Tests/BaseTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using SimpleInjector;
using CoreSharp.Cqrs.Events;
using SimpleInjector;
using SimpleInjector.Lifestyles;
using Xunit;

Expand Down Expand Up @@ -30,7 +31,7 @@ protected virtual void ConfigureContainer(Container container)

protected virtual void SetUp()
{

}

protected virtual void Cleanup()
Expand All @@ -39,6 +40,7 @@ protected virtual void Cleanup()

private void Configure(Container container)
{
var ep = new EventAggregator(container); // TODO: remove
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
ConfigureContainer(container);
container.RegisterPackages();
Expand Down
3 changes: 2 additions & 1 deletion CoreSharp.Common.Tests/CoreSharp.Common.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -17,6 +17,7 @@

<ItemGroup>
<ProjectReference Include="..\CoreSharp.Common\CoreSharp.Common.csproj" />
<ProjectReference Include="..\CoreSharp.Cqrs\CoreSharp.Cqrs.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion CoreSharp.Cqrs.AspNetCore/CoreSharp.Cqrs.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net5.0;netcoreapp3.1;netcoreapp3.0;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net5.0;netcoreapp3.1;netstandard2.0</TargetFrameworks>
<PackageId>CoreSharp.Cqrs.AspNetCore</PackageId>

<Authors>cime</Authors>
Expand Down
2 changes: 1 addition & 1 deletion CoreSharp.Cqrs.Tests/CoreSharp.Cqrs.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
41 changes: 41 additions & 0 deletions CoreSharp.NHibernate.SourceGenerator/AnalyzersConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Serialization;

namespace CoreSharp.NHibernate.SourceGenerator
{
[XmlRoot("Analyzers")]
public class AnalyzersConfig
{
private static AnalyzersConfig _instance;

public VirtualModifierAnalyzer VirtualModifierAnalyzer { get; set; } = new VirtualModifierAnalyzer();
public PropertyOrderAnalyzer PropertyOrderAnalyzer { get; set; } = new PropertyOrderAnalyzer();

[XmlArray("ValidTypes")]
[XmlArrayItem("ValidType")]
public ValidTypes ValidTypes { get; set; } = new ValidTypes() { "CoreSharp.DataAccess.IEntity", "CoreSharp.DataAccess.ICodeList" };

public List<string> VirtualModifierAnalyzerValidTypes => new List<string>().Concat(ValidTypes ?? new List<string>()).Concat(VirtualModifierAnalyzer?.ValidTypes ?? new List<string>()).Distinct().ToList();
public List<string> PropertyOrderAnalyzerValidTypes => new List<string>().Concat(ValidTypes ?? new List<string>()).Concat(PropertyOrderAnalyzer?.ValidTypes ?? new List<string>()).Distinct().ToList();

[DebuggerStepThrough]
public static AnalyzersConfig Deserialize(string content)
{
try
{
var xs = new XmlSerializer(typeof(AnalyzersConfig));
var sr = new StringReader(content);

return (AnalyzersConfig)xs.Deserialize(sr);
}
catch (Exception)
{
return _instance ?? (_instance = new AnalyzersConfig());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9</LangVersion>

<PackageId>CoreSharp.NHibernate.SourceGenerator</PackageId>

<Authors>cime</Authors>
<Description>.NET standard NHibernate extensions, convetions</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright 2021 (c) cime. All rights reserved.</Copyright>
<PackageTags>Core# nhibernate dataaccess db</PackageTags>
<PackageProjectUrl>https://github.com/cime/CoreSharp</PackageProjectUrl>
<PackageLicense>https://github.com/cime/CoreSharp/blob/master/LICENSE</PackageLicense>
<RepositoryUrl>https://github.com/cime/CoreSharp</RepositoryUrl>
<NullableContextOptions>enable</NullableContextOptions>
<Version>0.1.1</Version>
</PropertyGroup>

<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build -->
<IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.8.0" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup>
<!-- Package the generator in the analyzer directory of the nuget package -->
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />

<!-- Package the Newtonsoft.Json dependency alongside the generator assembly -->
<None Include="$(PkgHumanizer_Core)\lib\netstandard2.0\*.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

</Project>
Loading

0 comments on commit f19040a

Please sign in to comment.