Skip to content
This repository has been archived by the owner on May 21, 2018. It is now read-only.

Support to output the type definitions anywhere else in the filesystem #63

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ _ReSharper.T4TS.Example
T4TS.Build/_ReSharper.T4TS.Build
!buid/T4TS.Attributes.dll
packages/
build/T4TS.d.ts
build/test.d.ts
2 changes: 1 addition & 1 deletion T4TS.Build.Builder/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 23 additions & 4 deletions T4TS.Build.Builder/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,23 @@
<#@ import namespace="EnvDTE" #>
<#@ import namespace="Microsoft.VisualStudio.Shell.Interop" #>
<#@ import namespace="Microsoft.VisualStudio.TextTemplating" #>
<#@ import namespace="System.IO" #>
<#@ Include File="T4TS.tt.settings.t4" #><#=
OutputFormatter.GetOutput(GetDataToRender(), GetSettings()) #><#+
ProduceOutput()
#><#+

string ProduceOutput()
{
var settings = GetSettings();
var output = OutputFormatter.GetOutput(GetDataToRender(), settings);

if (!string.IsNullOrWhiteSpace(settings.OutputFile))
{
File.WriteAllText(Path.Combine(Path.GetDirectoryName(this.Host.TemplateFile), settings.OutputFile), output);
}

return output;
}

Settings settings = null;
Settings GetSettings()
Expand Down Expand Up @@ -178,8 +193,7 @@ Project GetProjectContainingT4File(DTE dte) {
projectItem.Document.Saved = false;

return projectItem.ContainingProject;
}
</value>
}</value>
<comment>The text to place in the beginning of T4TS.tt, before all code definitions.</comment>
</data>
<data name="TemplateSettings" xml:space="preserve">
Expand Down Expand Up @@ -222,7 +236,12 @@ readonly Dictionary&lt;string, object&gt; SettingsValues = new Dictionary&lt;str

// The default value for DateTime type translation.
// Type: bool?, defaults to false if not specified.
{ "UseNativeDates", null }
{ "UseNativeDates", null },


// If specified the relative path to an extra output file that doesn't need to be in your project
// Type: string, defaults to "" if not specified
{ "OutputFile", "" }
};
#&gt;</value>
<comment>The contents of the generated template settings file T4TS.tt.settings.t4</comment>
Expand Down
8 changes: 7 additions & 1 deletion T4TS/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class Settings
/// </summary>
public bool UseNativeDates { get; set; }

/// <summary>
/// Allows to produce an extra output in the desired location relative to the project folder
/// </summary>
public string OutputFile { get; set; }

public static Settings Parse(Dictionary<string,object> settingsValues)
{
// Read settings from T4TS.tt.settings.tt
Expand All @@ -48,7 +53,8 @@ public static Settings Parse(Dictionary<string,object> settingsValues)
DefaultCamelCaseMemberNames = ParseSettingNullableType(settingsValues, "DefaultCamelCaseMemberNames", false),
DefaultInterfaceNamePrefix = ParseSettingReferenceType(settingsValues, "DefaultInterfaceNamePrefix", s => s as string, string.Empty),
CompatibilityVersion = ParseSettingReferenceType(settingsValues, "CompatibilityVersion", v => v as Version, new Version(0, 9, 1, 1)),
UseNativeDates = ParseSettingNullableType(settingsValues, "UseNativeDates", false)
UseNativeDates = ParseSettingNullableType(settingsValues, "UseNativeDates", false),
OutputFile = ParseSettingReferenceType(settingsValues, "OutputFile", s => s as string, string.Empty)
};
}

Expand Down
Binary file modified build/T4TS.Attributes.dll
Binary file not shown.
Loading