From 27d4bb7cefe9960259d2f47f4bc90e9adac22eb0 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Fri, 8 Oct 2021 17:21:39 +0800 Subject: [PATCH] Fix the exception that the consumer name is null. --- .dockerignore | 25 ------- build/version.props | 4 +- src/DotNetCore.CAP/CAP.Attribute.cs | 66 +++++++++---------- .../IConsumerServiceSelector.Default.cs | 7 +- 4 files changed, 41 insertions(+), 61 deletions(-) delete mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 3729ff0..0000000 --- a/.dockerignore +++ /dev/null @@ -1,25 +0,0 @@ -**/.classpath -**/.dockerignore -**/.env -**/.git -**/.gitignore -**/.project -**/.settings -**/.toolstarget -**/.vs -**/.vscode -**/*.*proj.user -**/*.dbmdl -**/*.jfm -**/azds.yaml -**/bin -**/charts -**/docker-compose* -**/Dockerfile* -**/node_modules -**/npm-debug.log -**/obj -**/secrets.dev.yaml -**/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/build/version.props b/build/version.props index 2181d53..c6f1c59 100644 --- a/build/version.props +++ b/build/version.props @@ -1,8 +1,8 @@ 5 - 1 - 4 + 2 + 0 $(VersionMajor).$(VersionMinor).$(VersionPatch) diff --git a/src/DotNetCore.CAP/CAP.Attribute.cs b/src/DotNetCore.CAP/CAP.Attribute.cs index d77df33..d2c886d 100644 --- a/src/DotNetCore.CAP/CAP.Attribute.cs +++ b/src/DotNetCore.CAP/CAP.Attribute.cs @@ -1,39 +1,39 @@ -// Copyright (c) .NET Core Community. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using DotNetCore.CAP.Internal; - -// ReSharper disable once CheckNamespace -namespace DotNetCore.CAP -{ - public class CapSubscribeAttribute : TopicAttribute +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using DotNetCore.CAP.Internal; + +// ReSharper disable once CheckNamespace +namespace DotNetCore.CAP +{ + public class CapSubscribeAttribute : TopicAttribute { - public CapSubscribeAttribute(string name, bool isPartial = false) - : base(name, isPartial) + public CapSubscribeAttribute(string name, bool isPartial = false) + : base(name, isPartial) { } - public override string ToString() - { - return Name; - } - } - - [AttributeUsage(AttributeTargets.Parameter)] - public class FromCapAttribute : Attribute - { - - } - - public class CapHeader : ReadOnlyDictionary - { - public CapHeader(IDictionary dictionary) : base(dictionary) - { - - } - } + public override string ToString() + { + return Name; + } + } + + [AttributeUsage(AttributeTargets.Parameter)] + public class FromCapAttribute : Attribute + { + + } + + public class CapHeader : ReadOnlyDictionary + { + public CapHeader(IDictionary dictionary) : base(dictionary) + { + + } + } } \ No newline at end of file diff --git a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs index be718be..8939e0a 100644 --- a/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs +++ b/src/DotNetCore.CAP/Internal/IConsumerServiceSelector.Default.cs @@ -131,7 +131,7 @@ namespace DotNetCore.CAP.Internal // Ignore partial attributes when no topic attribute is defined on class. if (topicClassAttribute is null) { - topicMethodAttributes = topicMethodAttributes.Where(x => !x.IsPartial); + topicMethodAttributes = topicMethodAttributes.Where(x => !x.IsPartial && x.Name != null); } if (!topicMethodAttributes.Any()) @@ -189,6 +189,11 @@ namespace DotNetCore.CAP.Internal private ConsumerExecutorDescriptor MatchUsingName(string key, IReadOnlyList executeDescriptor) { + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + return executeDescriptor.FirstOrDefault(x => x.TopicName.Equals(key, StringComparison.InvariantCultureIgnoreCase)); }