Skip to content

Commit b899754

Browse files
authored
.NET 9 (#13)
(signed) +semver:major
1 parent 9ece67f commit b899754

File tree

72 files changed

+670
-797
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+670
-797
lines changed

source/.editorconfig .editorconfig

+20-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ root = true
33

44
[*]
55
charset = utf-8
6+
insert_final_newline = true
67

78
# C# files
89
[*.cs]
@@ -15,8 +16,8 @@ indent_style = space
1516
tab_width = 4
1617

1718
# New line preferences
18-
end_of_line = crlf
19-
insert_final_newline = true
19+
trim_trailing_whitespace = true
20+
2021

2122
#### .NET Coding Conventions ####
2223

@@ -37,7 +38,7 @@ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
3738
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
3839

3940
# Modifier preferences
40-
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
41+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
4142

4243
# Expression-level preferences
4344
csharp_style_deconstructed_variable_declaration = true:suggestion
@@ -65,9 +66,9 @@ dotnet_code_quality_unused_parameters = all:suggestion
6566
#### C# Coding Conventions ####
6667

6768
# var preferences
68-
csharp_style_var_elsewhere = false:silent
69-
csharp_style_var_for_built_in_types = false:silent
70-
csharp_style_var_when_type_is_apparent = false:silent
69+
csharp_style_var_elsewhere = true:silent
70+
csharp_style_var_for_built_in_types = true:silent
71+
csharp_style_var_when_type_is_apparent = true:silent
7172

7273
# Expression-bodied members
7374
csharp_style_expression_bodied_accessors = true:silent
@@ -87,7 +88,7 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
8788
csharp_style_conditional_delegate_call = true:suggestion
8889

8990
# Modifier preferences
90-
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
91+
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async
9192

9293
# Code-block preferences
9394
csharp_prefer_braces = true:silent
@@ -100,6 +101,12 @@ csharp_style_prefer_range_operator = true:suggestion
100101
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
101102
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
102103

104+
# C# 10
105+
csharp_style_namespace_declarations = file_scoped:error
106+
csharp_style_prefer_primary_constructors = true
107+
dotnet_diagnostic.IDE0290.severity = error
108+
109+
103110
#### C# Formatting Rules ####
104111

105112
# New line preferences
@@ -146,3 +153,9 @@ csharp_space_between_square_brackets = false
146153
# Wrapping preferences
147154
csharp_preserve_single_line_blocks = true
148155
csharp_preserve_single_line_statements = true
156+
157+
158+
[*.csproj]
159+
indent_size = 2
160+
indent_style = space
161+
tab_width = 2

.github/workflows/CI.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
2020
- name: Setup .NET
21-
uses: actions/setup-dotnet@v3
21+
uses: actions/setup-dotnet@v4
2222
with:
23-
dotnet-version: 8.0.x
23+
dotnet-version: 9.0.x
2424
- name: Restore dependencies
2525
run: dotnet restore source
2626
- name: Build

.github/workflows/PreRelease.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- run: echo "ACTIONS_ALLOW_UNSECURE_COMMANDS=true" >> $GITHUB_ENV
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v3
2121
with:
22-
dotnet-version: "8.0.x"
22+
dotnet-version: "9.0.x"
2323
- name: Determine Version
2424
id: gitversion
2525
uses: gittools/actions/gitversion/execute@v0

.github/workflows/Release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v3
11+
- uses: actions/checkout@v4
1212
with:
1313
fetch-depth: 0
1414
- run: echo "ACTIONS_ALLOW_UNSECURE_COMMANDS=true" >> $GITHUB_ENV
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup .NET
2020
uses: actions/setup-dotnet@v3
2121
with:
22-
dotnet-version: "8.0.x"
22+
dotnet-version: "9.0.x"
2323
- name: Determine Version
2424
id: gitversion
2525
uses: gittools/actions/gitversion/execute@v0

Samples/HelloWorld/HelloWorld.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<LangVersion>latest</LangVersion>

readme.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Slackbot.NET
22

3-
43
[![Build](https://github.com/slackbot-net/slackbot.net/workflows/CI/badge.svg)](https://github.com/slackbot.net/slackbot.net/actions)
54

6-
75
## What?
6+
87
An opinionated ASP.NET Core middleware to create simple Slackbots using the Slack event API.
98

109
### Install
11-
Download it from NuGet:[![NuGet](https://img.shields.io/nuget/dt/slackbot.net.endpoints.svg)](https://www.nuget.org/packages/slackbot.net.endpoints/)
10+
11+
Download it from
12+
NuGet:[![NuGet](https://img.shields.io/nuget/dt/slackbot.net.endpoints.svg)](https://www.nuget.org/packages/slackbot.net.endpoints/)
1213

1314
### Docs
1415

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
namespace Slackbot.Net.Endpoints.Abstractions;
22

3-
public class EventHandledResponse
3+
public class EventHandledResponse(string response)
44
{
5-
public string Response { get; }
6-
7-
public EventHandledResponse(string response)
8-
{
9-
Response = response;
10-
}
11-
}
5+
public string Response { get; } = response;
6+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleAppHomeOpened.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleAppHomeOpened
66
{
77
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppHomeOpenedEvent payload);
8-
}
8+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleAppMentions.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleAppMentions
66
{
77
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppMentionEvent slackEvent);
8-
bool ShouldHandle(AppMentionEvent slackEvent) => true;
9-
(string HandlerTrigger, string Description) GetHelpDescription() => ("", "");
10-
}
8+
9+
bool ShouldHandle(AppMentionEvent slackEvent)
10+
{
11+
return true;
12+
}
13+
14+
(string HandlerTrigger, string Description) GetHelpDescription()
15+
{
16+
return ("", "");
17+
}
18+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleInteractiveBlockActions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleInteractiveBlockActions
66
{
77
Task<EventHandledResponse> Handle(BlockActionInteraction blockActionEvent);
8-
}
8+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleMemberJoinedChannel.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleMemberJoinedChannel
66
{
77
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, MemberJoinedChannelEvent memberjoined);
8-
}
8+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleMessageActions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleMessageActions
66
{
77
Task<EventHandledResponse> Handle(MessageActionInteraction blockActionEvent);
8-
}
8+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IHandleViewSubmissions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
55
public interface IHandleViewSubmissions
66
{
77
Task<EventHandledResponse> Handle(ViewSubmission payload);
8-
}
8+
}

source/src/Slackbot.Net.Endpoints/Abstractions/INoOpAppMentions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
22

33
public interface INoOpAppMentions : IHandleAppMentions
44
{
5-
6-
}
5+
}

source/src/Slackbot.Net.Endpoints/Abstractions/ISelectAppMentionEventHandlers.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ namespace Slackbot.Net.Endpoints.Abstractions;
44

55
public interface ISelectAppMentionEventHandlers
66
{
7-
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent);
8-
}
7+
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata,
8+
AppMentionEvent slackEvent);
9+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IShortcutHandlers.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ public interface IShortcutAppMentions
66
{
77
Task Handle(EventMetaData eventMetadata, AppMentionEvent @event);
88
bool ShouldShortcut(AppMentionEvent @event);
9-
}
9+
}

source/src/Slackbot.Net.Endpoints/Abstractions/IUninstall.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ namespace Slackbot.Net.Endpoints.Abstractions;
33
public interface IUninstall
44
{
55
Task OnUninstalled(string teamId, string teamName);
6-
}
6+
}

source/src/Slackbot.Net.Endpoints/AppMentionEventHandlerSelector.cs

+18-21
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@
55

66
namespace Slackbot.Net.Endpoints;
77

8-
internal class AppMentionEventHandlerSelector : ISelectAppMentionEventHandlers
8+
internal class AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider)
9+
: ISelectAppMentionEventHandlers
910
{
10-
private readonly ILoggerFactory _loggerFactory;
11-
private readonly IServiceProvider _provider;
12-
13-
public AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider)
14-
{
15-
_loggerFactory = loggerFactory;
16-
_provider = provider;
17-
}
18-
19-
public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent)
11+
public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata,
12+
AppMentionEvent slackEvent)
2013
{
21-
var allHandlers = _provider.GetServices<IHandleAppMentions>();
22-
var shortCutter = _provider.GetService<IShortcutAppMentions>();
23-
var noopHandler = _provider.GetService<INoOpAppMentions>();
14+
var allHandlers = provider.GetServices<IHandleAppMentions>();
15+
var shortCutter = provider.GetService<IShortcutAppMentions>();
16+
var noopHandler = provider.GetService<INoOpAppMentions>();
2417

2518
if (shortCutter != null && shortCutter.ShouldShortcut(slackEvent))
2619
{
@@ -29,21 +22,25 @@ public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(
2922
}
3023

3124
return SelectHandler(allHandlers, noopHandler, slackEvent);
32-
3325
}
3426

35-
private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers, INoOpAppMentions noOpAppMentions, AppMentionEvent message)
27+
private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers,
28+
INoOpAppMentions noOpAppMentions, AppMentionEvent message)
3629
{
3730
var matchingHandlers = handlers.Where(s => s.ShouldHandle(message));
3831
if (matchingHandlers.Any())
32+
{
3933
return matchingHandlers;
40-
41-
if(noOpAppMentions != null)
34+
}
35+
36+
if (noOpAppMentions != null)
37+
{
4238
return new List<IHandleAppMentions> { noOpAppMentions };
43-
39+
}
40+
4441
return new List<IHandleAppMentions>
4542
{
46-
new NoOpAppMentionEventHandler(_loggerFactory.CreateLogger<NoOpAppMentionEventHandler>())
43+
new NoOpAppMentionEventHandler(loggerFactory.CreateLogger<NoOpAppMentionEventHandler>())
4744
};
4845
}
49-
}
46+
}

source/src/Slackbot.Net.Endpoints/Authentication/AuthenticationBuilderExtensions.cs

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ namespace Slackbot.Net.Endpoints.Authentication;
66

77
public static class AuthenticationBuilderExtensions
88
{
9-
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder, Action<SlackbotEventsAuthenticationOptions> optionsAction)
9+
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder,
10+
Action<SlackbotEventsAuthenticationOptions> optionsAction)
1011
{
1112
builder.Services.Configure(optionsAction);
12-
return builder.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction);
13+
return builder
14+
.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(
15+
SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction);
1316
}
1417
}
1518

1619
public class SlackbotEventsAuthenticationOptions : AuthenticationSchemeOptions
1720
{
18-
[Required]
19-
public string SigningSecret { get; set; }
21+
[Required] public string SigningSecret { get; set; }
2022
}
2123

2224
public static class SlackbotEventsAuthenticationConstants
2325
{
2426
public const string AuthenticationScheme = "SlacbotEventsAuthenticationScheme";
25-
}
27+
}

0 commit comments

Comments
 (0)