Skip to content

Commit

Permalink
Fixes nullability warnings
Browse files Browse the repository at this point in the history
JudahGabriel committed Jan 13, 2024
1 parent aa73887 commit 45dcf17
Showing 5 changed files with 21 additions and 9 deletions.
10 changes: 8 additions & 2 deletions Raven.Migrations/Raven.Migrations.csproj
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>6.0.0</Version>
<Version>6.0.1</Version>
<PackageId>RavenMigrations</PackageId>
<Authors>Darrel Portzline, Khalid Abuhakmeh, Judah Gabriel Himango</Authors>
<Company>BitShuva</Company>
@@ -15,7 +15,7 @@
<PackageLicenseUrl>
</PackageLicenseUrl>
<PackageTags>ravendb, nosql, migration, schema</PackageTags>
<PackageReleaseNotes>PatchCollection allows for stale timeout</PackageReleaseNotes>
<PackageReleaseNotes>Updates to .NET 8, Raven 6. Fixes nullability issues.</PackageReleaseNotes>
<!-- SourceLink support -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
@@ -27,6 +27,8 @@
<nullable>enable</nullable>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Title>RavenDB.Migrations</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
@@ -35,6 +37,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\RavenDB.DependencyInjection\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="logo-for-nuget.png">
<Pack>True</Pack>
<PackagePath>
12 changes: 9 additions & 3 deletions Raven.Migrations/RavenMigrationHelpers.cs
Original file line number Diff line number Diff line change
@@ -27,8 +27,14 @@ public static string GetMigrationDocumentId(Migration migration, char separator)
public static MigrationAttribute GetMigrationAttribute(this Type type)
{
var attribute = Attribute.GetCustomAttributes(type)
.FirstOrDefault(x => x is MigrationAttribute);
return (MigrationAttribute) attribute;
.OfType<MigrationAttribute>()
.FirstOrDefault();
if (attribute == null)
{
throw new InvalidOperationException("The migration must be decorated with a [Migration] attribute");
}

return attribute;
}

public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
@@ -44,7 +50,7 @@ public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
return e.Types.Where(t => t != null)!;
}
}

6 changes: 3 additions & 3 deletions Raven.Migrations/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ private static IServiceCollection CreateMigrationRunner(
IServiceCollection services,
Action<MigrationOptions>? configuration,
IDocumentStore? docStore,
Assembly assembly)
Assembly? assembly)
{
if (assembly == null)
{
@@ -61,12 +61,12 @@ private static IServiceCollection CreateMigrationRunner(
return services.AddSingleton(provider => CreateMigrationRunnerFromProvider(provider, assembly, configuration, docStore));
}

private static MigrationRunner CreateMigrationRunnerFromProvider(IServiceProvider provider, Assembly callingAssembly, Action<MigrationOptions>? configuration = null, IDocumentStore? store = null)
private static MigrationRunner CreateMigrationRunnerFromProvider(IServiceProvider provider, Assembly? callingAssembly, Action<MigrationOptions>? configuration = null, IDocumentStore? store = null)
{
var migrationResolver = new DependencyInjectionMigrationResolver(provider);
var options = new MigrationOptions(migrationResolver);
configuration?.Invoke(options);
if (options.Assemblies.Count == 0)
if (options.Assemblies.Count == 0 && callingAssembly != null)
{
// No assemblies configured? Use the assembly that called .AddRavenDbMigrations.
options.Assemblies.Add(callingAssembly);
2 changes: 1 addition & 1 deletion Raven.Migrations/SimpleMigrationResolver.cs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ public class SimpleMigrationResolver : IMigrationResolver
{
public Migration Resolve(Type migrationType)
{
return (Migration)Activator.CreateInstance(migrationType);
return (Migration)Activator.CreateInstance(migrationType)!;
}
}
}
Binary file modified Raven.Migrations/logo-for-nuget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 45dcf17

Please sign in to comment.