@@ -48,6 +48,12 @@ let normalizeIdent (s: string) =
4848 let s = s.[ 0 .. 0 ]. ToUpperInvariant() + s.[ 1 ..]
4949 invalidIdentifierCharRE.Replace( s, " _" )
5050
51+ let private invalidNamespaceCharRE =
52+ Regex( " [^a-zA-Z0-9_.]" , RegexOptions.Compiled)
53+
54+ let normalizeNamespace ( s : string ) =
55+ invalidNamespaceCharRE.Replace( s, " _" )
56+
5157let indent ( s : seq < string >) =
5258 s |> Seq.map ( fun s -> " " + s)
5359
@@ -305,12 +311,15 @@ let GetCode namespaceName projectDirectory filePath
305311 let parsed = Parsing.Parse ( getRelPath projectDirectory filePath) projectDirectory serverLoad clientLoad
306312 let item = parsed.Items.[ 0 ] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
307313 let templateName = normalizeIdent item.Id
314+ let namespaceName = normalizeNamespace namespaceName
308315 autoGeneratedComment + getCodeInternal namespaceName templateName item
309316
310317let GetCodeClientOnly namespaceName templateName htmlString
311318 ( [<Optional; DefaultParameterValue( ClientLoad.Inline) >] clientLoad ) =
312319 let parsed = Parsing.Parse htmlString null ServerLoad.Once clientLoad
313320 let item = parsed.Items.[ 0 ] // it's always 1 item because C# doesn't support "foo.html,bar.html" style
321+ let templateName = normalizeIdent templateName
322+ let namespaceName = normalizeNamespace namespaceName
314323 autoGeneratedComment + getCodeInternal namespaceName templateName item
315324
316325/// Get the path to the output file for a given input file, creating any necessary directory.
0 commit comments