From 3f95883da6d39224b0d96e365a7d04c35c24b656 Mon Sep 17 00:00:00 2001 From: zengwenjie <1663900244@qq.com> Date: Fri, 26 Sep 2025 11:52:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8[NotNullWhen(true)]=E6=A0=87?= =?UTF-8?q?=E8=AE=B0=E3=80=8CTryGetParamDefine=E3=80=8D=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Deedy.Activity/Collection/ActionTemplateCollection.cs | 3 ++- .../Deedy.Activity/Collection/ParamDefineCollection.cs | 4 ++-- DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/DeedyDesigner/Deedy.Activity/Collection/ActionTemplateCollection.cs b/DeedyDesigner/Deedy.Activity/Collection/ActionTemplateCollection.cs index a86ccb8..ccae047 100644 --- a/DeedyDesigner/Deedy.Activity/Collection/ActionTemplateCollection.cs +++ b/DeedyDesigner/Deedy.Activity/Collection/ActionTemplateCollection.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -14,7 +15,7 @@ namespace Deedy.Activity public class ActionTemplateCollection : ObservableCollection { public ActionTemplateCollection() { } - public bool TryGetTemplate(Type type, out DataTemplate template) + public bool TryGetTemplate(Type type, [NotNullWhen(true)] out DataTemplate template) { DataTemplate dataTemplate = new DataTemplate(typeof(IActionElement)); bool result = false; diff --git a/DeedyDesigner/Deedy.Activity/Collection/ParamDefineCollection.cs b/DeedyDesigner/Deedy.Activity/Collection/ParamDefineCollection.cs index 46dcdb1..e8235de 100644 --- a/DeedyDesigner/Deedy.Activity/Collection/ParamDefineCollection.cs +++ b/DeedyDesigner/Deedy.Activity/Collection/ParamDefineCollection.cs @@ -16,9 +16,9 @@ namespace Deedy.Activity public class ParamDefineCollection : InitialSortedObservableCollection { internal ParamDefineCollection() { } - public bool TryGetParamDefine(string name, [NotNull] out ParamDefineAttribute value) + public bool TryGetParamDefine(string name, [NotNullWhen(true)] out ParamDefineAttribute? value) { - ParamDefineAttribute pda = new(); + ParamDefineAttribute? pda = null; bool result = false; foreach (var item in this) diff --git a/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs b/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs index 545b030..e43a34b 100644 --- a/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs +++ b/DeedyDesigner/Deedy.Activity/Helpers/ElementHelper.cs @@ -111,11 +111,11 @@ namespace Deedy.Activity var pda = prop.GetCustomAttribute(); if (pda != null) { - pda.Name = prop.Name; if (element.ParamsMapping.TryGetParamDefine(prop.Name, out var value)) pda = value; else element.ParamsMapping.Add(pda); - value.Target = element; - value.Property = prop; + pda.Name = prop.Name; + pda.Target = element; + pda.Property = prop; } } }