@@ -293,6 +293,47 @@ public void Create_InvalidHostJson_ThrowsInformativeException()
293293 Assert . Equal ( "Invalid property identifier character: ~. Path '', line 2, position 4." , ex . InnerException . Message ) ;
294294 }
295295
296+ [ Theory ]
297+ [ InlineData ( "host" ) ]
298+ [ InlineData ( "-function" ) ]
299+ [ InlineData ( "_function" ) ]
300+ [ InlineData ( "function test" ) ]
301+ [ InlineData ( "function.test" ) ]
302+ [ InlineData ( "function0.1" ) ]
303+ public void Create_InvalidFunctionNames_DoesNotCreateFunctionAndLogsFailure ( string functionName )
304+ {
305+ string rootPath = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ;
306+ string invalidFunctionNamePath = Path . Combine ( rootPath , functionName ) ;
307+ try
308+ {
309+ Directory . CreateDirectory ( invalidFunctionNamePath ) ;
310+
311+ JObject config = new JObject ( ) ;
312+ config [ "id" ] = ID ;
313+
314+ File . WriteAllText ( Path . Combine ( rootPath , ScriptConstants . HostMetadataFileName ) , config . ToString ( ) ) ;
315+ File . WriteAllText ( Path . Combine ( invalidFunctionNamePath , ScriptConstants . FunctionMetadataFileName ) , string . Empty ) ;
316+
317+ ScriptHostConfiguration scriptConfig = new ScriptHostConfiguration ( )
318+ {
319+ RootScriptPath = rootPath
320+ } ;
321+
322+ var scriptHost = ScriptHost . Create ( _settingsManager , scriptConfig ) ;
323+
324+ Assert . Equal ( 1 , scriptHost . FunctionErrors . Count ) ;
325+ Assert . Equal ( functionName , scriptHost . FunctionErrors . First ( ) . Key ) ;
326+ Assert . Equal ( $ "'{ functionName } ' is not a valid function name.", scriptHost . FunctionErrors . First ( ) . Value . First ( ) ) ;
327+ }
328+ finally
329+ {
330+ if ( Directory . Exists ( rootPath ) )
331+ {
332+ Directory . Delete ( rootPath , true ) ;
333+ }
334+ }
335+ }
336+
296337 [ Fact ]
297338 public void ApplyConfiguration_TopLevel ( )
298339 {
@@ -612,6 +653,8 @@ public void TryGetFunctionFromException_FunctionMatch()
612653 [ InlineData ( "-function" ) ]
613654 [ InlineData ( "_function" ) ]
614655 [ InlineData ( "function test" ) ]
656+ [ InlineData ( "function.test" ) ]
657+ [ InlineData ( "function0.1" ) ]
615658 public void ValidateFunctionName_ThrowsOnInvalidName ( string functionName )
616659 {
617660 var ex = Assert . Throws < InvalidOperationException > ( ( ) =>
0 commit comments