Skip to content

Commit

Permalink
feat: target framework .NET 8.0 (#726)
Browse files Browse the repository at this point in the history
* refactor: mappers, locators and connectivities classes now visible outside of the libraries
* refactor: use GetExportedTypes in place of GetTypes
* build: active build for .NET 8.0
  • Loading branch information
Seddryck authored Dec 9, 2023
1 parent eb0a6ea commit 73ea994
Show file tree
Hide file tree
Showing 49 changed files with 95 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Platform>AnyCPU</Platform>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
4 changes: 2 additions & 2 deletions DubUrl.Adomd/Mapping/PowerBiDesktopMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace DubUrl.Adomd.Mapping;
[Mapper<PowerBiDesktopDatabase, NamedParametrizer>(
"Microsoft.AnalysisServices.AdomdClient"
)]
internal class PowerBiDesktopMapper : PowerBiPremiumMapper
public class PowerBiDesktopMapper : PowerBiPremiumMapper
{
public PowerBiDesktopMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new PowerBiDesktopRewriter(csb),
dialect,
parametrizer
)
{ }
}
}
4 changes: 2 additions & 2 deletions DubUrl.Adomd/Mapping/PowerBiPremiumMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace DubUrl.Adomd.Mapping;
[Mapper<PowerBiPremiumDatabase, NamedParametrizer>(
"Microsoft.AnalysisServices.AdomdClient"
)]
internal class PowerBiPremiumMapper : BaseMapper
public class PowerBiPremiumMapper : BaseMapper
{
public PowerBiPremiumMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: this(new PowerBiPremiumRewriter(csb),
Expand All @@ -30,4 +30,4 @@ protected PowerBiPremiumMapper(ConnectionStringRewriter rewriter, IDialect diale
parametrizer
)
{ }
}
}
2 changes: 1 addition & 1 deletion DubUrl.Core/Locating/OdbcDriver/BaseDriverLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace DubUrl.Locating.OdbcDriver;

internal abstract class BaseDriverLocator : IDriverLocator
public abstract class BaseDriverLocator : IDriverLocator
{
protected string RegexPattern { get; }
protected DriverLister Lister { get; }
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Locating/OdbcDriver/DriverLister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace DubUrl.Locating.OdbcDriver;

internal class DriverLister
public class DriverLister
{
public virtual string[] List()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<DrillDriverRegex, DrillOdbcMapper, DrillDatabase>()]
internal class DrillDriverLocator : BaseDriverLocator
public class DrillDriverLocator : BaseDriverLocator
{
internal class DrillDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<DuckdbDriverRegex, OdbcMapper, DuckdbDatabase>()]
internal class DuckdbDriverLocator : BaseDriverLocator
public class DuckdbDriverLocator : BaseDriverLocator
{
internal class DuckdbDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<MariaDbDriverRegex, OdbcMapper, MariaDbDatabase>()]
internal class MariaDbDriverLocator : BaseDriverLocator
public class MariaDbDriverLocator : BaseDriverLocator
{
internal class MariaDbDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DubUrl.Locating.OdbcDriver;

[Driver<MsExcelDriverRegex, OdbcDbqMapper, MsExcelDatabase>()]
internal class MsExcelDriverLocator : BaseDriverLocator
public class MsExcelDriverLocator : BaseDriverLocator
{
internal class MsExcelDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<MssqlDriverRegex, OdbcMapper, MsSqlServerDatabase>()]
internal class MssqlDriverLocator : BaseDriverLocator
public class MssqlDriverLocator : BaseDriverLocator
{
internal class MssqlDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<MySqlConnectorDriverRegex, OdbcMapper, MySqlDatabase>()]
internal class MySqlConnectorDriverLocator : BaseDriverLocator
public class MySqlConnectorDriverLocator : BaseDriverLocator
{
internal class MySqlConnectorDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<PostgresqlDriverRegex, OdbcMapper, PostgresqlDatabase>()]
internal class PostgresqlDriverLocator : BaseDriverLocator
public class PostgresqlDriverLocator : BaseDriverLocator
{
internal class PostgresqlDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<PostgresqlDriverRegex, QuestDbOdbcMapper, QuestDbDatabase>()]
internal class QuestDbDriverLocator : PostgresqlDriverLocator
public class QuestDbDriverLocator : PostgresqlDriverLocator
{
public QuestDbDriverLocator()
: this(EncodingOption.Unspecified, ArchitectureOption.Unspecified) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DubUrl.Locating.OdbcDriver;

[Driver<TextDriverRegex, OdbcDbqMapper, TextDatabase>()]
internal class TextDriverLocator : BaseDriverLocator
public class TextDriverLocator : BaseDriverLocator
{
internal class TextDriverRegex : BaseDriverRegex
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<PostgresqlDriverRegex, OdbcMapper, TimescaleDatabase>()]
internal class TimescaleDriverLocator : PostgresqlDriverLocator
public class TimescaleDriverLocator : PostgresqlDriverLocator
{
public TimescaleDriverLocator()
: this(EncodingOption.Unspecified, ArchitectureOption.Unspecified) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Locating.OdbcDriver.Implementation;

[Driver<TrinoDriverRegex, TrinoOdbcMapper, TrinoDatabase>()]
internal class TrinoDriverLocator : BaseDriverLocator
public class TrinoDriverLocator : BaseDriverLocator
{
internal class TrinoDriverRegex : BaseDriverRegex
{
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Locating/Options/LocatorOptionAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace DubUrl.Locating.Options;

[AttributeUsage(AttributeTargets.Enum, Inherited = true, AllowMultiple = false)]
sealed class LocatorOptionAttribute : Attribute
public sealed class LocatorOptionAttribute : Attribute
{
public LocatorOptionAttribute()
{ }
Expand Down
14 changes: 11 additions & 3 deletions DubUrl.Core/Mapping/BaseMapperIntrospector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ protected record class AttributeInfo<T>(Type Type, T Attribute) { }
protected Type[] Types { get => _types ??= Probe.Locate().ToArray(); }

protected BaseIntrospector(ITypesProbe probe)
=> (Probe) = (probe);
=> (Probe) = (probe);

protected IEnumerable<AttributeInfo<T>> LocateAttribute<T>() where T : Attribute
=> Types.Where(
{
var types = Types.Where(
x => x.GetCustomAttributes(typeof(T), false).Length > 0
)
.Select(x => (Type: x, Attribute: x.GetCustomAttribute<T>() ?? throw new InvalidOperationException()))
Expand All @@ -29,6 +30,8 @@ protected IEnumerable<AttributeInfo<T>> LocateAttribute<T>() where T : Attribute
x.Type,
x.Attribute
));
return types;
}
}

public class AssemblyTypesProbe : ITypesProbe
Expand All @@ -44,7 +47,12 @@ public AssemblyTypesProbe(Assembly[] assemblies)
public virtual IEnumerable<Type> Locate()
=> Assemblies.Aggregate(
Array.Empty<Type>(), (types, asm)
=> types.Concat(asm.GetTypes().Where(x => x.IsClass && !x.IsAbstract)).ToArray()
//#if NET7_0_OR_GREATER
=> types.Concat(asm.GetExportedTypes().Where(x => x.IsClass && !x.IsAbstract)).ToArray()
//#else
// => types.Concat(asm.GetTypes().Where(x => x.IsClass && !x.IsAbstract)).ToArray()
//#endif

);
}

Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/CockRoachMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace DubUrl.Mapping.Implementation;

[Mapper<CockRoachDatabase, PositionalParametrizer>("Npgsql")]
internal class CockRoachMapper : PostgresqlMapper
public class CockRoachMapper : PostgresqlMapper
{
public CockRoachMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new CockRoachRewriter(csb), dialect, parametrizer) { }
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/Db2Mapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace DubUrl.Mapping.Implementation;

[Mapper<Db2Database, NamedParametrizer>("IBM.Data.Db2")]
internal class Db2Mapper : BaseMapper
public class Db2Mapper : BaseMapper
{
public Db2Mapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new Db2Rewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/DuckdbMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace DubUrl.Mapping.Implementation;
[MapperAttribute<DuckdbDatabase, PositionalParametrizer>(
"DuckDB.NET.Data"
)]
internal class DuckdbMapper : BaseMapper
public class DuckdbMapper : BaseMapper
{
public DuckdbMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new DuckdbRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/FirebirdSqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Mapping.Implementation;

[Mapper<FirebirdSqlDatabase, NamedParametrizer>("FirebirdSql.Data.FirebirdClient")]
internal class FirebirdSqlMapper : BaseMapper
public class FirebirdSqlMapper : BaseMapper
{
public FirebirdSqlMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new FirebirdSqlRewriter(csb),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Mapping.Implementation;

[Mapper<MariaDbDatabase, NamedParametrizer>("MySqlConnector")]
internal class MariaDbConnectorMapper : MySqlConnectorMapper
public class MariaDbConnectorMapper : MySqlConnectorMapper
{
public MariaDbConnectorMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(csb, dialect, parametrizer)
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/MariaDbDataMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace DubUrl.Mapping.Implementation;

[AlternativeMapper<MariaDbDatabase, NamedParametrizer>("MySql.Data")]
internal class MariaDbDataRewriter : MySqlDataMapper
public class MariaDbDataRewriter : MySqlDataMapper
{
public MariaDbDataRewriter(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(csb, dialect, parametrizer)
Expand Down
4 changes: 2 additions & 2 deletions DubUrl.Core/Mapping/Implementation/MsSqlServerMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<MsSqlServerDatabase, NamedParametrizer>(
"Microsoft.Data.SqlClient"
)]
internal class MsSqlServerMapper : BaseMapper
public class MsSqlServerMapper : BaseMapper
{
public MsSqlServerMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new MsSqlServerRewriter(csb),
dialect,
parametrizer
)
{ }
}
}
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/MySqlConnectorMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<MySqlDatabase, NamedParametrizer>(
"MySqlConnector"
)]
internal class MySqlConnectorMapper : BaseMapper
public class MySqlConnectorMapper : BaseMapper
{
public MySqlConnectorMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new MySqlConnectorRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/MySqlDataMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[AlternativeMapper<MySqlDatabase, NamedParametrizer>(
"MySql.Data"
)]
internal class MySqlDataMapper : MySqlConnectorMapper
public class MySqlDataMapper : MySqlConnectorMapper
{
public MySqlDataMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new MySqlDataRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/OdbcDbqMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace DubUrl.Mapping.Implementation;
[WrapperMapper<OdbcConnectivity, PositionalParametrizer>(
"System.Data.Odbc"
)]
internal class OdbcDbqMapper : BaseMapper, IOdbcMapper
public class OdbcDbqMapper : BaseMapper, IOdbcMapper
{
public OdbcDbqMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new OdbcDbqRewriter(csb),
Expand Down
1 change: 0 additions & 1 deletion DubUrl.Core/Mapping/Implementation/OdbcMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ public OdbcMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer
parametrizer
)
{ }

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<OracleDatabase, NamedParametrizer>(
"Oracle.ManagedDataAccess"
)]
internal class OracleManagedDataAccessMapper : BaseMapper
public class OracleManagedDataAccessMapper : BaseMapper
{
public OracleManagedDataAccessMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new OracleManagedDataAccessRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/PostgresqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace DubUrl.Mapping.Implementation;
[MapperAttribute<PostgresqlDatabase, PositionalParametrizer>(
"Npgsql"
)]
internal class PostgresqlMapper : BaseMapper
public class PostgresqlMapper : BaseMapper
{
public PostgresqlMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new PostgresqlRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/QuestDbMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<QuestDbDatabase, PositionalParametrizer>(
"Npgsql"
)]
internal class QuestDbMapper : PostgresqlMapper
public class QuestDbMapper : PostgresqlMapper
{
public QuestDbMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new QuestDbRewriter(csb), dialect, parametrizer)
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/SnowflakeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<SnowflakeDatabase, PositionalNamedParametrizer>(
"Snowflake.Data"
)]
internal class SnowflakeMapper : BaseMapper
public class SnowflakeMapper : BaseMapper
{
public SnowflakeMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new SnowflakeRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/SqliteMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<SqliteDatabase, NamedParametrizer>(
"Microsoft.Data.Sqlite"
)]
internal class SqliteMapper : BaseMapper
public class SqliteMapper : BaseMapper
{
public SqliteMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new SqliteRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/TeradataMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<TeradataDatabase, PositionalParametrizer>(
"Teradata.Client"
)]
internal class TeradataMapper : BaseMapper
public class TeradataMapper : BaseMapper
{
public TeradataMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new TeradataRewriter(csb),
Expand Down
2 changes: 1 addition & 1 deletion DubUrl.Core/Mapping/Implementation/TimescaleMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<TimescaleDatabase, PositionalParametrizer>(
"Npgsql"
)]
internal class TimescaleMapper : PostgresqlMapper
public class TimescaleMapper : PostgresqlMapper
{
public TimescaleMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new TimescaleRewriter(csb), dialect, parametrizer)
Expand Down
4 changes: 2 additions & 2 deletions DubUrl.Core/Mapping/Implementation/TrinoMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace DubUrl.Mapping.Implementation;
[Mapper<TrinoDatabase, NamedParametrizer>(
"NReco.PrestoAdo"
)]
internal class TrinoMapper : BaseMapper
public class TrinoMapper : BaseMapper
{
public TrinoMapper(DbConnectionStringBuilder csb, IDialect dialect, IParametrizer parametrizer)
: base(new TrinoRewriter(csb),
dialect,
parametrizer
)
{ }
}
}
2 changes: 1 addition & 1 deletion DubUrl.Core/Registering/BinFolderDiscoverer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public virtual IEnumerable<Type> Execute()
?? AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(asmPath));

//Check if assembly contains a DbProviderFactory
var types = asm.DefinedTypes;
var types = asm.GetExportedTypes();
var providerFactories = types.Where(t =>
t.IsClass
&& t.IsVisible
Expand Down
Loading

0 comments on commit 73ea994

Please sign in to comment.