Skip to content

Commit

Permalink
adds netcoreapp3.1 target framework
Browse files Browse the repository at this point in the history
  • Loading branch information
thoemmi authored and khellang committed Nov 3, 2020
1 parent 1d4f644 commit 087f844
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/Scrutor/IFluentInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public interface IFluentInterface
int GetHashCode();

[EditorBrowsable(EditorBrowsableState.Never)]
string ToString();
string? ToString();

[EditorBrowsable(EditorBrowsableState.Never)]
bool Equals(object obj);
}
}
}
6 changes: 3 additions & 3 deletions src/Scrutor/ImplementationTypeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public IImplementationTypeFilter InNamespaceOf(params Type[] types)
{
Preconditions.NotNull(types, nameof(types));

return InNamespaces(types.Select(t => t.Namespace));
return InNamespaces(types.Select(t => t.Namespace!));
}

public IImplementationTypeFilter InNamespaces(params string[] namespaces)
Expand All @@ -104,7 +104,7 @@ public IImplementationTypeFilter InExactNamespaceOf<T>()
public IImplementationTypeFilter InExactNamespaceOf(params Type[] types)
{
Preconditions.NotNull(types, nameof(types));
return Where(t => types.Any(x => t.IsInExactNamespace(x.Namespace)));
return Where(t => types.Any(x => t.IsInExactNamespace(x.Namespace!)));
}

public IImplementationTypeFilter InExactNamespaces(params string[] namespaces)
Expand All @@ -130,7 +130,7 @@ public IImplementationTypeFilter NotInNamespaceOf(params Type[] types)
{
Preconditions.NotNull(types, nameof(types));

return NotInNamespaces(types.Select(t => t.Namespace));
return NotInNamespaces(types.Select(t => t.Namespace!));
}

public IImplementationTypeFilter NotInNamespaces(params string[] namespaces)
Expand Down
4 changes: 4 additions & 0 deletions src/Scrutor/NullableAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// Copied from https://github.com/dotnet/coreclr/blob/16697076c0a6af47fbcce75e11c45d35a12b7d4e/src/System.Private.CoreLib/shared/System/Diagnostics/CodeAnalysis/NullableAttributes.cs

#if NET461 || NETSTANDARD

// ReSharper disable once CheckNamespace
namespace System.Diagnostics.CodeAnalysis
{
Expand Down Expand Up @@ -84,3 +86,5 @@ internal sealed class DoesNotReturnIfAttribute : Attribute
public bool ParameterValue { get; }
}
}

#endif
13 changes: 10 additions & 3 deletions src/Scrutor/Scrutor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Description>Register services using assembly scanning and a fluent API.</Description>
<VersionPrefix>3.2.2</VersionPrefix>
<Authors>Kristian Hellang</Authors>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netcoreapp3.1</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>
Expand All @@ -27,10 +27,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.9" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions src/Scrutor/TypeNameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,19 @@ private static void ProcessType(StringBuilder builder, Type type, DisplayNameOpt
private static void ProcessArrayType(StringBuilder builder, Type type, DisplayNameOptions options)
{
var innerType = type;
while (innerType.IsArray)
while (innerType!.IsArray)
{
innerType = innerType.GetElementType();
}

ProcessType(builder, innerType, options);

while (type.IsArray)
while (type!.IsArray)
{
builder.Append('[');
builder.Append(',', type.GetArrayRank() - 1);
builder.Append(']');
type = type.GetElementType();
type = type.GetElementType()!;
}
}

Expand All @@ -114,14 +114,14 @@ private static void ProcessGenericType(StringBuilder builder, Type type, Type[]
var offset = 0;
if (type.IsNested)
{
offset = type.DeclaringType.GetTypeInfo().GenericTypeArguments.Length;
offset = type.DeclaringType!.GetTypeInfo().GenericTypeArguments.Length;
}

if (options.FullName)
{
if (type.IsNested)
{
ProcessGenericType(builder, type.DeclaringType, genericArguments, offset, options);
ProcessGenericType(builder, type.DeclaringType!, genericArguments, offset, options);
builder.Append('+');
}
else if (!string.IsNullOrEmpty(type.Namespace))
Expand Down
4 changes: 2 additions & 2 deletions src/Scrutor/TypeSourceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IImplementationTypeSelector FromExecutingAssembly()

public IImplementationTypeSelector FromEntryAssembly()
{
return FromAssemblies(Assembly.GetEntryAssembly());
return FromAssemblies(Assembly.GetEntryAssembly()!);
}

public IImplementationTypeSelector FromApplicationDependencies()
Expand All @@ -47,7 +47,7 @@ public IImplementationTypeSelector FromApplicationDependencies(Func<Assembly, bo
{
// Something went wrong when loading the DependencyContext, fall
// back to loading all referenced assemblies of the entry assembly...
return FromAssemblyDependencies(Assembly.GetEntryAssembly());
return FromAssemblyDependencies(Assembly.GetEntryAssembly()!);
}
}

Expand Down
17 changes: 13 additions & 4 deletions test/Scrutor.Tests/Scrutor.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Scrutor\Scrutor.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.9" />
</ItemGroup>

</Project>

0 comments on commit 087f844

Please sign in to comment.