MarimerLLC / csla

A home for your business logic in any .NET application.
https://cslanet.com
MIT License
1.23k stars 394 forks source link

Code fix for public constructor seems to be broken #4061

Closed kant2002 closed 1 week ago

kant2002 commented 1 week ago

Describe the bug Open the BlazorExample and add private parameterless constructor to the BusinessLibrary.PersonEdit. I assume that this rule should trigger https://github.com/MarimerLLC/csla/blob/main/docs/analyzers/CSLA0003-CheckConstructorsAnalyzer.md But it is not, only Analyzer error displayed, image

but no code fix. image

Version and Platform CSLA version: main OS: Windows, Linux, iOS, Android, etc. Platform: WinForms, WPF, ASP.NET Core, MVC, Xamarin, etc.

Code that Fails

namespace BusinessLibrary
{
  [Serializable]
  public class PersonEdit : BusinessBase<PersonEdit>
  {
    private PersonEdit()
    {
    }

  }
}
kant2002 commented 1 week ago

Here the stack trace

System.InvalidOperationException : Sequence contains more than one element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
   at System.Linq.ImmutableArrayExtensions.Single[T](ImmutableArray`1 immutableArray,Func`2 predicate)
   at Csla.Analyzers.CheckConstructorsAnalyzerPublicConstructorCodeFix.AddCodeFixWithUpdatingNonPublicConstructor(CodeFixContext context,SyntaxNode root,Diagnostic diagnostic,ClassDeclarationSyntax classNode,SemanticModel model)
   at async Csla.Analyzers.CheckConstructorsAnalyzerPublicConstructorCodeFix.RegisterCodeFixesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.CodeFixes.CodeFixService.GetCodeFixesAsync(<Unknown Parameters>)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)