Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Commit

Permalink
Configured dotnet watch to help test codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLariviere committed Jan 12, 2022
1 parent 230c66f commit f08f73a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/Fabulous.XamarinForms/Fabulous.XamarinForms.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<Compile Include="Xamarin.Forms.Core.Attributes.fs" />
<Compile Include="Xamarin.Forms.Core.fs" />
<Compile Include="WidgetExtensions.fs" />
<Compile Include="Xamarin.Forms.Core.Attributes.Generated.fs" />
<Compile Include="Xamarin.Forms.Core.Generated.fs" />
<None Include="PackageREADME.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
Expand Down
34 changes: 15 additions & 19 deletions tools/Fabulous.CodeGen/Generator/CodeGenerator.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ module CodeGenerator =
| Some attributeKey -> attributeKey

let generateNamespace (namespaceOfGeneratedCode: string) (additionalNamespaces: string array) (w: StringWriter) =
w.printfn "// Copyright 2018-2020 Fabulous contributors. See LICENSE.md for license."
w.printfn "// Copyright 2018-2022 Fabulous contributors. See LICENSE.md for license."
w.printfn $"namespace %s{namespaceOfGeneratedCode}"
w.printfn ""
w.printfn "#nowarn \"59\" // cast always holds"
w.printfn "#nowarn \"66\" // cast always holds"
w.printfn "#nowarn \"67\" // cast always holds"
w.printfn "#nowarn \"760\""
w.printfn ""
w.printfn "open Fabulous"
w.printfn "open Fabulous.XamarinForms"

for additionalNamespace in additionalNamespaces do
w.printfn $"open %s{additionalNamespace}"
Expand All @@ -34,14 +30,14 @@ module CodeGenerator =
w

let generateAttributes (members: AttributeData array) (w: StringWriter) =
w.printfn "module ViewAttributes ="
for m in members do
let typeName =
match m.Name with
| "Created" -> "(obj -> unit)"
| _ -> m.ModelType

w.printfn $" let %s{getAttributeKeyName m.UniqueName} : AttributeKey<_> = AttributeKey<%s{typeName}>(\"%s{m.UniqueName}\")"
// w.printfn "module ViewAttributes ="
// for m in members do
// let typeName =
// match m.Name with
// | "Created" -> "(obj -> unit)"
// | _ -> m.ModelType
//
// w.printfn $" let %s{getAttributeKeyName m.UniqueName} : AttributeKey<_> = AttributeKey<%s{typeName}>(\"%s{m.UniqueName}\")"
w.printfn ""
w

Expand Down Expand Up @@ -436,11 +432,11 @@ module CodeGenerator =
use writer = new StringWriter()

writer
|> generateNamespace data.Namespace data.AdditionalNamespaces
|> generateBuilders data.Builders
|> generateViewers data.Viewers
|> generateConstructors data.Constructors
|> generateViewExtensions data.ViewExtensions
// |> generateNamespace data.Namespace data.AdditionalNamespaces
// |> generateBuilders data.Builders
// |> generateViewers data.Viewers
// |> generateConstructors data.Constructors
// |> generateViewExtensions data.ViewExtensions
|> toString

let generateCode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"assemblies": [
"packages/generator/Xamarin.Forms/lib/netstandard2.0/Xamarin.Forms.Core.dll"
"../../packages/generator/Xamarin.Forms/lib/netstandard2.0/Xamarin.Forms.Core.dll"
],
"outputNamespace": "Fabulous.XamarinForms",
"types": [
Expand Down
1 change: 1 addition & 0 deletions watch-codegen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet watch run --project tools/Fabulous.XamarinForms.Generator/Fabulous.XamarinForms.Generator.fsproj -- -m Xamarin.Forms.Core.json -a ../../src/Fabulous.XamarinForms/Xamarin.Forms.Core.Attributes.Generated.fs -b ../../src/Fabulous.XamarinForms/Xamarin.Forms.Core.Generated.fs -d

0 comments on commit f08f73a

Please sign in to comment.