@@ -31,9 +31,10 @@ private MethodInfo FindMethod(Type startupType, string methodName, string enviro
3131 {
3232 if ( required )
3333 {
34- throw new Exception ( string . Format ( "TODO: {0} or {1} method not found" ,
34+ throw new Exception ( string . Format ( "A method named ' {0}' or ' {1}' in the type '{2}' could not be found. " ,
3535 methodNameWithEnv ,
36- methodNameWithNoEnv ) ) ;
36+ methodNameWithNoEnv ,
37+ startupType . FullName ) ) ;
3738
3839 }
3940 return null ;
@@ -42,8 +43,10 @@ private MethodInfo FindMethod(Type startupType, string methodName, string enviro
4243 {
4344 if ( required )
4445 {
45- throw new Exception ( string . Format ( "TODO: {0} method does not return " + returnType . Name ,
46- methodInfo . Name ) ) ;
46+ throw new Exception ( string . Format ( "The '{0}' method in the type '{1}' must have a return type of '{2}'." ,
47+ methodInfo . Name ,
48+ startupType . FullName ,
49+ returnType . Name ) ) ;
4750 }
4851 return null ;
4952 }
@@ -75,10 +78,11 @@ private object Invoke(MethodInfo methodInfo, object instance, IApplicationBuilde
7578 catch ( Exception )
7679 {
7780 throw new Exception ( string . Format (
78- "TODO: Unable to resolve service for {0} method {1} {2}" ,
79- methodInfo . Name ,
81+ "Could not resolve a service of type ' {0}' for the parameter ' {1}' of method ' {2}' on type '{3}'. " ,
82+ parameterInfo . ParameterType . FullName ,
8083 parameterInfo . Name ,
81- parameterInfo . ParameterType . FullName ) ) ;
84+ methodInfo . Name ,
85+ methodInfo . DeclaringType . FullName ) ) ;
8286 }
8387 }
8488 }
@@ -98,26 +102,26 @@ public Action<IApplicationBuilder> LoadStartup(
98102 var assembly = Assembly . Load ( new AssemblyName ( applicationName ) ) ;
99103 if ( assembly == null )
100104 {
101- throw new Exception ( String . Format ( "TODO: assembly {0} failed to load message " , applicationName ) ) ;
105+ throw new Exception ( String . Format ( "The assembly ' {0}' failed to load. " , applicationName ) ) ;
102106 }
103107
104- var startupName1 = "Startup" + environmentName ;
105- var startupName2 = "Startup" ;
108+ var startupNameWithEnv = "Startup" + environmentName ;
109+ var startupNameWithoutEnv = "Startup" ;
106110
107111 // Check the most likely places first
108112 var type =
109- assembly . GetType ( startupName1 ) ??
110- assembly . GetType ( applicationName + "." + startupName1 ) ??
111- assembly . GetType ( startupName2 ) ??
112- assembly . GetType ( applicationName + "." + startupName2 ) ;
113+ assembly . GetType ( startupNameWithEnv ) ??
114+ assembly . GetType ( applicationName + "." + startupNameWithEnv ) ??
115+ assembly . GetType ( startupNameWithoutEnv ) ??
116+ assembly . GetType ( applicationName + "." + startupNameWithoutEnv ) ;
113117
114118 if ( type == null )
115119 {
116120 // Full scan
117121 var definedTypes = assembly . DefinedTypes . ToList ( ) ;
118122
119- var startupType1 = definedTypes . Where ( info => info . Name . Equals ( startupName1 , StringComparison . Ordinal ) ) ;
120- var startupType2 = definedTypes . Where ( info => info . Name . Equals ( startupName2 , StringComparison . Ordinal ) ) ;
123+ var startupType1 = definedTypes . Where ( info => info . Name . Equals ( startupNameWithEnv , StringComparison . Ordinal ) ) ;
124+ var startupType2 = definedTypes . Where ( info => info . Name . Equals ( startupNameWithoutEnv , StringComparison . Ordinal ) ) ;
121125
122126 var typeInfo = startupType1 . Concat ( startupType2 ) . FirstOrDefault ( ) ;
123127 if ( typeInfo != null )
@@ -128,9 +132,9 @@ public Action<IApplicationBuilder> LoadStartup(
128132
129133 if ( type == null )
130134 {
131- throw new Exception ( String . Format ( "TODO: {0} or {1} class not found in assembly {2}" ,
132- startupName1 ,
133- startupName2 ,
135+ throw new Exception ( String . Format ( "A type named ' {0}' or ' {1}' could not be found in assembly ' {2}'. " ,
136+ startupNameWithEnv ,
137+ startupNameWithoutEnv ,
134138 applicationName ) ) ;
135139 }
136140
0 commit comments