File tree Expand file tree Collapse file tree
GameFrameX.Foundation.Options Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -291,41 +291,21 @@ private void ValidateRequiredOptions(T target)
291291 bool isRequired = false ;
292292 string optionName = property . Name . ToLowerInvariant ( ) . Replace ( "_" , "-" ) ;
293293
294- // 检查是否有必需选项特性
295- var requiredOptionAttrs = property . GetCustomAttributes < RequiredOptionAttribute > ( ) . ToList ( ) ;
296- foreach ( var requiredOptionAttr in requiredOptionAttrs )
294+ // 仅基于 OptionAttribute 的 Required 标志进行校验
295+ var optionAttrs = property . GetCustomAttributes < OptionAttribute > ( ) . ToList ( ) ;
296+ foreach ( var optionAttr in optionAttrs )
297297 {
298- if ( requiredOptionAttr . Required )
298+ if ( optionAttr . Required )
299299 {
300300 isRequired = true ;
301- if ( ! string . IsNullOrEmpty ( requiredOptionAttr . LongName ) )
301+ if ( ! string . IsNullOrEmpty ( optionAttr . LongName ) )
302302 {
303- optionName = requiredOptionAttr . LongName ;
303+ optionName = optionAttr . LongName ;
304304 }
305-
306305 break ;
307306 }
308307 }
309308
310- // 检查选项特性中的必需标志
311- if ( ! isRequired )
312- {
313- var optionAttrs = property . GetCustomAttributes < OptionAttribute > ( ) . ToList ( ) ;
314- foreach ( var optionAttr in optionAttrs )
315- {
316- if ( optionAttr . Required && ! ( optionAttr is RequiredOptionAttribute ) )
317- {
318- isRequired = true ;
319- if ( ! string . IsNullOrEmpty ( optionAttr . LongName ) )
320- {
321- optionName = optionAttr . LongName ;
322- }
323-
324- break ;
325- }
326- }
327- }
328-
329309 // 如果是必需的,检查值
330310 if ( isRequired )
331311 {
@@ -862,4 +842,4 @@ private string NormalizePropertyName(string key)
862842
863843 return key ;
864844 }
865- }
845+ }
You can’t perform that action at this time.
0 commit comments