Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Nov 13, 2023
1 parent c7e16c2 commit 6b17416
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.13.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Backgrounder.Azure.ServiceBus\Backgrounder.Azure.ServiceBus.csproj" />
<ProjectReference Include="..\..\src\Backgrounder.Generators\Backgrounder.Generators.csproj">
Expand Down
8 changes: 0 additions & 8 deletions samples/Backgrounder.Sample.Library/IsExternalInit.cs

This file was deleted.

49 changes: 21 additions & 28 deletions samples/Backgrounder.Sample.Library/LibraryJobs.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
using System;
using System.Threading.Tasks;

namespace Backgrounder.Sample.Library
namespace Backgrounder.Sample.Library;

public class LibraryJobs
{
public class LibraryJobs
[BackgroundOperation]
public Task LibraryWork(int? jobId)
{
[BackgroundOperation]
public Task DoWork(int? jobId)
{
return Task.FromResult(jobId);
}

[BackgroundOperation]
public Task CompleteWork(int jobId)
{
return Task.FromResult(jobId);
}

[BackgroundOperation]
public static Task StaticWork(int jobId)
{
return Task.FromResult(jobId);
}

return Task.FromResult(jobId);
}

[BackgroundOperation(ExtensionName = "RunScheduler")]
public Task RunSchedule()
{
return Task.CompletedTask;
}
[BackgroundOperation]
public Task LibraryCompleteWork(int jobId)
{
return Task.FromResult(jobId);
}

[BackgroundOperation]
public static Task LibraryStaticWork(int jobId)
{
return Task.FromResult(jobId);
}
}


namespace System.Runtime.CompilerServices
{
[BackgroundOperation(ExtensionName = "LibraryScheduler")]
public Task RunSchedule()
{
return Task.CompletedTask;
}
}
31 changes: 0 additions & 31 deletions samples/Backgrounder.Sample.Library/ModuleInitializerAttribute.cs

This file was deleted.

1 change: 1 addition & 0 deletions samples/Backgrounder.Sample/Backgrounder.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
<OutputItemType>Analyzer</OutputItemType>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\Backgrounder.Sample.Library\Backgrounder.Sample.Library.csproj" />
</ItemGroup>
</Project>
40 changes: 0 additions & 40 deletions samples/Backgrounder.Sample/Generated.cs

This file was deleted.

3 changes: 3 additions & 0 deletions samples/Backgrounder.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using Backgrounder.Sample.Library;

namespace Backgrounder.Sample;

Expand Down Expand Up @@ -27,6 +28,8 @@ public static async Task Main(string[] args)
await backgrounder.CheckPerson(new Person { Name = "Test" });
await backgrounder.RunScheduler();

await backgrounder.LibraryWork(123);

await host.RunAsync();
}
}
2 changes: 1 addition & 1 deletion samples/Backgrounder.Sample/SampleJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public SampleJob(ILogger<Worker> logger)
_logger = logger;
}

//[BackgroundOperation]
[BackgroundOperation]
public Task DoWork(int? jobId)
{
_logger.LogInformation("DoWork Job {JobId}", jobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MessagePackMessageSerializer : IMessageSerializer
private readonly MessagePackSerializerOptions _messagePackSerializerOptions;

/// <summary>
/// Initializes a new instance of the <see cref="MessagePackCacheSerializer"/> class.
/// Initializes a new instance of the <see cref="MessagePackMessageSerializer"/> class.
/// </summary>
/// <param name="messagePackSerializerOptions">The message pack serializer options.</param>
public MessagePackMessageSerializer(MessagePackSerializerOptions? messagePackSerializerOptions = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Backgrounder.Generators/BackgroundGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ private static void InitializeAttribute(IncrementalGeneratorInitializationContex

// Emit the diagnostics, if needed
var diagnostics = provider
.Select(static (item, _) => item.Diagnostics)
.Select(static (item, _) => item!.Diagnostics)
.Where(static item => item.Count > 0);

context.RegisterSourceOutput(diagnostics, ReportDiagnostic);

var backgroundMethods = provider
.Select(static (item, _) => item.Method)
.Select(static (item, _) => item!.Method)
.Where(static item => item is not null);

context.RegisterSourceOutput(backgroundMethods, Execute);
Expand Down
8 changes: 3 additions & 5 deletions src/Backgrounder.Generators/Internal/HashCode.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Backgrounder.Generators.Internal;

/// <summary>
Expand Down Expand Up @@ -73,7 +71,7 @@ public HashCode Combine(string value)
/// </summary>
/// <param name="value">The value to combine hash codes with.</param>
/// <returns>A new hash code combined with this and the values hash codes.</returns>
public HashCode Combine(object value)
public HashCode Combine(object? value)
{
// need to handle string values deterministically
return value switch
Expand All @@ -89,7 +87,7 @@ public HashCode Combine(object value)
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="values">The values to combine hash codes with.</param>
/// <returns>A new hash code combined with this and the values hash codes.</returns>
public HashCode CombineAll<TValue>(IEnumerable<TValue> values)
public HashCode CombineAll<TValue>(IEnumerable<TValue>? values)
{
if (values == null)
return this;
Expand Down Expand Up @@ -171,7 +169,7 @@ public HashCode CombineAll<TValue>(IEnumerable<TValue> values)
/// <returns>
/// <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object other) => other is HashCode code && Equals(code);
public override bool Equals(object? other) => other is HashCode code && Equals(code);

/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
Expand Down

0 comments on commit 6b17416

Please sign in to comment.