@@ -13,61 +13,82 @@ public class NoConstructorsFoundException : Exception
1313 /// <summary>
1414 /// Initializes a new instance of the <see cref="NoConstructorsFoundException"/> class.
1515 /// </summary>
16- /// <param name="offendingType">The <see cref="System.Type"/> whose constructor was not found.</param>
17- public NoConstructorsFoundException ( Type offendingType )
18- : this ( offendingType , FormatMessage ( offendingType ) )
16+ /// <param name="offendingType">The <see cref="Type"/> whose constructor was not found.</param>
17+ /// <param name="constructorFinder">The <see cref="IConstructorFinder"/> that was used to scan for the constructors.</param>
18+ public NoConstructorsFoundException ( Type offendingType , IConstructorFinder constructorFinder )
19+ : this ( offendingType , constructorFinder , FormatMessage ( offendingType , constructorFinder ) )
1920 {
2021 }
2122
2223 /// <summary>
2324 /// Initializes a new instance of the <see cref="NoConstructorsFoundException"/> class.
2425 /// </summary>
25- /// <param name="offendingType">The <see cref="System.Type"/> whose constructor was not found.</param>
26+ /// <param name="offendingType">The <see cref="Type"/> whose constructor was not found.</param>
27+ /// <param name="constructorFinder">The <see cref="IConstructorFinder"/> that was used to scan for the constructors.</param>
2628 /// <param name="message">Exception message.</param>
27- public NoConstructorsFoundException ( Type offendingType , string message )
29+ public NoConstructorsFoundException ( Type offendingType , IConstructorFinder constructorFinder , string message )
2830 : base ( message )
2931 {
3032 OffendingType = offendingType ?? throw new ArgumentNullException ( nameof ( offendingType ) ) ;
33+ ConstructorFinder = constructorFinder ?? throw new ArgumentNullException ( nameof ( constructorFinder ) ) ;
3134 }
3235
3336 /// <summary>
3437 /// Initializes a new instance of the <see cref="NoConstructorsFoundException"/> class.
3538 /// </summary>
36- /// <param name="offendingType">The <see cref="System.Type"/> whose constructor was not found.</param>
39+ /// <param name="offendingType">The <see cref="Type"/> whose constructor was not found.</param>
40+ /// <param name="constructorFinder">The <see cref="IConstructorFinder"/> that was used to scan for the constructors.</param>
3741 /// <param name="innerException">The inner exception.</param>
38- public NoConstructorsFoundException ( Type offendingType , Exception innerException )
39- : this ( offendingType , FormatMessage ( offendingType ) , innerException )
42+ public NoConstructorsFoundException ( Type offendingType , IConstructorFinder constructorFinder , Exception innerException )
43+ : this ( offendingType , constructorFinder , FormatMessage ( offendingType , constructorFinder ) , innerException )
4044 {
4145 }
4246
4347 /// <summary>
4448 /// Initializes a new instance of the <see cref="NoConstructorsFoundException"/> class.
4549 /// </summary>
46- /// <param name="offendingType">The <see cref="System.Type"/> whose constructor was not found.</param>
50+ /// <param name="offendingType">The <see cref="Type"/> whose constructor was not found.</param>
51+ /// <param name="constructorFinder">The <see cref="IConstructorFinder"/> that was used to scan for the constructors.</param>
4752 /// <param name="message">Exception message.</param>
4853 /// <param name="innerException">The inner exception.</param>
49- public NoConstructorsFoundException ( Type offendingType , string message , Exception innerException )
54+ public NoConstructorsFoundException ( Type offendingType , IConstructorFinder constructorFinder , string message , Exception innerException )
5055 : base ( message , innerException )
5156 {
5257 OffendingType = offendingType ?? throw new ArgumentNullException ( nameof ( offendingType ) ) ;
58+ ConstructorFinder = constructorFinder ?? throw new ArgumentNullException ( nameof ( constructorFinder ) ) ;
5359 }
5460
61+ /// <summary>
62+ /// Gets the finder used when locating constructors.
63+ /// </summary>
64+ /// <value>
65+ /// An <see cref="IConstructorFinder"/> that was used when scanning the
66+ /// <see cref="OffendingType"/> to find constructors.
67+ /// </value>
68+ public IConstructorFinder ConstructorFinder { get ; private set ; }
69+
5570 /// <summary>
5671 /// Gets the type without found constructors.
5772 /// </summary>
5873 /// <value>
59- /// A <see cref="System.Type"/> that was processed by an <see cref="IConstructorFinder"/>
60- /// or similar mechanism and was determined to have no available constructors.
74+ /// A <see cref="Type"/> that was processed by the
75+ /// <see cref="ConstructorFinder"/> and was determined to have no available
76+ /// constructors.
6177 /// </value>
6278 public Type OffendingType { get ; private set ; }
6379
64- private static string FormatMessage ( Type offendingType )
80+ private static string FormatMessage ( Type offendingType , IConstructorFinder constructorFinder )
6581 {
6682 if ( offendingType == null )
6783 {
6884 throw new ArgumentNullException ( nameof ( offendingType ) ) ;
6985 }
7086
71- return string . Format ( CultureInfo . CurrentCulture , NoConstructorsFoundExceptionResources . Message , offendingType . FullName ) ;
87+ if ( constructorFinder == null )
88+ {
89+ throw new ArgumentNullException ( nameof ( constructorFinder ) ) ;
90+ }
91+
92+ return string . Format ( CultureInfo . CurrentCulture , NoConstructorsFoundExceptionResources . Message , offendingType . FullName , constructorFinder . GetType ( ) . FullName ) ;
7293 }
7394}
0 commit comments