From 687b10759a5ac17237b877c0a8b42d0e8ac23c3a Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 8 Apr 2019 14:09:50 -0700 Subject: [PATCH 01/21] moving gentracesources and gentracestrings to tt files these will now be generated using .tt files that are contained in the Microsoft.DotNet.Arcade.Wpf.sdk --- eng/WpfArcadeSdk/Sdk/Sdk.props | 3 +- eng/WpfArcadeSdk/Sdk/Sdk.targets | 1 + .../tools/AvTrace/GenTraceSources.pl | 136 -------- .../tools/AvTrace/GenTraceStrings.pl | 297 ------------------ eng/WpfArcadeSdk/tools/CodeGen.props | 5 + eng/WpfArcadeSdk/tools/CodeGen.targets | 3 + .../tools/CodeGen/AvTrace/AvTraceDetails.tt | 60 ++++ .../CodeGen/AvTrace/GenTraceSources.targets | 32 ++ .../AvTrace/PresentationTraceSources.tt | 47 +++ .../tools/CodeGen/TextTemplate.targets | 18 ++ ...t.DotNet.Arcade.Wpf.Sdk.ArchNeutral.csproj | 2 +- 11 files changed, 168 insertions(+), 436 deletions(-) delete mode 100644 eng/WpfArcadeSdk/tools/AvTrace/GenTraceSources.pl delete mode 100644 eng/WpfArcadeSdk/tools/AvTrace/GenTraceStrings.pl create mode 100644 eng/WpfArcadeSdk/tools/CodeGen.props create mode 100644 eng/WpfArcadeSdk/tools/CodeGen.targets create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets diff --git a/eng/WpfArcadeSdk/Sdk/Sdk.props b/eng/WpfArcadeSdk/Sdk/Sdk.props index fa2b157324a..d06889c487d 100644 --- a/eng/WpfArcadeSdk/Sdk/Sdk.props +++ b/eng/WpfArcadeSdk/Sdk/Sdk.props @@ -13,7 +13,6 @@ - $(WpfArcadeSdkToolsDir)AvTrace\GenTraceSources.pl $(WpfArcadeSdkToolsDir)GenXmlStringTable.pl true @@ -35,7 +34,7 @@ - + full diff --git a/eng/WpfArcadeSdk/Sdk/Sdk.targets b/eng/WpfArcadeSdk/Sdk/Sdk.targets index 4f4c216b798..3aae51c9ad5 100644 --- a/eng/WpfArcadeSdk/Sdk/Sdk.targets +++ b/eng/WpfArcadeSdk/Sdk/Sdk.targets @@ -20,6 +20,7 @@ + diff --git a/eng/WpfArcadeSdk/tools/AvTrace/GenTraceSources.pl b/eng/WpfArcadeSdk/tools/AvTrace/GenTraceSources.pl deleted file mode 100644 index 593c43dd5a0..00000000000 --- a/eng/WpfArcadeSdk/tools/AvTrace/GenTraceSources.pl +++ /dev/null @@ -1,136 +0,0 @@ -######################################################## -# Generate the enum used for retrieving wrapper classes for managed debug tracing. -# -# This scripts reads an input file with the trace information, -# and generates a cs file with the enum containing trace area values. -# -######################################################## -use File::Copy; -use Getopt::Std; - -sub usage() -{ - print "Usage: $0 -i [Inputfile1,Inputfile2,...] -o [output.cs] \n\n"; -} - -#hash to store all the arguements. -my %args -; -#error header. -my $error_msg = "GenTraceSources.pl: error:"; - -#get the switches values. -getopts('i:o:', \%args); - -#all these switches are required. - -my $outfile = $args{o}; -my @inputfilelist = split(/,/, $args{i}); - -print "\n"; - - -# -# The header for the file -# - -my $header = <<"END_OF_HEADER"; -//------------------------------------------------------------------------------- -// -// Copyright (c) Microsoft Corporation. All Rights Reserved. -// Information Contained Herein is Proprietary and Confidential. -// -// -// This file is generated from AvTraceMessages.txt by gentracesources.pl - do not modify this file directly -//------------------------------------------------------------------------------- - -using MS.Internal; - -namespace System.Diagnostics -{ - /// Access point for TraceSources - public static partial class PresentationTraceSources - { -END_OF_HEADER - - -# -# The footer for the file -# - -my $footer = <<"END_OF_FOOTER"; - } -}//endof namespace -END_OF_FOOTER - - -# -# Initialize the output file -# - -open(OUT, '>'.$outfile) or die "$error_msg Cannot create $outfile. $!\n"; - -print OUT $header or die "$error_msg Cannot write to $outfile. $! \n"; - -{ - # Now we read the trace areas from the files - - for $inputfile (@inputfilelist) - { - - open(IN, $inputfile) or die "$error_msg Cannot open $inputfile. $!\n"; - - - # Loop through the strings - - my $traceArea; - my $traceClass; - my $traceName; - my $traceSourceName; - - while ($stringIn = ) - { - chomp; - - # Find the beginning of a section, with the trace source name - # and the name of the trace area. - # E.g. "[System.Windows.ComponentModel.Events,RoutedEvent]" - - if (($traceName, $traceArea, $traceClass) = ($stringIn =~ /^\[(.*),(.*),(.*)\]/)) - { - # append "Source" for the TraceSource name - $traceSourceName = $traceArea."Source"; - - # Write out the property - - print OUT -" - /// $traceSourceName for $traceArea - public static TraceSource $traceSourceName - { - get - { - if (_$traceSourceName == null) - { - _$traceSourceName = CreateTraceSource(\"$traceName\"); - } - return _$traceSourceName; - } - } - internal static TraceSource _$traceSourceName; -" - or die "$error_msg Cannot write to $outfile. $! \n"; - - } - } - - #close files - close (IN) or die "$error_msg Cannot close $infile. $!\n"; - } -} - -print OUT "\n".$footer or die "$error_msg Cannot write to $outfile. $! \n"; - -#close files -close (OUT) or die "$error_msg Cannot close $outfile. $!\n"; - diff --git a/eng/WpfArcadeSdk/tools/AvTrace/GenTraceStrings.pl b/eng/WpfArcadeSdk/tools/AvTrace/GenTraceStrings.pl deleted file mode 100644 index 937e125b562..00000000000 --- a/eng/WpfArcadeSdk/tools/AvTrace/GenTraceStrings.pl +++ /dev/null @@ -1,297 +0,0 @@ -######################################################## -# Generate the wrapper classes for managed debug tracing. -# -# This scripts reads an input file with the trace information, -# and generates a cs file with the wrapper classes. -# -######################################################## -use File::Copy; -use Getopt::Std; - -sub usage() -{ - print "Usage: $0 -i [Inputfile1] -o [output.cs] \n\n"; -} - -#hash to store all the arguements. -my %args -; -#error header. -my $error_msg = "GenTraceStrings.pl: error:"; - -#get the switches values. -getopts('i:o:', \%args); - -#all these switches are required. - -my $outfile = $args{o}; -my $inputfile = $args{i}; - -print "\n"; - - -# -# The header for the file -# - -my $header = <<"END_OF_HEADER"; - -using System; -using System.Diagnostics; - -namespace MS.Internal -{ -END_OF_HEADER - - -# -# The footer for the file -# - -my $footer = <<"END_OF_FOOTER"; -}//endof namespace -END_OF_FOOTER - - -# -# The footer section for each class -# - -my $classFooter = <<"END_OF_FOOTER"; - - // Send a single trace output - static public void Trace( TraceEventType type, AvTraceDetails traceDetails, params object[] parameters ) - { - _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); - } - - // these help delay allocation of object array - static public void Trace( TraceEventType type, AvTraceDetails traceDetails ) - { - _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); - } - static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1 ) - { - _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1 } ); - } - static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1, object p2 ) - { - _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2 } ); - } - static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1, object p2, object p3 ) - { - _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); - } - - // Send a singleton "activity" trace (really, this sends the same trace as both a Start and a Stop) - static public void TraceActivityItem( AvTraceDetails traceDetails, params Object[] parameters ) - { - _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); - } - - // these help delay allocation of object array - static public void TraceActivityItem( AvTraceDetails traceDetails ) - { - _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); - } - static public void TraceActivityItem( AvTraceDetails traceDetails, object p1 ) - { - _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1 } ); - } - static public void TraceActivityItem( AvTraceDetails traceDetails, object p1, object p2 ) - { - _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2 } ); - } - static public void TraceActivityItem( AvTraceDetails traceDetails, object p1, object p2, object p3 ) - { - _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); - } - - // Is tracing enabled here? - static public bool IsEnabled - { - get { return _avTrace != null && _avTrace.IsEnabled; } - } - - // Is there a Tracesource? (See comment on AvTrace.IsEnabledOverride.) - static public bool IsEnabledOverride - { - get { return _avTrace.IsEnabledOverride; } - } - - // Re-read the configuration for this trace source - static public void Refresh() - { - _avTrace.Refresh(); - } - - }//endof class $srclass -END_OF_FOOTER - - - -# -# Initialize the output file -# - -open(OUT, '>'.$outfile) or die "$error_msg Cannot create $outfile. $!\n"; - -print OUT $header or die "$error_msg Cannot write to $outfile. $! \n"; - - - -{ - # Now we read the trace information from the file - - open(IN, $inputfile) or die "$error_msg Cannot open $inputfile. $!\n"; - - - # Loop through the strings - - my $prev_id = 0; - my $max_id = 0; - my $inClass = 0; - my $traceArea; - my $traceClass; - my $traceName; - my $traceSourceName; - - while ($stringIn = ) - { - chomp; - next if ($stringIn =~ /^;/); # ignore all comments - next if ($stringIn =~ /^\r/); # ignore newline - - # Handle the beginning of a section, with the trace source name, - # the name of the area, and the name of the class to be generated. - # E.g. "[System.Windows.ComponentModel.Events,RoutedEvent,TraceRoutedEvent]" - - if (($traceName, $traceArea, $traceClass) = ($stringIn =~ /^\[(.*),(.*),(.*)\]/)) - { - # append "Source" for the property name to be used in PresentationTraceSources - - $traceSourceName = $traceArea."Source"; - - # Write out the class header - - print OUT -" - static internal partial class $traceClass - { - static private AvTrace _avTrace = new AvTrace( - delegate() { return PresentationTraceSources.$traceSourceName; }, - delegate() { PresentationTraceSources._$traceSourceName = null; } - ); - -" - or die "$error_msg Cannot write to $outfile. $! \n"; - - # reset id auto-generation counters - $max_id = $prev_id = 0; - $inClass = 1; - next; - } - - # Check for the end of a section, e.g. "[end]" - - if ($stringIn =~ /^\[end]/) - { - print OUT $classFooter or die "$error_msg Cannot write to $outfile. $! \n"; - $inClass = 0; - next; - } - - - # Handle a line within a section, which has the trace strings - # E.g. MyEvent=AUTO,FORMAT,{"Basic message or format string", "Param1", "Param2"} - - if (($name, $id, $shouldFormat, $labels) = ($stringIn =~ /^(\w+)=(\w*)\,(\w*)\,(.*)/)) - { - $inClass or die "Trace string '$stringIn' is not inside a section."; - - # auto-generate id if int is not specified - if ($id =~ /^\d+$/) - { - $max_id = $id if $id > $max_id; - } - elsif ($id == "" || $id == "AUTO") - { - $id = ++$max_id; - } - elsif ($id == "PREVIOUS") - { - $id = $prev_id; - } - else - { - die "invalid id '$id' for trace string."; - } - - if ($shouldFormat) - { - # create a method that passes args for the format string - - # TODO: calculate number of parameters and create precise method signature - - print OUT -" - static AvTraceDetails _$name; - static public AvTraceDetails $name(params object[] args) - { - if ( _$name == null ) - { - _$name = new AvTraceDetails( $id, new string[] $labels ); - } - - return new AvTraceFormat(_$name, args); - } -" - or die "$error_msg Cannot write to $outfile. $! \n"; - - } - elsif ($shouldFormat == "" || $shouldFormat =~ /false/i) - { - # create a property - print OUT -" - static AvTraceDetails _$name; - static public AvTraceDetails $name - { - get - { - if ( _$name == null ) - { - _$name = new AvTraceDetails( $id, new string[] $labels ); - } - - return _$name; - } - } -" - or die "$error_msg Cannot write to $outfile. $! \n"; - - } - else - { - die "invalid value '$id' for trace string ShouldFormat boolean."; - } - - $prev_id = $id; - next; - } - - - next if ($stringIn =~ /^$/); - - die "Invalid trace string '$stringIn'"; - } - - #close files - close (IN) or die "$error_msg Cannot close $infile. $!\n"; -} - -print OUT "\n".$footer or die "$error_msg Cannot write to $outfile. $! \n"; - -#close files -close (OUT) or die "$error_msg Cannot close $outfile. $!\n"; - diff --git a/eng/WpfArcadeSdk/tools/CodeGen.props b/eng/WpfArcadeSdk/tools/CodeGen.props new file mode 100644 index 00000000000..13c67d0b521 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen.props @@ -0,0 +1,5 @@ + + + $(WpfArcadeSdkToolsDir)CodeGen\ + + \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen.targets b/eng/WpfArcadeSdk/tools/CodeGen.targets new file mode 100644 index 00000000000..06899ee77c8 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen.targets @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt new file mode 100644 index 00000000000..961735bfa6f --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt @@ -0,0 +1,60 @@ +<#@ template hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="Newtonsoft.Json" #> +<#@ assembly name="Microsoft.CSharp" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="Newtonsoft.Json" #> +<#@ output extension=".cs" #> +<#@ parameter type="System.String" name="AvTraceMessageFile" #> + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Diagnostics; + +namespace MS.Internal +{ +<# + string fileName = this.Host.ResolvePath(AvTraceMessageFile); + string jsonText = File.ReadAllText(fileName); + dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); + foreach (var source in jsonObj.sources) + { + string name = source.name; +#> + static internal partial class Trace<#=name#> + { + static private AvTrace _avTrace = new AvTrace( + delegate() { return PresentationTraceSources.<#=name#>Source; }, + delegate() { PresentationTraceSources._<#=name#>Source = null; } + ); + +<# + int id = 0; + foreach (var traceDetails in source.trace_details) + { + ++id; + string traceName = traceDetails.name; +#> + static AvTraceDetails _<#=traceName#>; + static public AvTraceDetails <#=traceName#> + { + get + { + if ( _<#=traceName#> == null ) + { +<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace(Environment.NewLine,""); #> + _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>", <#=dataString#> } ); + } + + return _<#=traceName#>; + } + } +<# } #> + } +<# } #> +} \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets new file mode 100644 index 00000000000..c355f258189 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -0,0 +1,32 @@ + + + + + TextTemplatingFileGenerator + AvTraceDetails.cs + $(MSBuildProjectDirectory) + + + True + True + AvTraceDetails.tt + + + TextTemplatingFileGenerator + PresentationTraceSources.cs + $(MSBuildProjectDirectory) + + + True + True + PresentationTraceSources.tt + + + + + + $(MSBuildProjectDirectory)AvTraceMessages.json + False + + + diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt new file mode 100644 index 00000000000..079ee310aa0 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -0,0 +1,47 @@ +<#@ template hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="Newtonsoft.Json" #> +<#@ assembly name="Microsoft.CSharp" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="Newtonsoft.Json" #> +<#@ output extension=".cs" #> +<#@ parameter type="System.String" name="AvTraceMessageFile" #> +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using MS.Internal; + +namespace System.Diagnostics +{ + /// Access point for TraceSources + public static partial class PresentationTraceSources + { +<# + string fileName = this.Host.ResolvePath(AvTraceMessageFile); + string jsonText = File.ReadAllText(fileName); + dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); + foreach (var source in jsonObj.sources) + { + string name = source.name; +#> + /// <#=name#>Source for <#=name#> + public static TraceSource <#=name#>Source + { + get + { + if (_<#=name#>Source == null) + { + _<#=name#>Source = CreateTraceSource("<#=source.source_name#>"); + } + return _<#=name#>Source; + } + } + internal static TraceSource _<#=name#>Source; + +<# } #> + } +} \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets b/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets new file mode 100644 index 00000000000..1858da47fc9 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets @@ -0,0 +1,18 @@ + + + + + + + 16.0 + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + true + + true + + false + + + \ No newline at end of file diff --git a/packaging/Microsoft.DotNet.Arcade.Wpf.Sdk/Microsoft.DotNet.Arcade.Wpf.Sdk.ArchNeutral.csproj b/packaging/Microsoft.DotNet.Arcade.Wpf.Sdk/Microsoft.DotNet.Arcade.Wpf.Sdk.ArchNeutral.csproj index ac9fb2d1129..944083f2fe5 100644 --- a/packaging/Microsoft.DotNet.Arcade.Wpf.Sdk/Microsoft.DotNet.Arcade.Wpf.Sdk.ArchNeutral.csproj +++ b/packaging/Microsoft.DotNet.Arcade.Wpf.Sdk/Microsoft.DotNet.Arcade.Wpf.Sdk.ArchNeutral.csproj @@ -23,7 +23,7 @@ - + From 05b7af4f3ca11602143eee2a6bee09d6d088e76b Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 8 Apr 2019 14:31:07 -0700 Subject: [PATCH 02/21] minor fixes --- .../tools/CodeGen/AvTrace/GenTraceSources.targets | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index c355f258189..ebfb9a3970c 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -1,6 +1,6 @@ - - - + + + TextTemplatingFileGenerator AvTraceDetails.cs @@ -22,8 +22,8 @@ PresentationTraceSources.tt - - + + $(MSBuildProjectDirectory)AvTraceMessages.json False From 5634556ef80b9224c7ff5ffaa4f56c4923b9b97b Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 8 Apr 2019 14:32:51 -0700 Subject: [PATCH 03/21] remove GenerateAvTraceMessages.targets --- eng/WpfArcadeSdk/Sdk/Sdk.targets | 1 - .../tools/GenerateAvTraceMessages.targets | 18 ------------------ 2 files changed, 19 deletions(-) delete mode 100644 eng/WpfArcadeSdk/tools/GenerateAvTraceMessages.targets diff --git a/eng/WpfArcadeSdk/Sdk/Sdk.targets b/eng/WpfArcadeSdk/Sdk/Sdk.targets index 3aae51c9ad5..eaa94ace741 100644 --- a/eng/WpfArcadeSdk/Sdk/Sdk.targets +++ b/eng/WpfArcadeSdk/Sdk/Sdk.targets @@ -7,7 +7,6 @@ - diff --git a/eng/WpfArcadeSdk/tools/GenerateAvTraceMessages.targets b/eng/WpfArcadeSdk/tools/GenerateAvTraceMessages.targets deleted file mode 100644 index a69a220cd94..00000000000 --- a/eng/WpfArcadeSdk/tools/GenerateAvTraceMessages.targets +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file From 78b57134a0fde933c7392a5c81f3cfa7c831deeb Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 8 Apr 2019 19:07:28 -0700 Subject: [PATCH 04/21] Simplifying these targets so they should be manually included --- eng/WpfArcadeSdk/Sdk/Sdk.targets | 1 - eng/WpfArcadeSdk/tools/CodeGen.props | 2 +- eng/WpfArcadeSdk/tools/CodeGen.targets | 3 -- .../CodeGen/AvTrace/GenTraceSources.targets | 46 ++++++++++++++----- .../tools/CodeGen/TextTemplate.targets | 18 -------- 5 files changed, 35 insertions(+), 35 deletions(-) delete mode 100644 eng/WpfArcadeSdk/tools/CodeGen.targets delete mode 100644 eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets diff --git a/eng/WpfArcadeSdk/Sdk/Sdk.targets b/eng/WpfArcadeSdk/Sdk/Sdk.targets index eaa94ace741..db055716b96 100644 --- a/eng/WpfArcadeSdk/Sdk/Sdk.targets +++ b/eng/WpfArcadeSdk/Sdk/Sdk.targets @@ -19,7 +19,6 @@ - diff --git a/eng/WpfArcadeSdk/tools/CodeGen.props b/eng/WpfArcadeSdk/tools/CodeGen.props index 13c67d0b521..dbe3e9dac56 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen.props +++ b/eng/WpfArcadeSdk/tools/CodeGen.props @@ -1,5 +1,5 @@ - + $(WpfArcadeSdkToolsDir)CodeGen\ \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen.targets b/eng/WpfArcadeSdk/tools/CodeGen.targets deleted file mode 100644 index 06899ee77c8..00000000000 --- a/eng/WpfArcadeSdk/tools/CodeGen.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index ebfb9a3970c..bde945ccf1c 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -1,32 +1,54 @@ - - - + + + + + + + + 16.0 + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + true + + true + + false + $(MSBuildProjectDirectory)\AvTraceMessages.json + 12.0.2-beta1 + + + + TextTemplatingFileGenerator AvTraceDetails.cs - $(MSBuildProjectDirectory) + $(MSBuildProjectDirectory)Generated\ True True - AvTraceDetails.tt + $(MSBuildThisFileDirectory)AvTraceDetails.tt - + TextTemplatingFileGenerator PresentationTraceSources.cs - $(MSBuildProjectDirectory) + $(MSBuildProjectDirectory)Generated\ True True - PresentationTraceSources.tt + $(MSBuildThisFileDirectory)PresentationTraceSources.tt - - + - $(MSBuildProjectDirectory)AvTraceMessages.json + $(AvTraceMessageFile) False + + $(NugetPackageRoot)\newtonsoft.json\$(NewtonsoftVersion)\lib\netstandard2.0 + false + - + \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets b/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets deleted file mode 100644 index 1858da47fc9..00000000000 --- a/eng/WpfArcadeSdk/tools/CodeGen/TextTemplate.targets +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - 16.0 - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - true - - true - - false - - - \ No newline at end of file From 2b1c0dbc492969ed682510b97c76e66d9c4d1586 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 8 Apr 2019 19:11:11 -0700 Subject: [PATCH 05/21] add comment as to why we manually import Sdk.targets --- .../tools/CodeGen/AvTrace/GenTraceSources.targets | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index bde945ccf1c..646738bc1f8 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -2,7 +2,10 @@ - + From 2424d8dc5b2729fe436f91807b186e55323eea7e Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 11 Apr 2019 10:46:03 -0700 Subject: [PATCH 06/21] Fixing targets and .tt so that they can be executed Files are finally being generated now --- .../tools/CodeGen/AvTrace/AvTraceDetails.tt | 3 +- .../CodeGen/AvTrace/GenTraceSources.targets | 73 ++++++++++++++++++- .../AvTrace/PresentationTraceSources.tt | 3 +- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt index 961735bfa6f..1d92cdeaef7 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt @@ -1,6 +1,7 @@ <#@ template hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="Newtonsoft.Json" #> +<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> +<#@ assembly name="netstandard" #> <#@ assembly name="Microsoft.CSharp" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index 646738bc1f8..3842f7353fe 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -22,11 +22,80 @@ 12.0.2-beta1 + + + + + + + + + + + + + + + + + + + $(RootNamespace) + + + + + + + + + + + + + + + + TextTemplatingFileGenerator AvTraceDetails.cs - $(MSBuildProjectDirectory)Generated\ + $(MSBuildProjectDirectory)\Generated\ True @@ -36,7 +105,7 @@ TextTemplatingFileGenerator PresentationTraceSources.cs - $(MSBuildProjectDirectory)Generated\ + $(MSBuildProjectDirectory)\Generated\ True diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 079ee310aa0..1c1dc3ec88e 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -1,6 +1,7 @@ <#@ template hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="Newtonsoft.Json" #> +<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> +<#@ assembly name="netstandard" #> <#@ assembly name="Microsoft.CSharp" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> From e9e86394069d37c69b5d7165434ac3340de24a00 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Tue, 16 Apr 2019 08:09:24 -0700 Subject: [PATCH 07/21] updating targets and tt files so that we gen the same file and filenames as before --- .../tools/CodeGen/AvTrace/AvTraceDetails.tt | 61 --------- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 127 ++++++++++++++++++ .../CodeGen/AvTrace/GenAvMessages.targets | 24 ++++ .../CodeGen/AvTrace/GenTraceSources.targets | 112 +-------------- .../AvTrace/PresentationTraceSources.tt | 18 +-- .../CodeGen/DesignTimeTextTemplating.targets | 98 ++++++++++++++ 6 files changed, 265 insertions(+), 175 deletions(-) delete mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets create mode 100644 eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt deleted file mode 100644 index 1d92cdeaef7..00000000000 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceDetails.tt +++ /dev/null @@ -1,61 +0,0 @@ -<#@ template hostspecific="true" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> -<#@ assembly name="netstandard" #> -<#@ assembly name="Microsoft.CSharp" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="System.IO" #> -<#@ import namespace="Newtonsoft.Json" #> -<#@ output extension=".cs" #> -<#@ parameter type="System.String" name="AvTraceMessageFile" #> - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -using System; -using System.Diagnostics; - -namespace MS.Internal -{ -<# - string fileName = this.Host.ResolvePath(AvTraceMessageFile); - string jsonText = File.ReadAllText(fileName); - dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); - foreach (var source in jsonObj.sources) - { - string name = source.name; -#> - static internal partial class Trace<#=name#> - { - static private AvTrace _avTrace = new AvTrace( - delegate() { return PresentationTraceSources.<#=name#>Source; }, - delegate() { PresentationTraceSources._<#=name#>Source = null; } - ); - -<# - int id = 0; - foreach (var traceDetails in source.trace_details) - { - ++id; - string traceName = traceDetails.name; -#> - static AvTraceDetails _<#=traceName#>; - static public AvTraceDetails <#=traceName#> - { - get - { - if ( _<#=traceName#> == null ) - { -<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace(Environment.NewLine,""); #> - _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>", <#=dataString#> } ); - } - - return _<#=traceName#>; - } - } -<# } #> - } -<# } #> -} \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt new file mode 100644 index 00000000000..1662aa0242c --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -0,0 +1,127 @@ +<#@ template hostspecific="true" language="C#" #> +<#@ assembly name="System.Core" #> +<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> +<#@ assembly name="netstandard" #> +<#@ assembly name="Microsoft.CSharp" #> +<#@ import namespace="System.Linq" #> +<#@ import namespace="System.Text" #> +<#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="Newtonsoft.Json" #> +<#@ output extension=".cs" #> +<#@ parameter type="System.String" name="AvTraceMessageFile" #> + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Diagnostics; + +namespace MS.Internal +{ +<# + string fileName = this.Host.ResolvePath(AvTraceMessageFile); + string jsonText = File.ReadAllText(fileName); + dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); + foreach (var source in jsonObj.sources) + { + string name = source.name; +#> + static internal partial class Trace<#=name#> + { + static private AvTrace _avTrace = new AvTrace( + delegate() { return PresentationTraceSources.<#=name#>Source; }, + delegate() { PresentationTraceSources._<#=name#>Source = null; } + ); + +<# + int id = 0; + foreach (var traceDetails in source.trace_details) + { + ++id; + string traceName = traceDetails.name; +#> + static AvTraceDetails _<#=traceName#>; + static public AvTraceDetails <#=traceName#> + { + get + { + if ( _<#=traceName#> == null ) + { +<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace(Environment.NewLine,"").Trim(); #> + _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>", <#=dataString#> } ); + } + + return _<#=traceName#>; + } + } +<# } #> + + // Send a single trace output + static public void Trace( TraceEventType type, AvTraceDetails traceDetails, params object[] parameters ) + { + _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); + } + + // these help delay allocation of object array + static public void Trace( TraceEventType type, AvTraceDetails traceDetails ) + { + _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); + } + static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1 ) + { + _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1 } ); + } + static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1, object p2 ) + { + _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2 } ); + } + static public void Trace( TraceEventType type, AvTraceDetails traceDetails, object p1, object p2, object p3 ) + { + _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); + } + + // Send a singleton "activity" trace (really, this sends the same trace as both a Start and a Stop) + static public void TraceActivityItem( AvTraceDetails traceDetails, params Object[] parameters ) + { + _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); + } + + // these help delay allocation of object array + static public void TraceActivityItem( AvTraceDetails traceDetails ) + { + _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); + } + static public void TraceActivityItem( AvTraceDetails traceDetails, object p1 ) + { + _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1 } ); + } + static public void TraceActivityItem( AvTraceDetails traceDetails, object p1, object p2 ) + { + _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2 } ); + } + static public void TraceActivityItem( AvTraceDetails traceDetails, object p1, object p2, object p3 ) + { + _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); + } + + // Is tracing enabled here? + static public bool IsEnabled + { + get { return _avTrace != null && _avTrace.IsEnabled; } + } + + // Is there a Tracesource? (See comment on AvTrace.IsEnabledOverride.) + static public bool IsEnabledOverride + { + get { return _avTrace.IsEnabledOverride; } + } + + // Re-read the configuration for this trace source + static public void Refresh() + { + _avTrace.Refresh(); + } + } +<# } #> +} \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets new file mode 100644 index 00000000000..cda05f412a5 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets @@ -0,0 +1,24 @@ + + + $(MSBuildProjectDirectory)\AvTraceMessages.json + + + + + TextTemplatingFileGenerator + AvTraceMessages.cs + $(MSBuildProjectDirectory)\Generated\ + + + True + True + $(MSBuildThisFileDirectory)AvTraceMessages.tt + + + + + $(AvTraceMessageFile) + False + + + \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index 3842f7353fe..5f1fc13a5f3 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -1,111 +1,15 @@ - - - - - - - 16.0 - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - true - - true - - false - $(MSBuildProjectDirectory)\AvTraceMessages.json - 12.0.2-beta1 + $(WpfSourceDir)\WindowsBase\AvTraceMessages.json + $(WpfSourceDir)\PresentationCore\AvTraceMessages.json + $(WpfSourceDir)\PresentationFramework\AvTraceMessages.json - - - - - - - - - - - - - - - - - - - - $(RootNamespace) - - - - - - - - - - - - - - - - - TextTemplatingFileGenerator - AvTraceDetails.cs - $(MSBuildProjectDirectory)\Generated\ - - - True - True - $(MSBuildThisFileDirectory)AvTraceDetails.tt - TextTemplatingFileGenerator PresentationTraceSources.cs - $(MSBuildProjectDirectory)\Generated\ + $(WpfSourceDir)\WindowsBase\Generated\ True @@ -114,13 +18,9 @@ - - $(AvTraceMessageFile) + + $(WindowsBaseAvTraceMessageFile);$(PresentationCoreAvTraceMessageFile);$(PresentationFrameworkAvTraceMessageFile) False - - $(NugetPackageRoot)\newtonsoft.json\$(NewtonsoftVersion)\lib\netstandard2.0 - false - \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 1c1dc3ec88e..d7d15888b3c 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -9,7 +9,7 @@ <#@ import namespace="System.IO" #> <#@ import namespace="Newtonsoft.Json" #> <#@ output extension=".cs" #> -<#@ parameter type="System.String" name="AvTraceMessageFile" #> +<#@ parameter type="System.String" name="AvTraceMessageFiles" #> // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -22,12 +22,14 @@ namespace System.Diagnostics public static partial class PresentationTraceSources { <# - string fileName = this.Host.ResolvePath(AvTraceMessageFile); - string jsonText = File.ReadAllText(fileName); - dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); - foreach (var source in jsonObj.sources) + foreach (var avTracMessageFile in AvTraceMessageFiles.Split(';')) { - string name = source.name; + string fileName = this.Host.ResolvePath(avTracMessageFile); + string jsonText = File.ReadAllText(fileName); + dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); + foreach (var source in jsonObj.sources) + { + string name = source.name; #> /// <#=name#>Source for <#=name#> public static TraceSource <#=name#>Source @@ -42,7 +44,7 @@ namespace System.Diagnostics } } internal static TraceSource _<#=name#>Source; - -<# } #> +<# } + } #> } } \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets new file mode 100644 index 00000000000..79c070b0f33 --- /dev/null +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -0,0 +1,98 @@ + + + + + + + + + 16.0 + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + true + + true + + false + 12.0.2-beta1 + + + + + + + + + + + + + + + + + + + + + $(RootNamespace) + + + + + + + + + + + + + + + + + + $(NugetPackageRoot)\newtonsoft.json\$(NewtonsoftVersion)\lib\netstandard2.0 + false + + + \ No newline at end of file From 97b69367ecd22baf23b97309440897ecf05a0ec6 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Tue, 16 Apr 2019 11:19:58 -0700 Subject: [PATCH 08/21] making generated code prettier --- eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt | 2 +- .../tools/CodeGen/AvTrace/PresentationTraceSources.tt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 1662aa0242c..2a9fdc8700b 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -48,7 +48,7 @@ namespace MS.Internal { if ( _<#=traceName#> == null ) { -<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace(Environment.NewLine,"").Trim(); #> +<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); #> _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>", <#=dataString#> } ); } diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index d7d15888b3c..769fa25bfc4 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -44,6 +44,7 @@ namespace System.Diagnostics } } internal static TraceSource _<#=name#>Source; + <# } } #> } From 902b69ec1d455cf0adf940ce5b8137c4bfb0de52 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Tue, 16 Apr 2019 15:12:41 -0700 Subject: [PATCH 09/21] adding formatting strings --- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 2a9fdc8700b..4366cba08b1 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -25,9 +25,10 @@ namespace MS.Internal dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); foreach (var source in jsonObj.sources) { - string name = source.name; + string name = source.name; + string traceClassName = source.tracename_override ?? $"Trace{name}"; #> - static internal partial class Trace<#=name#> + static internal partial class <#=traceClassName#> { static private AvTrace _avTrace = new AvTrace( delegate() { return PresentationTraceSources.<#=name#>Source; }, @@ -42,21 +43,43 @@ namespace MS.Internal string traceName = traceDetails.name; #> static AvTraceDetails _<#=traceName#>; +<# // Formattings strings are invoked by a function call, not a property + string traceMessage = traceDetails.message.ToString(); + if (traceMessage.Contains("{0}")) + { +#> + static public AvTraceDetails <#=traceName#>(params object[] args) + { + if ( _<#=traceName#> == null ) + { + _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceMessage #>" } ); + } + return new AvTraceFormat(_<#=traceName#>, args); + } + +<# } else { #> static public AvTraceDetails <#=traceName#> { get { if ( _<#=traceName#> == null ) { -<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); #> - _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>", <#=dataString#> } ); +<# if (traceDetails.data.Count == 0) { #> + _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>" } ); +<# } else { #> +<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); #> + _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceMessage #>", <#=dataString#> } ); +<# } #> } return _<#=traceName#>; } } + +<# } #> <# } #> + // Send a single trace output static public void Trace( TraceEventType type, AvTraceDetails traceDetails, params object[] parameters ) { From 3a3c1bcc8ca505471fa45dd8b0e459cb476a53aa Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Tue, 16 Apr 2019 15:20:34 -0700 Subject: [PATCH 10/21] adding note about the file being generated --- eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt | 4 ++++ .../tools/CodeGen/AvTrace/PresentationTraceSources.tt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 4366cba08b1..c5493c943f8 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -14,6 +14,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. + +// NOTE: This file was generated by $(WpfCodeGenDir)AvTrace\AvTraceMessages.tt. +// Any manual updates to this file will overwritten. + using System; using System.Diagnostics; diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 769fa25bfc4..7a707f38799 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -10,10 +10,14 @@ <#@ import namespace="Newtonsoft.Json" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFiles" #> + // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// NOTE: This file was generated by $(WpfCodeGenDir)AvTrace\PresentationTraceSources.tt. +// Any manual updates to this file will overwritten. + using MS.Internal; namespace System.Diagnostics From 43d6541997deee3dc9cdbc07a94c46f8cdb68fc4 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Tue, 16 Apr 2019 15:33:06 -0700 Subject: [PATCH 11/21] removing extra line at top of files --- eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt | 1 - .../tools/CodeGen/AvTrace/PresentationTraceSources.tt | 1 - 2 files changed, 2 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index c5493c943f8..b8ff144dd21 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -10,7 +10,6 @@ <#@ import namespace="Newtonsoft.Json" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFile" #> - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 7a707f38799..4b489f589e6 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -10,7 +10,6 @@ <#@ import namespace="Newtonsoft.Json" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFiles" #> - // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. From 0d2c932327346a6aef5b718bd535e6c0b029c5cb Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Wed, 17 Apr 2019 08:06:56 -0700 Subject: [PATCH 12/21] making the .tt a bit cleaner --- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index b8ff144dd21..4194e1dc9f8 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -8,6 +8,7 @@ <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="System.IO" #> <#@ import namespace="Newtonsoft.Json" #> +<#@ import namespace="Newtonsoft.Json.Linq" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFile" #> // Licensed to the .NET Foundation under one or more agreements. @@ -37,7 +38,6 @@ namespace MS.Internal delegate() { return PresentationTraceSources.<#=name#>Source; }, delegate() { PresentationTraceSources._<#=name#>Source = null; } ); - <# int id = 0; foreach (var traceDetails in source.trace_details) @@ -45,21 +45,20 @@ namespace MS.Internal ++id; string traceName = traceDetails.name; #> + static AvTraceDetails _<#=traceName#>; <# // Formattings strings are invoked by a function call, not a property - string traceMessage = traceDetails.message.ToString(); - if (traceMessage.Contains("{0}")) + if (IsFormattedTraceMessage(traceDetails)) { #> static public AvTraceDetails <#=traceName#>(params object[] args) { if ( _<#=traceName#> == null ) { - _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceMessage #>" } ); + <# OutputTraceCreation(id, traceDetails); #> } return new AvTraceFormat(_<#=traceName#>, args); } - <# } else { #> static public AvTraceDetails <#=traceName#> { @@ -67,22 +66,15 @@ namespace MS.Internal { if ( _<#=traceName#> == null ) { -<# if (traceDetails.data.Count == 0) { #> - _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails.message #>" } ); -<# } else { #> -<# string dataString = traceDetails.data.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); #> - _<#=traceName#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceMessage #>", <#=dataString#> } ); -<# } #> + <# OutputTraceCreation(id, traceDetails); #> } return _<#=traceName#>; } } - <# } #> <# } #> - // Send a single trace output static public void Trace( TraceEventType type, AvTraceDetails traceDetails, params object[] parameters ) { @@ -150,4 +142,38 @@ namespace MS.Internal } } <# } #> -} \ No newline at end of file +} +<#+ +bool TryGetTraceDataString(JArray traceData, out string traceDataString) +{ + traceDataString = string.Empty; + if (traceData.Count > 0) + { + traceDataString = traceData.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); + } + return !string.IsNullOrEmpty(traceDataString); +} +bool IsFormattedTraceMessage(JObject traceDetails) +{ + string traceMessage = traceDetails["message"].ToString(); + return traceMessage.Contains("{0}"); +} +// Put any Output* methods at the end, as they tend to be a bit messier because they need the special tags. +// For ease of re-use, methods that output text should not make any assumptions about the indentation, and it +// should be the callers responsibility for properly indenting +void OutputTraceCreation(int id, JObject traceDetails) +{ + var traceData = (JArray)traceDetails["data"]; + if (TryGetTraceDataString(traceData, out string dataString)) + { + // Prepend the comma to the list of strings (if any). This way we can write the dataString + // regardless if it is empty or not + dataString = $", {dataString}"; + } + // The list of data strings in the JsonArray will already have quotation marks (i.e. "data1"), + // so we specifically don't add quotes around those here. +#> +_<#=traceDetails["name"]#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails["message"] #>"<#=dataString#> } ); +<#+ +} +#> \ No newline at end of file From 1cb305b76f02a9239f86e3a37619d7977cfb1d05 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 18 Apr 2019 09:34:49 -0700 Subject: [PATCH 13/21] don't run certain targets that aren't supported when building using "dotnet" --- .../tools/CodeGen/DesignTimeTextTemplating.targets | 2 +- eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets index 79c070b0f33..0478b0e202e 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -20,7 +20,7 @@ false 12.0.2-beta1 - + diff --git a/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets b/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets index 466425168a2..6f200a9d584 100644 --- a/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets +++ b/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets @@ -120,7 +120,8 @@ --> + AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" + Condition="'$(MSBuildRuntimeType)'!='Core'"> @@ -294,7 +295,7 @@ - + From f0fcfad62a905e0a1a7ac95cf42f68f98f81281c Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 18 Apr 2019 11:06:52 -0700 Subject: [PATCH 14/21] adding codegen guidance --- Documentation/codegen.md | 86 +++++++++++++++++++ Documentation/developer-guide.md | 1 + .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 5 +- .../CodeGen/DesignTimeTextTemplating.targets | 4 +- .../tools/ExtendedAssemblyInfo.targets | 5 +- 5 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 Documentation/codegen.md diff --git a/Documentation/codegen.md b/Documentation/codegen.md new file mode 100644 index 00000000000..6d627e7d3b0 --- /dev/null +++ b/Documentation/codegen.md @@ -0,0 +1,86 @@ +# CodeGen in the dotnet/wpf repo + +The following document describes how code generation in this repo works. The goal is to have all our code generation done through the use of T4 text generation. See the offical [Visual Studio T4 documentation](https://docs.microsoft.com/en-us/visualstudio/modeling/design-time-code-generation-by-using-t4-text-templates?view=vs-2019) for more information. + +## Basic T4 code generation philosophy and guidelines +T4 templates can be a powerful tool, however without a conscious effort, they can quickly become unmaintainable and difficult to understand. When authoring/modifying a T4 template, extra care should be taken to ensure that the templates are as readable as possible. While the "readibility" of a template may be a bit subjective, there are a few common guidelines that really help. Note that these are guidelines, and are not mandatory. The readability of the template is paramount to all things. + +* When multiple lines of code need to be written inside of "<# #>" blocks, the "<#" and "#>" tags should be on seperate lines. This makes it easier to tell where the code starts and stops. If we follow this policy, we can know that a line that only contains a "<#" tag is the start of a multi-line code block. + +**Correct** +``` +<# + string helloWorld = " Hello World "; + hellowWorld = helloWorld.Trim(); +#> +<#= hellowWorld #> +``` +**Incorrect** +``` +<# string helloWorld = " Hello World "; + helloWorld = helloWorld.Trim(); #> +<#= hellowWorld #> +``` + +* In similar fashion, single-line code statements should contain the "<#" and "#>" tags on the same line as the code. This way we can know that any line that starts with a "<#" that has code next to it is only a one-line statement. + +* if/else/elseif statements, and the closing bracket, should all be contained on a single line + +**Correct** +``` +<# if (WriteAsFunction()){ #> +bool GetFoo() +{ + ... +} +<# } else { #> +bool Foo +{ + get {...} +} +<# } #> +``` +**Incorrect** +``` +<# +if (WriteAsFunction()) +{ +#> +bool GetFoo() +{ + ... +} +<# +} +else +{ +#> +bool Foo +{ + get {...} +} +<# +} +#> +``` +* T4 generation allows you to write functions that you can invoke in the template inside of "<#+ #>" blocks. If the function is intended to be re-used to output some common text, the name of the function should start with "Output" so that is clear to the reader the intent of the function. Also, these functions should not impose any extra indentation (or it should be minimal), as this makes it more complicated to re-use and plug +in the function anywhere throughout the template. + +**Correct** +``` +<#+ void OutputFooFunction() { #> +bool GetFoo() +{ + ... +} +<#+ } #> +``` +**Incorrect** +``` +<#+ void FooFunction() { #> + bool GetFoo() + { + ... + } +<#+ } #> +``` \ No newline at end of file diff --git a/Documentation/developer-guide.md b/Documentation/developer-guide.md index 87ce5200cb3..f1988774c09 100644 --- a/Documentation/developer-guide.md +++ b/Documentation/developer-guide.md @@ -158,3 +158,4 @@ Follow the steps defined [here](https://github.com/dotnet/arcade/blob/master/Doc * [Coding guidelines](https://github.com/dotnet/corefx/tree/master/Documentation#coding-guidelines) * [up-for-grabs WPF issues](https://github.com/dotnet/wpf/issues?q=is%3Aopen+is%3Aissue+label%3Aup-for-grabs) * [easy WPF issues](https://github.com/dotnet/wpf/issues?utf8=%E2%9C%93&q=is%3Aopen+is%3Aissue+label%3Aeasy) +* [Code generation in dotnet/wpf](codegen.md) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 4194e1dc9f8..3795fdc4211 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -47,10 +47,7 @@ namespace MS.Internal #> static AvTraceDetails _<#=traceName#>; -<# // Formattings strings are invoked by a function call, not a property - if (IsFormattedTraceMessage(traceDetails)) - { -#> +<# if (IsFormattedTraceMessage(traceDetails)) { #> static public AvTraceDetails <#=traceName#>(params object[] args) { if ( _<#=traceName#> == null ) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets index 0478b0e202e..35d8682c1c0 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -14,13 +14,11 @@ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) true - - true false 12.0.2-beta1 - + diff --git a/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets b/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets index 6f200a9d584..e32ef43e2c0 100644 --- a/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets +++ b/eng/WpfArcadeSdk/tools/ExtendedAssemblyInfo.targets @@ -120,8 +120,7 @@ --> + AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> @@ -295,7 +294,7 @@ - + From ffaeacb9dde74aaaaf5f0502c0f196cd59d58a18 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 18 Apr 2019 12:06:35 -0700 Subject: [PATCH 15/21] adding dependency via "darc add-dependency" --- eng/Version.Details.xml | 5 +++++ eng/Versions.props | 1 + .../tools/CodeGen/DesignTimeTextTemplating.targets | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index e61d91e44f4..9a7d70e5d37 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -75,5 +75,10 @@ https://github.com/dotnet/corefx bd278630dd08914ef521e62658afb69845c5b93a + + https://github.com/JamesNK/Newtonsoft.Json + + + diff --git a/eng/Versions.props b/eng/Versions.props index edf224bd44f..91c1effe88e 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -4,6 +4,7 @@ 4.8.0 preview6 4.0.0.0 + 12.0.1 diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets index 35d8682c1c0..d4194ebc294 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -16,8 +16,10 @@ true false - 12.0.2-beta1 + + + @@ -89,7 +91,7 @@ - $(NugetPackageRoot)\newtonsoft.json\$(NewtonsoftVersion)\lib\netstandard2.0 + $(PkgNewtonSoft_Json)\lib\netstandard2.0 false From 848cd16d40638401d366855a58d9b0256de9548e Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 18 Apr 2019 12:34:35 -0700 Subject: [PATCH 16/21] adding more info to codegen.md --- Documentation/codegen.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/codegen.md b/Documentation/codegen.md index 6d627e7d3b0..495a01d3660 100644 --- a/Documentation/codegen.md +++ b/Documentation/codegen.md @@ -2,6 +2,16 @@ The following document describes how code generation in this repo works. The goal is to have all our code generation done through the use of T4 text generation. See the offical [Visual Studio T4 documentation](https://docs.microsoft.com/en-us/visualstudio/modeling/design-time-code-generation-by-using-t4-text-templates?view=vs-2019) for more information. +## Design-Time vs Run-Time T4 templates +Currently, we are evaluating the use of design-time text templates. This gives us the ability to simply add the templates and associated targets to the build, without the need of maintaining a separate tool to do run-time generation. Including the `Microsoft.TextTemplating.targets` requires us to manually import Sdk.Targets because it needs to be imported after Sdk.targets. This causes the `BuildDependsOn` variable, which is modified by the T4 targets, to be overwritten, so the `TransformAll` target doesn’t run before the Build target. The boilerplait for including design-time templates has been encapsulated in the `$(WpfCodeGenDir)DesignTimeTextTemplating.targets` file, so the pattern for enabling these in a project looks like this: + +``` + + + + +``` + ## Basic T4 code generation philosophy and guidelines T4 templates can be a powerful tool, however without a conscious effort, they can quickly become unmaintainable and difficult to understand. When authoring/modifying a T4 template, extra care should be taken to ensure that the templates are as readable as possible. While the "readibility" of a template may be a bit subjective, there are a few common guidelines that really help. Note that these are guidelines, and are not mandatory. The readability of the template is paramount to all things. @@ -83,4 +93,12 @@ bool GetFoo() ... } <#+ } #> -``` \ No newline at end of file +``` + + ## Location of CodeGen targets + Unless there is a good reason (that should be documented), all codegen related targets should go into the $(WpfArcadeSdk)tools\CodeGen folder. This way we have a clean and clear location where we are able to keep track of all code generation in the codebase. + + ## GenTraceSources and GenAvMessages + These two projects codegen the files the WPF codebase uses for tracing, and both use the AvTraceMessages.json files located in the project location that includes it, located via the MSBuild property $(MSBuildProjectFileDirectory). + + **Note**: GenTraceSources should currently only be used by WindowsBase. It generates the [PresentationTraceSources](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.presentationtracesources?view=netcore3.0) class, which is a public class. Changing this file can impact the public API surface of WindowsBase or other WPF assemblies. \ No newline at end of file From c1716d6914161f8ede1d0054190340eceff7d048 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Fri, 19 Apr 2019 09:20:42 -0700 Subject: [PATCH 17/21] removing use of dynamic --- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 14 ++++++-------- .../CodeGen/AvTrace/PresentationTraceSources.tt | 10 ++++------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 3795fdc4211..888e092a134 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -2,7 +2,6 @@ <#@ assembly name="System.Core" #> <#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> <#@ assembly name="netstandard" #> -<#@ assembly name="Microsoft.CSharp" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> @@ -25,12 +24,11 @@ namespace MS.Internal { <# string fileName = this.Host.ResolvePath(AvTraceMessageFile); - string jsonText = File.ReadAllText(fileName); - dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); - foreach (var source in jsonObj.sources) + JObject jsonObj = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(fileName)); + foreach (JObject source in (JArray)jsonObj["sources"]) { - string name = source.name; - string traceClassName = source.tracename_override ?? $"Trace{name}"; + string name = source["name"].ToString(); + string traceClassName = (source["tracename_override"]?.ToString()) ?? $"Trace{name}"; #> static internal partial class <#=traceClassName#> { @@ -40,10 +38,10 @@ namespace MS.Internal ); <# int id = 0; - foreach (var traceDetails in source.trace_details) + foreach (JObject traceDetails in (JArray)source["trace_details"]) { ++id; - string traceName = traceDetails.name; + string traceName = traceDetails["name"].ToString(); #> static AvTraceDetails _<#=traceName#>; diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 4b489f589e6..0544dd49e0b 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -2,7 +2,6 @@ <#@ assembly name="System.Core" #> <#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> <#@ assembly name="netstandard" #> -<#@ assembly name="Microsoft.CSharp" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> @@ -28,11 +27,10 @@ namespace System.Diagnostics foreach (var avTracMessageFile in AvTraceMessageFiles.Split(';')) { string fileName = this.Host.ResolvePath(avTracMessageFile); - string jsonText = File.ReadAllText(fileName); - dynamic jsonObj = JsonConvert.DeserializeObject(jsonText); - foreach (var source in jsonObj.sources) + JObject jsonObj = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(fileName)); + foreach (JObject source in (JArray)jsonObj["sources"]) { - string name = source.name; + string name = source["name"].ToString(); #> /// <#=name#>Source for <#=name#> public static TraceSource <#=name#>Source @@ -41,7 +39,7 @@ namespace System.Diagnostics { if (_<#=name#>Source == null) { - _<#=name#>Source = CreateTraceSource("<#=source.source_name#>"); + _<#=name#>Source = CreateTraceSource("<#=source["source_name"]#>"); } return _<#=name#>Source; } From 667468fc6cba6fbc373d92a1330524448d6a52b6 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 25 Apr 2019 13:24:18 -0700 Subject: [PATCH 18/21] converting to xml instead of json --- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 68 +++++++++---------- .../CodeGen/AvTrace/GenAvMessages.targets | 4 +- .../CodeGen/AvTrace/GenTraceSources.targets | 8 +-- .../AvTrace/PresentationTraceSources.tt | 16 ++--- .../CodeGen/DesignTimeTextTemplating.targets | 9 --- 5 files changed, 47 insertions(+), 58 deletions(-) diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index 888e092a134..d1db2dc9a81 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -1,13 +1,12 @@ <#@ template hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> -<#@ assembly name="netstandard" #> +<#@ assembly name="System.Xml" #> +<#@ assembly name="System.Xml.XDocument" #> +<#@ assembly name="System.Xml.Linq" #> <#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> +<#@ import namespace="System.Xml.Linq" #> <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="System.IO" #> -<#@ import namespace="Newtonsoft.Json" #> -<#@ import namespace="Newtonsoft.Json.Linq" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFile" #> // Licensed to the .NET Foundation under one or more agreements. @@ -24,13 +23,13 @@ namespace MS.Internal { <# string fileName = this.Host.ResolvePath(AvTraceMessageFile); - JObject jsonObj = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(fileName)); - foreach (JObject source in (JArray)jsonObj["sources"]) + XDocument doc = XDocument.Load(fileName); + foreach (XElement source in doc.Root.Elements("Source")) { - string name = source["name"].ToString(); - string traceClassName = (source["tracename_override"]?.ToString()) ?? $"Trace{name}"; + string name = source.Attribute("Name").Value; + string traceClassName = source.Attribute("TraceNameOverride")?.Value ?? $"Trace{name}"; #> - static internal partial class <#=traceClassName#> + static internal partial class <#= traceClassName #> { static private AvTrace _avTrace = new AvTrace( delegate() { return PresentationTraceSources.<#=name#>Source; }, @@ -38,33 +37,33 @@ namespace MS.Internal ); <# int id = 0; - foreach (JObject traceDetails in (JArray)source["trace_details"]) + foreach (XElement traceDetails in source.Elements("TraceDetails")) { ++id; - string traceName = traceDetails["name"].ToString(); + string traceName = traceDetails.Attribute("Name").Value; #> static AvTraceDetails _<#=traceName#>; <# if (IsFormattedTraceMessage(traceDetails)) { #> - static public AvTraceDetails <#=traceName#>(params object[] args) + static public AvTraceDetails <#= traceName #>(params object[] args) { if ( _<#=traceName#> == null ) { <# OutputTraceCreation(id, traceDetails); #> } - return new AvTraceFormat(_<#=traceName#>, args); + return new AvTraceFormat(_<#= traceName #>, args); } <# } else { #> - static public AvTraceDetails <#=traceName#> + static public AvTraceDetails <#= traceName #> { get { - if ( _<#=traceName#> == null ) + if ( _<#= traceName #> == null ) { <# OutputTraceCreation(id, traceDetails); #> } - return _<#=traceName#>; + return _<#= traceName #>; } } <# } #> @@ -139,36 +138,35 @@ namespace MS.Internal <# } #> } <#+ -bool TryGetTraceDataString(JArray traceData, out string traceDataString) +string GetTraceDataString(XElement labels) { - traceDataString = string.Empty; - if (traceData.Count > 0) + // We need to ensure that we have quotes around each of these so that they will be written with them + string traceDataString = $"\"{labels.Attribute("Message").Value}\""; + if (labels.HasElements) { - traceDataString = traceData.ToString().Trim('[',']').Replace($"{Environment.NewLine} ","").Trim(); + foreach (XElement param in labels.Elements("Parameters")) + { + traceDataString += labels.LastNode != param ? $"\"{param}\", " : $"\"{param}\""; + } } - return !string.IsNullOrEmpty(traceDataString); + + return traceDataString; } -bool IsFormattedTraceMessage(JObject traceDetails) +bool IsFormattedTraceMessage(XElement traceDetails) { - string traceMessage = traceDetails["message"].ToString(); + XElement labels = traceDetails.Element("Labels"); + string traceMessage = labels.Attribute("Message").Value; return traceMessage.Contains("{0}"); } // Put any Output* methods at the end, as they tend to be a bit messier because they need the special tags. // For ease of re-use, methods that output text should not make any assumptions about the indentation, and it // should be the callers responsibility for properly indenting -void OutputTraceCreation(int id, JObject traceDetails) +void OutputTraceCreation(int id, XElement traceDetails) { - var traceData = (JArray)traceDetails["data"]; - if (TryGetTraceDataString(traceData, out string dataString)) - { - // Prepend the comma to the list of strings (if any). This way we can write the dataString - // regardless if it is empty or not - dataString = $", {dataString}"; - } - // The list of data strings in the JsonArray will already have quotation marks (i.e. "data1"), - // so we specifically don't add quotes around those here. + XElement labels = traceDetails.Element("Labels"); + string dataString = GetTraceDataString(labels); #> -_<#=traceDetails["name"]#> = new AvTraceDetails(<#=id#>, new string[] { "<#=traceDetails["message"] #>"<#=dataString#> } ); +_<#= traceDetails.Attribute("Name").Value #> = new AvTraceDetails(<#=id#>, new string[] { <#= dataString #> } ); <#+ } #> \ No newline at end of file diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets index cda05f412a5..fcd188f0d81 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenAvMessages.targets @@ -1,13 +1,13 @@ - $(MSBuildProjectDirectory)\AvTraceMessages.json + $(MSBuildProjectDirectory)\AvTraceMessages.xml TextTemplatingFileGenerator AvTraceMessages.cs - $(MSBuildProjectDirectory)\Generated\ + $(MSBuildProjectDirectory)\MS\Internal\Generated\ True diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets index 5f1fc13a5f3..dc85c259768 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/GenTraceSources.targets @@ -1,15 +1,15 @@ - $(WpfSourceDir)\WindowsBase\AvTraceMessages.json - $(WpfSourceDir)\PresentationCore\AvTraceMessages.json - $(WpfSourceDir)\PresentationFramework\AvTraceMessages.json + $(WpfSourceDir)\WindowsBase\AvTraceMessages.xml + $(WpfSourceDir)\PresentationCore\AvTraceMessages.xml + $(WpfSourceDir)\PresentationFramework\AvTraceMessages.xml TextTemplatingFileGenerator PresentationTraceSources.cs - $(WpfSourceDir)\WindowsBase\Generated\ + $(WpfSourceDir)\WindowsBase\System\Diagnostics\Generated\ True diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 0544dd49e0b..8df72fd51e3 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -1,12 +1,12 @@ <#@ template hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> -<#@ assembly name="$(NewtonsoftLocation)\Newtonsoft.Json.dll" #> -<#@ assembly name="netstandard" #> +<#@ assembly name="System.Xml" #> +<#@ assembly name="System.Xml.XDocument" #> +<#@ assembly name="System.Xml.Linq" #> <#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> +<#@ import namespace="System.Xml.Linq" #> <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="System.IO" #> -<#@ import namespace="Newtonsoft.Json" #> <#@ output extension=".cs" #> <#@ parameter type="System.String" name="AvTraceMessageFiles" #> // Licensed to the .NET Foundation under one or more agreements. @@ -27,10 +27,10 @@ namespace System.Diagnostics foreach (var avTracMessageFile in AvTraceMessageFiles.Split(';')) { string fileName = this.Host.ResolvePath(avTracMessageFile); - JObject jsonObj = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(fileName)); - foreach (JObject source in (JArray)jsonObj["sources"]) + XDocument doc = XDocument.Load(fileName); + foreach (XElement source in doc.Root.Elements("Source")) { - string name = source["name"].ToString(); + string name = source.Attribute("Name").Value; #> /// <#=name#>Source for <#=name#> public static TraceSource <#=name#>Source @@ -39,7 +39,7 @@ namespace System.Diagnostics { if (_<#=name#>Source == null) { - _<#=name#>Source = CreateTraceSource("<#=source["source_name"]#>"); + _<#=name#>Source = CreateTraceSource("<#= source.Attribute("SourceName").Value #>"); } return _<#=name#>Source; } diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets index d4194ebc294..cb07be5d40d 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -17,9 +17,6 @@ false - - - @@ -89,10 +86,4 @@ - - - $(PkgNewtonSoft_Json)\lib\netstandard2.0 - false - - \ No newline at end of file From 02edc41eae8a5045a18ea471f97932cdd9ce0b1c Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 25 Apr 2019 13:26:57 -0700 Subject: [PATCH 19/21] updating documentation to xml --- Documentation/codegen.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/codegen.md b/Documentation/codegen.md index 495a01d3660..f767e5efc8b 100644 --- a/Documentation/codegen.md +++ b/Documentation/codegen.md @@ -99,6 +99,6 @@ bool GetFoo() Unless there is a good reason (that should be documented), all codegen related targets should go into the $(WpfArcadeSdk)tools\CodeGen folder. This way we have a clean and clear location where we are able to keep track of all code generation in the codebase. ## GenTraceSources and GenAvMessages - These two projects codegen the files the WPF codebase uses for tracing, and both use the AvTraceMessages.json files located in the project location that includes it, located via the MSBuild property $(MSBuildProjectFileDirectory). + These two projects codegen the files the WPF codebase uses for tracing, and both use the AvTraceMessages.xml files located in the project location that includes it, located via the MSBuild property $(MSBuildProjectFileDirectory). **Note**: GenTraceSources should currently only be used by WindowsBase. It generates the [PresentationTraceSources](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.presentationtracesources?view=netcore3.0) class, which is a public class. Changing this file can impact the public API surface of WindowsBase or other WPF assemblies. \ No newline at end of file From d5ab2cf4522029310d866b7855dbde8d24295dcb Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Thu, 25 Apr 2019 13:36:51 -0700 Subject: [PATCH 20/21] removing newtonsoft dependency --- eng/Version.Details.xml | 5 ----- eng/Versions.props | 1 - 2 files changed, 6 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 9a7d70e5d37..e61d91e44f4 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -75,10 +75,5 @@ https://github.com/dotnet/corefx bd278630dd08914ef521e62658afb69845c5b93a - - https://github.com/JamesNK/Newtonsoft.Json - - - diff --git a/eng/Versions.props b/eng/Versions.props index 91c1effe88e..edf224bd44f 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -4,7 +4,6 @@ 4.8.0 preview6 4.0.0.0 - 12.0.1 From 044170c0aeb68c6a898b61d095367faa741ad5f7 Mon Sep 17 00:00:00 2001 From: Steven Kirbach Date: Mon, 6 May 2019 15:59:42 -0700 Subject: [PATCH 21/21] cr feedback --- Documentation/codegen.md | 4 ++-- .../tools/CodeGen/AvTrace/AvTraceMessages.tt | 13 ++++++------- .../CodeGen/AvTrace/PresentationTraceSources.tt | 4 ++-- .../tools/CodeGen/DesignTimeTextTemplating.targets | 5 ----- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Documentation/codegen.md b/Documentation/codegen.md index f767e5efc8b..cb5fec33960 100644 --- a/Documentation/codegen.md +++ b/Documentation/codegen.md @@ -3,7 +3,7 @@ The following document describes how code generation in this repo works. The goal is to have all our code generation done through the use of T4 text generation. See the offical [Visual Studio T4 documentation](https://docs.microsoft.com/en-us/visualstudio/modeling/design-time-code-generation-by-using-t4-text-templates?view=vs-2019) for more information. ## Design-Time vs Run-Time T4 templates -Currently, we are evaluating the use of design-time text templates. This gives us the ability to simply add the templates and associated targets to the build, without the need of maintaining a separate tool to do run-time generation. Including the `Microsoft.TextTemplating.targets` requires us to manually import Sdk.Targets because it needs to be imported after Sdk.targets. This causes the `BuildDependsOn` variable, which is modified by the T4 targets, to be overwritten, so the `TransformAll` target doesn’t run before the Build target. The boilerplait for including design-time templates has been encapsulated in the `$(WpfCodeGenDir)DesignTimeTextTemplating.targets` file, so the pattern for enabling these in a project looks like this: +Currently, we are evaluating the use of design-time text templates. This gives us the ability to simply add the templates and associated targets to the build, without the need of maintaining a separate tool to do run-time generation. When using the SDK-style project format, including the `Microsoft.TextTemplating.targets` requires us to manually import `Sdk.Targets` because the `BuildDependsOn` variable, which is modified by the T4 targets, would otherwise be overwritten by the automatic inclusion of `Sdk.targets`. This causes the `TransformAll` target to not run before the `Build` target. The boilerplait for including design-time templates has been encapsulated in the `$(WpfCodeGenDir)DesignTimeTextTemplating.targets` file, so the pattern for enabling these in a project looks like this: ``` @@ -13,7 +13,7 @@ Currently, we are evaluating the use of design-time text templates. This gives u ``` ## Basic T4 code generation philosophy and guidelines -T4 templates can be a powerful tool, however without a conscious effort, they can quickly become unmaintainable and difficult to understand. When authoring/modifying a T4 template, extra care should be taken to ensure that the templates are as readable as possible. While the "readibility" of a template may be a bit subjective, there are a few common guidelines that really help. Note that these are guidelines, and are not mandatory. The readability of the template is paramount to all things. +T4 templates can be a powerful tool, however without a conscious effort, they can quickly become unmaintainable and difficult to understand. When authoring/modifying a T4 template, extra care should be taken to ensure that the templates are as readable as possible. While the "readability" of a template may be a bit subjective, there are a few common guidelines that really help. Note that these are guidelines, and are not mandatory. The readability of the template is paramount to all things. * When multiple lines of code need to be written inside of "<# #>" blocks, the "<#" and "#>" tags should be on seperate lines. This makes it easier to tell where the code starts and stops. If we follow this policy, we can know that a line that only contains a "<#" tag is the start of a multi-line code block. diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt index d1db2dc9a81..71467b40910 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/AvTraceMessages.tt @@ -69,13 +69,13 @@ namespace MS.Internal <# } #> <# } #> - // Send a single trace output + /// Send a single trace output static public void Trace( TraceEventType type, AvTraceDetails traceDetails, params object[] parameters ) { _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); } - // these help delay allocation of object array + /// These help delay allocation of object array static public void Trace( TraceEventType type, AvTraceDetails traceDetails ) { _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); @@ -93,13 +93,13 @@ namespace MS.Internal _avTrace.Trace( type, traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); } - // Send a singleton "activity" trace (really, this sends the same trace as both a Start and a Stop) + /// Send a singleton "activity" trace (really, this sends the same trace as both a Start and a Stop) static public void TraceActivityItem( AvTraceDetails traceDetails, params Object[] parameters ) { _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, parameters ); } - // these help delay allocation of object array + /// These help delay allocation of object array static public void TraceActivityItem( AvTraceDetails traceDetails ) { _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[0] ); @@ -117,19 +117,18 @@ namespace MS.Internal _avTrace.TraceStartStop( traceDetails.Id, traceDetails.Message, traceDetails.Labels, new object[] { p1, p2, p3 } ); } - // Is tracing enabled here? static public bool IsEnabled { get { return _avTrace != null && _avTrace.IsEnabled; } } - // Is there a Tracesource? (See comment on AvTrace.IsEnabledOverride.) + /// Is there a Tracesource? (See comment on AvTrace.IsEnabledOverride.) static public bool IsEnabledOverride { get { return _avTrace.IsEnabledOverride; } } - // Re-read the configuration for this trace source + /// Re-read the configuration for this trace source static public void Refresh() { _avTrace.Refresh(); diff --git a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt index 8df72fd51e3..5bc9457a827 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt +++ b/eng/WpfArcadeSdk/tools/CodeGen/AvTrace/PresentationTraceSources.tt @@ -24,9 +24,9 @@ namespace System.Diagnostics public static partial class PresentationTraceSources { <# - foreach (var avTracMessageFile in AvTraceMessageFiles.Split(';')) + foreach (var avTraceMessageFile in AvTraceMessageFiles.Split(';')) { - string fileName = this.Host.ResolvePath(avTracMessageFile); + string fileName = this.Host.ResolvePath(avTraceMessageFile); XDocument doc = XDocument.Load(fileName); foreach (XElement source in doc.Root.Elements("Source")) { diff --git a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets index cb07be5d40d..1af21bd38e9 100644 --- a/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets +++ b/eng/WpfArcadeSdk/tools/CodeGen/DesignTimeTextTemplating.targets @@ -2,11 +2,6 @@ - - 16.0