Skip to content

Commit

Permalink
Update to .NET 6 RTM (#7)
Browse files Browse the repository at this point in the history
* Implicit usings + file-scoped ns

* Make Shared lib a P2P dep and dont publish to nuget.org

* Update CI.yml to RTM of .NET 6

* Delete Cake remnants

* RTM version of .NET 6 in release pipes

* Drop .NET 5

* Remove .NET 3.1 SDK from all pipes
  • Loading branch information
johnkors authored Nov 9, 2021
1 parent 2c92b16 commit 01e3107
Show file tree
Hide file tree
Showing 101 changed files with 2,081 additions and 2,291 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- uses: actions/checkout@v2
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.100-rc.2.21458.9"
dotnet-version: "6.0.x"
- name: Restore dependencies
run: dotnet restore source
- name: Build
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/PreRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
Expand All @@ -27,7 +23,7 @@ jobs:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.100-rc.2.21458.9"
dotnet-version: "6.0.x"
include-prerelease: true
- name: Determine Version
id: gitversion
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
- name: Setup .NET 5
uses: actions/setup-dotnet@v1
with:
Expand All @@ -27,7 +23,7 @@ jobs:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: "6.0.100-rc.2.21458.9"
dotnet-version: "6.0.x"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions Samples/HelloWorld/HelloWorld.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<LangVersion>latest</LangVersion>
</PropertyGroup>


<ItemGroup>
<ProjectReference Include="..\..\source\src\Slackbot.Net.Endpoints\Slackbot.Net.Endpoints.csproj" />
Expand Down
1 change: 0 additions & 1 deletion Samples/HelloWorld/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Slackbot.Net.Endpoints.Abstractions;
using Slackbot.Net.Endpoints.Models.Events;


var builder = WebApplication.CreateBuilder(args);

// Needed in production to verify that incoming event payloads are from Slack
Expand Down
1 change: 0 additions & 1 deletion source/Slackbot.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ProjectSection(SolutionItems) = preProject
..\CI.yml = ..\.github\workflows\CI.yml
..\Release.yml = ..\.github\workflows\Release.yml
..\PreRelease.yml = ..\.github\workflows\PreRelease.yml
..\tools\packages.config = ..\tools\packages.config
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "..\Samples\HelloWorld\HelloWorld.csproj", "{15519075-7574-4F9B-820F-D8F7190AF460}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public class EventHandledResponse
{
public class EventHandledResponse
{
public string Response { get; }
public string Response { get; }

public EventHandledResponse(string response)
{
Response = response;
}
public EventHandledResponse(string response)
{
Response = response;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IHandleAppHomeOpened
{
public interface IHandleAppHomeOpened
{
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppHomeOpenedEvent payload);
}
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppHomeOpenedEvent payload);
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IHandleAppMentions
{
public interface IHandleAppMentions
{
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppMentionEvent slackEvent);
bool ShouldHandle(AppMentionEvent slackEvent) => true;
(string HandlerTrigger, string Description) GetHelpDescription() => ("", "");
}
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppMentionEvent slackEvent);
bool ShouldHandle(AppMentionEvent slackEvent) => true;
(string HandlerTrigger, string Description) GetHelpDescription() => ("", "");
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Interactive.BlockActions;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IHandleInteractiveBlockActions
{
public interface IHandleInteractiveBlockActions
{
Task<EventHandledResponse> Handle(BlockActionInteraction blockActionEvent);
}
Task<EventHandledResponse> Handle(BlockActionInteraction blockActionEvent);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IHandleMemberJoinedChannel
{
public interface IHandleMemberJoinedChannel
{
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, MemberJoinedChannelEvent memberjoined);
}
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, MemberJoinedChannelEvent memberjoined);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Interactive.ViewSubmissions;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IHandleViewSubmissions
{
public interface IHandleViewSubmissions
{
Task<EventHandledResponse> Handle(ViewSubmission payload);
}
Task<EventHandledResponse> Handle(ViewSubmission payload);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface INoOpAppMentions : IHandleAppMentions
{
public interface INoOpAppMentions : IHandleAppMentions
{

}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface ISelectAppMentionEventHandlers
{
public interface ISelectAppMentionEventHandlers
{
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent);
}
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent);
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Threading.Tasks;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints.Abstractions
namespace Slackbot.Net.Endpoints.Abstractions;

public interface IShortcutAppMentions
{
public interface IShortcutAppMentions
{
Task Handle(EventMetaData eventMetadata, AppMentionEvent @event);
bool ShouldShortcut(AppMentionEvent @event);
}
Task Handle(EventMetaData eventMetadata, AppMentionEvent @event);
bool ShouldShortcut(AppMentionEvent @event);
}
11 changes: 4 additions & 7 deletions source/src/Slackbot.Net.Endpoints/Abstractions/IUninstall.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System.Threading.Tasks;
namespace Slackbot.Net.Endpoints.Abstractions;

namespace Slackbot.Net.Endpoints.Abstractions
public interface IUninstall
{
public interface IUninstall
{
Task OnUninstalled(string teamId, string teamName);
}
}
Task OnUninstalled(string teamId, string teamName);
}
69 changes: 32 additions & 37 deletions source/src/Slackbot.Net.Endpoints/AppMentionEventHandlerSelector.cs
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Slackbot.Net.Endpoints.Abstractions;
using Slackbot.Net.Endpoints.Models.Events;

namespace Slackbot.Net.Endpoints
namespace Slackbot.Net.Endpoints;

internal class AppMentionEventHandlerSelector : ISelectAppMentionEventHandlers
{
internal class AppMentionEventHandlerSelector : ISelectAppMentionEventHandlers
private readonly ILoggerFactory _loggerFactory;
private readonly IServiceProvider _provider;

public AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider)
{
private readonly ILoggerFactory _loggerFactory;
private readonly IServiceProvider _provider;
_loggerFactory = loggerFactory;
_provider = provider;
}

public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent)
{
var allHandlers = _provider.GetServices<IHandleAppMentions>();
var shortCutter = _provider.GetService<IShortcutAppMentions>();
var noopHandler = _provider.GetService<INoOpAppMentions>();

public AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider)
if (shortCutter != null && shortCutter.ShouldShortcut(slackEvent))
{
_loggerFactory = loggerFactory;
_provider = provider;
await shortCutter.Handle(eventMetadata, slackEvent);
return new List<IHandleAppMentions>();
}

public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent)
{
var allHandlers = _provider.GetServices<IHandleAppMentions>();
var shortCutter = _provider.GetService<IShortcutAppMentions>();
var noopHandler = _provider.GetService<INoOpAppMentions>();

if (shortCutter != null && shortCutter.ShouldShortcut(slackEvent))
{
await shortCutter.Handle(eventMetadata, slackEvent);
return new List<IHandleAppMentions>();
}

return SelectHandler(allHandlers, noopHandler, slackEvent);
return SelectHandler(allHandlers, noopHandler, slackEvent);

}
}

private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers, INoOpAppMentions noOpAppMentions, AppMentionEvent message)
{
var matchingHandlers = handlers.Where(s => s.ShouldHandle(message));
if (matchingHandlers.Any())
return matchingHandlers;
private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers, INoOpAppMentions noOpAppMentions, AppMentionEvent message)
{
var matchingHandlers = handlers.Where(s => s.ShouldHandle(message));
if (matchingHandlers.Any())
return matchingHandlers;

if(noOpAppMentions != null)
return new List<IHandleAppMentions> { noOpAppMentions };
if(noOpAppMentions != null)
return new List<IHandleAppMentions> { noOpAppMentions };

return new List<IHandleAppMentions>
{
new NoOpAppMentionEventHandler(_loggerFactory.CreateLogger<NoOpAppMentionEventHandler>())
};
}
return new List<IHandleAppMentions>
{
new NoOpAppMentionEventHandler(_loggerFactory.CreateLogger<NoOpAppMentionEventHandler>())
};
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
using System;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;

namespace Slackbot.Net.Endpoints.Authentication
{
public static class AuthenticationBuilderExtensions
{
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder, Action<SlackbotEventsAuthenticationOptions> optionsAction)
{
builder.Services.Configure(optionsAction);
return builder.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction);
}
}
namespace Slackbot.Net.Endpoints.Authentication;

public class SlackbotEventsAuthenticationOptions : AuthenticationSchemeOptions
public static class AuthenticationBuilderExtensions
{
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder, Action<SlackbotEventsAuthenticationOptions> optionsAction)
{
[Required]
public string SigningSecret { get; set; }
builder.Services.Configure(optionsAction);
return builder.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction);
}
}

public static class SlackbotEventsAuthenticationConstants
{
public const string AuthenticationScheme = "SlacbotEventsAuthenticationScheme";
}
public class SlackbotEventsAuthenticationOptions : AuthenticationSchemeOptions
{
[Required]
public string SigningSecret { get; set; }
}

public static class SlackbotEventsAuthenticationConstants
{
public const string AuthenticationScheme = "SlacbotEventsAuthenticationScheme";
}
Loading

0 comments on commit 01e3107

Please sign in to comment.