Skip to content

Commit

Permalink
Fix dotnet pack.
Browse files Browse the repository at this point in the history
Eliminate build warnings.
  • Loading branch information
fryderykhuang committed Jan 19, 2024
1 parent 1570a19 commit de2bde9
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 70 deletions.
1 change: 0 additions & 1 deletion scripts/Build.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
. $PSScriptRoot\Variables.ps1
Push-Location $SolutionDir

$Env:Platform = ''
foreach ($project in $Projects)
{
dotnet build --no-restore -c Debug .\$project\$project.csproj
Expand Down
13 changes: 6 additions & 7 deletions scripts/Clean.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
. $PSScriptRoot\Variables.ps1
Push-Location $SolutionDir

$Env:Platform = ''
foreach ($project in $Projects)
{
dotnet clean -c Release .\$project\$project.csproj
dotnet clean -c Debug .\$project\$project.csproj
}

$Env:Platform = 'x64'
foreach ($project in $Projects)
{
dotnet clean -c Release .\$project\$project.csproj
dotnet clean -c Debug .\$project\$project.csproj
}
# $Env:Platform = 'x64'
# foreach ($project in $Projects)
# {
# dotnet clean -c Release .\$project\$project.csproj
# dotnet clean -c Debug .\$project\$project.csproj
# }

Pop-Location
11 changes: 5 additions & 6 deletions scripts/CleanAll.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
. $PSScriptRoot\Variables.ps1
Push-Location $SolutionDir

$Env:Platform = ''
dotnet clean -c Release
dotnet clean -c Debug
dotnet clean -c Release
dotnet clean -c Debug

$Env:Platform = 'x64'
dotnet clean -c Release
dotnet clean -c Debug
# $Env:Platform = 'x64'
# dotnet clean -c Release
# dotnet clean -c Debug

Pop-Location
1 change: 0 additions & 1 deletion scripts/Pack.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Push-Location $SolutionDir

if (!(Test-Path -PathType Container $ArtifactsDir)) { New-Item -ItemType Directory -Path $ArtifactsDir }

$Env:Platform = ''
foreach ($project in $Projects) {
dotnet pack --no-build -c Release -o $ArtifactsDir "-p:Version=$Env:GitVersion_NuGetVersionV2" .\$project\$project.csproj
if (!$?) { throw }
Expand Down
1 change: 0 additions & 1 deletion scripts/PublishNuget.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
. $PSScriptRoot\Variables.ps1
Push-Location $SolutionDir
$Env:Platform = ''
foreach ($project in $Projects)
{
dotnet nuget push ".\artifacts\$project.$Env:GitVersion_NuGetVersionV2.nupkg" --skip-duplicate --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json
Expand Down
4 changes: 3 additions & 1 deletion src/NullGC.Abstractions/Collections/IUnsafeArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ public interface IUnsafeArray<T>
///
/// </summary>
/// <remarks>
/// unmanaged constraint is not added to facilitate <
/// unmanaged constraint is not added to allow potential fixable managed pointer implementations.
/// </remarks>
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
unsafe T* Items { get; }
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
int Length { get; }
bool IsInitialized { get; }
}
2 changes: 1 addition & 1 deletion src/NullGC.Abstractions/Extensions/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static ref TValue GetValueRefOrNullRef<TKey, TValue>(this Dictionary<TKey
{
ref var ret = ref CollectionsMarshal.GetValueRefOrNullRef(dict, key);
exists = !Unsafe.IsNullRef(ref ret);
return ref ret;
return ref ret!;
}

public static ref TValue? GetValueRefOrAddDefault<TKey, TValue>(this Dictionary<TKey, TValue> dict, TKey key, out bool exist) where TKey : notnull
Expand Down
5 changes: 3 additions & 2 deletions src/NullGC.Abstractions/FuncInvokers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type

namespace NullGC;

Expand Down Expand Up @@ -387,7 +388,7 @@ public int Compare(RawKeyValuePair<TKey, TValue> a, RawKeyValuePair<TKey, TValue
public StructComparer(Comparison<T> comparer) => _comparer = comparer;

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int Compare(T? x, T? y) => _comparer(x, y);
public int Compare(T? x, T? y) => _comparer(x!, y!);
}

public struct StructComparerWithPtrArg<T, TArg> : IComparer<T> where TArg : unmanaged
Expand All @@ -410,7 +411,7 @@ public int Compare(T? x, T? y)
{
unsafe
{
return _comparer(x, y, ref Unsafe.AsRef<TArg>(_arg));
return _comparer(x!, y!, ref Unsafe.AsRef<TArg>(_arg));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/NullGC.Abstractions/Linq/ILinqRefEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public interface ILinqRefEnumerator<T> : ILinqEnumerator<T>
{
new ref T Current { get; }
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
unsafe T* CurrentPtr { get; }
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
}
8 changes: 4 additions & 4 deletions src/NullGC.Abstractions/NullGC.Abstractions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<PackageReference Include="CommunityToolkit.Diagnostics" Version="8.2.2"/>
</ItemGroup>

<ItemGroup>
<!-- <ItemGroup>-->
<!-- <None Include="bin/x86/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x86\lib\net8.0"/>-->
<!-- <None Include="bin/x86/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x86\lib\net8.0"/>-->
<None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x64\lib\net8.0"/>
<None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x64\lib\net8.0"/>
</ItemGroup>
<!-- <None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x64\lib\net8.0"/>-->
<!-- <None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x64\lib\net8.0"/>-->
<!-- </ItemGroup>-->
</Project>
3 changes: 2 additions & 1 deletion src/NullGC.Abstractions/RefDelegates.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace NullGC;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
namespace NullGC;

public delegate TR FuncT1RefReadOnly<T1, in T2, out TR>(ref readonly T1 t1, T2 t2);

Expand Down
2 changes: 1 addition & 1 deletion src/NullGC.Allocators/DefaultAllocatorContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal ref readonly PerProviderContainer GetPerProviderContainer(int providerI
if (Unsafe.IsNullRef(in ret))
ThrowHelper.ThrowInvalidOperationException($"Provider with ID '{providerId}' is not found.");

return ref ret;
return ref ret!;
}

private ContextContainer? RentContext()
Expand Down
8 changes: 4 additions & 4 deletions src/NullGC.Collections/NullGC.Collections.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.2.2"/>
</ItemGroup>

<ItemGroup>
<!-- <ItemGroup>-->
<!-- <None Include="bin/x86/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x86\lib\net8.0"/>-->
<!-- <None Include="bin/x86/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x86\lib\net8.0"/>-->
<None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x64\lib\net8.0"/>
<None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x64\lib\net8.0"/>
</ItemGroup>
<!-- <None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\win-x64\lib\net8.0"/>-->
<!-- <None Include="bin/x64/$(Configuration)/net8.0/$(TargetFileName)" Pack="true" PackagePath="runtimes\linux-x64\lib\net8.0"/>-->
<!-- </ItemGroup>-->
</Project>
35 changes: 4 additions & 31 deletions src/NullGC.Collections/ThrowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static void ThrowArgumentNullException(string paramName)
[DoesNotReturn]
public static void ThrowArgumentOutOfRange_IndexMustBeLessException()
{
// ReSharper disable once NotResolvedInText
throw new ArgumentOutOfRangeException("index", "IndexMustBeLessException");
}

Expand Down Expand Up @@ -57,6 +58,7 @@ public static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
[DoesNotReturn]
public static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLessOrEqual()
{
// ReSharper disable once NotResolvedInText
throw new ArgumentOutOfRangeException("ArgumentOutOfRange_IndexMustBeLessOrEqual");
}

Expand All @@ -71,31 +73,14 @@ public static void ThrowArgumentException_Argument_IncompatibleArrayType()
{
throw new ArgumentException("Argument_IncompatibleArrayType");
}

[DoesNotReturn]
public static void ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException()
{
throw new ArgumentOutOfRangeException("IndexMustBeLessOrEqualException");
}


[DoesNotReturn]
public static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
{
// ReSharper disable once NotResolvedInText
throw new ArgumentOutOfRangeException("ArgumentOutOfRange_Count");
}

[DoesNotReturn]
public static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLess()
{
throw new ArgumentOutOfRangeException("ArgumentOutOfRange_IndexMustBeLess");
}

[DoesNotReturn]
public static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
{
throw new InvalidOperationException("InvalidOperation_EnumOpCantHappen");
}

[DoesNotReturn]
public static void ThrowKeyNotFoundException<TKey>(TKey key) where TKey : notnull
{
Expand All @@ -114,18 +99,6 @@ public static void ThrowAddingDuplicateWithKeyArgumentException<TKey>(TKey key)
throw new ArgumentException($"AddingDuplicateWithKey {key}");
}

[DoesNotReturn]
public static void ThrowWrongKeyTypeArgumentException(object? key, Type type)
{
throw new ArgumentException($"WrongKeyType {key} {type}");
}

[DoesNotReturn]
public static void ThrowNotSupportedException(string message)
{
throw new NotSupportedException(message);
}

[DoesNotReturn]
public static void ThrowNoMoreElements()
{
Expand Down
21 changes: 15 additions & 6 deletions src/NullGC.DragRace/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class InProcConfig : ConfigBase
{
public InProcConfig()
{
AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})
AddJob(Job.ShortRun//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")})
.WithToolchain(InProcessNoEmitToolchain.Instance))
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
.AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
Expand All @@ -38,7 +38,7 @@ internal class FastConfig : ConfigBase
{
public FastConfig()
{
AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
AddJob(Job.ShortRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
.AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
.AddLogger(new ConsoleLogger());
Expand All @@ -49,7 +49,7 @@ internal class NormalConfig : ConfigBase
{
public NormalConfig()
{
AddJob(Job.MediumRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
AddJob(Job.MediumRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
.AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
.AddLogger(new ConsoleLogger());
}
Expand All @@ -59,7 +59,7 @@ internal class CicdConfig : ConfigBase
{
public CicdConfig()
{
AddJob(Job.ShortRun.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
AddJob(Job.ShortRun)//.WithArguments(new[] {new MsBuildArgument("/p:Platform=x64")}))
.AddDiagnoser(new MemoryDiagnoser(new MemoryDiagnoserConfig(true)))
.AddExporter(new JsonExporter()).AddExporter(new HtmlExporter())
.AddColumnProvider(DefaultColumnProviders.Instance)
Expand Down Expand Up @@ -106,6 +106,15 @@ public ConfigBase AddExporter(params IExporter[] newExporters)
this.exporters.AddRange(newExporters);
return this;
}

public ConfigBase AddHardwareCounters(params HardwareCounter[] newHardwareCounters)
{
foreach (var counter in newHardwareCounters)
{
this.hardwareCounters.Add(counter);
}
return this;
}

public IEnumerable<IColumnProvider> GetColumnProviders()
{
Expand Down Expand Up @@ -146,13 +155,13 @@ public IEnumerable<IValidator> GetValidators()
yield return (IValidator) ParamsValidator.FailOnError;
}

public IOrderer Orderer => null;
public IOrderer? Orderer => null;

public ICategoryDiscoverer? CategoryDiscoverer => null;

public ConfigUnionRule UnionRule => ConfigUnionRule.Union;

public CultureInfo CultureInfo => null;
public CultureInfo? CultureInfo => null;

public ConfigOptions Options { get; set; } = ConfigOptions.Default;

Expand Down
14 changes: 13 additions & 1 deletion src/NullGC.Linq/Enumerators/ArrayLinqRefEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ public void Reset()
}

T IEnumerator<T>.Current => Current;
public unsafe T* CurrentPtr => (T*) Unsafe.AsPointer(ref _array[_index]);
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
public unsafe T* CurrentPtr
#pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type
{
get
{
CommunityToolkit.Diagnostics.ThrowHelper
.ThrowNotSupportedException();
return default;
//(T*) Unsafe.AsPointer(ref _array[_index]);
}
}

object? IEnumerator.Current => Current;

public int? Count => _length;
Expand Down
1 change: 1 addition & 0 deletions src/NullGC.Linq/Enumerators/Select.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Runtime.CompilerServices;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type

namespace NullGC.Linq.Enumerators;

Expand Down
1 change: 1 addition & 0 deletions src/NullGC.Linq/Enumerators/Skip.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Runtime.CompilerServices;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type

namespace NullGC.Linq.Enumerators;
public struct SkipRef<T, TPrevious> : ILinqRefEnumerator<T>,
Expand Down
1 change: 1 addition & 0 deletions src/NullGC.Linq/Enumerators/Take.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections;
using System.Runtime.CompilerServices;
using CommunityToolkit.Diagnostics;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type

namespace NullGC.Linq.Enumerators;

Expand Down
1 change: 1 addition & 0 deletions src/NullGC.Linq/Enumerators/Where.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using System.Runtime.CompilerServices;
#pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type

namespace NullGC.Linq.Enumerators;

Expand Down
4 changes: 2 additions & 2 deletions src/NullGC.Linq/LinqExtensions.First.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static ref T First<T, TEnumerator>(this LinqRefEnumerable<T, TEnumerator>
{
ref var ret = ref FirstOrNullRef(src, predicate);
if (Unsafe.IsNullRef(ref ret)) ThrowHelper.SequenceContainsNoElement();
return ref ret;
return ref ret!;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -59,7 +59,7 @@ public static ref T First<T, TEnumerator, TArg>(this LinqRefEnumerable<T, TEnume
{
ref var ret = ref FirstOrNullRef<T, TEnumerator, TArg>(src, predicate, arg);
if (Unsafe.IsNullRef(ref ret)) ThrowHelper.SequenceContainsNoElement();
return ref ret;
return ref ret!;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down

0 comments on commit de2bde9

Please sign in to comment.