Skip to content

Commit

Permalink
Merge pull request #1839 from cwensley/curtis/vswin-updates
Browse files Browse the repository at this point in the history
Fix templates for VS 16.8
  • Loading branch information
cwensley authored Dec 4, 2020
2 parents d166c8c + 38aafa4 commit a6a0e53
Show file tree
Hide file tree
Showing 70 changed files with 285 additions and 324 deletions.
25 changes: 12 additions & 13 deletions src/Addins/Eto.Addin.Shared/ProjectWizardPageModel.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ProjectWizardPageModel(IParameterSource source, XElement optionsElement)
if (SupportsBase)
Base = "Panel";
if (SupportsFramework)
SelectedFrameworks = new[] { SupportedFrameworks[0] };
SelectedFramework = SupportedFrameworks[0];
}

public bool IsValid
Expand All @@ -40,7 +40,7 @@ public bool IsValid
if (string.IsNullOrWhiteSpace(AppName) || AppNameInvalid)
return false;
}
if (SupportsFramework && !SelectedFrameworks.Any())
if (SupportsFramework && SelectedFramework == null)
return false;
return true;
}
Expand Down Expand Up @@ -231,21 +231,21 @@ public class FrameworkInfo

static readonly FrameworkInfo[] frameworkInformation =
{
new FrameworkInfo { Text = "Full .NET Framework", Value = "full", CanUseCombined = true },
new FrameworkInfo { Text = ".NET Core", Value = "core", CanUseCombined = false }
new FrameworkInfo { Text = ".NET 5", Value = "net5.0", CanUseCombined = false },
new FrameworkInfo { Text = ".NET Core 3.1", Value = "netcoreapp3.1", CanUseCombined = false },
new FrameworkInfo { Text = ".NET Framework 4.7.2 / Mono", Value = "net472", CanUseCombined = true },
};

List<FrameworkInfo> _selectedFrameworks;
FrameworkInfo _selectedFramework;

public IEnumerable<object> SelectedFrameworks
public FrameworkInfo SelectedFramework
{
get => _selectedFrameworks ?? Enumerable.Empty<FrameworkInfo>();
get => _selectedFramework;
set
{
_selectedFrameworks = (value?.OfType<FrameworkInfo>() ?? Enumerable.Empty<FrameworkInfo>()).ToList();
_selectedFramework = value;

string parameterValue = _selectedFrameworks.Count == 1 ? _selectedFrameworks[0].Value : "both";
Source.SetParameter("Framework", parameterValue);
Source.SetParameter("TargetFrameworkOverride", value.Value);

if (!AllowCombined)
Combined = false;
Expand All @@ -255,7 +255,7 @@ public IEnumerable<object> SelectedFrameworks
}
}

public bool AllowCombined => _selectedFrameworks?.All(r => r.CanUseCombined) == true;
public bool AllowCombined => _selectedFramework?.CanUseCombined == true;


struct TypeInfo
Expand Down Expand Up @@ -347,8 +347,7 @@ public string Information

if (SupportsFramework)
{
var frameworks = string.Join(" and ", _selectedFrameworks?.Select(r => r.Text) ?? Enumerable.Empty<string>());
text.Add($"For {frameworks} framework(s).");
text.Add($"For {SelectedFramework.Text}.");
}

return string.Join("\n\n", text);
Expand Down
16 changes: 12 additions & 4 deletions src/Addins/Eto.Addin.Shared/ProjectWizardPageView.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,21 @@ public ProjectWizardPageView(ProjectWizardPageModel model)

if (model.SupportsFramework)
{
var frameworkDropDown = new DropDown();
frameworkDropDown.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks);
frameworkDropDown.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text);
frameworkDropDown.ItemKeyBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value);
frameworkDropDown.SelectedValueBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFramework);

/*
var frameworkCheckBoxes = new CheckBoxList();
frameworkCheckBoxes.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks);
frameworkCheckBoxes.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text);
frameworkCheckBoxes.ItemKeyBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value);
frameworkCheckBoxes.SelectedValuesBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFrameworks);
*/

content.AddRow(HeadingLabel("Framework:"), frameworkCheckBoxes);
content.AddRow(HeadingLabel("Framework:"), frameworkDropDown);
}

if (model.SupportsProjectType)
Expand Down Expand Up @@ -179,9 +187,9 @@ public ProjectWizardPageView(ProjectWizardPageModel model)
}

#if DEBUG
var showColorsButton = new Button { Text = "Show all themed colors" };
showColorsButton.Click += (sender, e) => new ThemedColorsDialog().ShowModal(this);
content.AddRow(new Panel(), showColorsButton);
//var showColorsButton = new Button { Text = "Show all themed colors" };
//showColorsButton.Click += (sender, e) => new ThemedColorsDialog().ShowModal(this);
//content.AddRow(new Panel(), showColorsButton);
#endif

var informationLabel = new Label();
Expand Down
5 changes: 5 additions & 0 deletions src/Addins/Eto.Addin.VisualStudio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Eto.Serialization.Xaml", ".
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Eto.Forms.Templates", "Eto.Forms.Templates\Eto.Forms.Templates.csproj", "{F3B5405C-64C3-4EEE-B32E-C028F48DB745}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{F132CF00-BA1F-41E0-BFD9-0F691C47C5FE}"
ProjectSection(SolutionItems) = preProject
..\..\build\Common.props = ..\..\build\Common.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
90 changes: 13 additions & 77 deletions src/Addins/Eto.Addin.VisualStudio/Eto.Addin.VisualStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TargetFrameworkProfile />
<TargetVsixContainerName>Eto.Addin.VisualStudio-$(PackageVersion).vsix</TargetVsixContainerName>
<AutoGenerateBindingRedirects>True</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup>
<StartAction>Program</StartAction>
Expand Down Expand Up @@ -190,83 +191,13 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Reference Include="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
<Private>False</Private>
</Reference>
<Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.Build">
<EmbedInteropTypes>False</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Editor, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Language.Intellisense, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.OLE.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Framework, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.15.3.DesignTime, Version=15.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TemplateWizardInterface">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Data, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.Logic, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Text.UI.Wpf, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop, Version=7.1.40304.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Utilities, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ReachFramework" />
Expand All @@ -283,9 +214,6 @@
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="VSLangProj, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
Expand All @@ -301,11 +229,16 @@
</COMReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.3.1" />
<PackageReference Include="Portable.Xaml" Version="0.24.0" />
<PackageReference Include="FSharp.Core" Version="5.0.0" />
<PackageReference Include="Portable.Xaml" Version="0.26.0" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="3.6.0" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.202" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.4.1057" />
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.0.206" ExcludeAssets="runtime">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="16.8.3038">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Page Include="theme\WindowStyles.xaml">
Expand Down Expand Up @@ -336,6 +269,9 @@
</ItemGroup>
<Message Text="CopyLocal: %(ReferencePath.Identity), %(Filename)" Condition="%(ReferencePath.CopyLocal) == 'True'" Importance="high" />
</Target>
<Target Name="ClearTemplateCache" AfterTargets="AfterBuild">
<RemoveDir Directories="$(HOMEDRIVE)$(HOMEPATH)\.templateengine\vs" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
66 changes: 37 additions & 29 deletions src/Addins/Eto.Addin.VisualStudio/Intellisense/XamlCompletionSource.cs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Eto.Designer.Completion;
using Eto.Designer.Completion;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Operations;
Expand Down Expand Up @@ -53,41 +53,49 @@ ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint point, ICompletionSession s

public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
{
// read XML up to the cursor
var point = session.TextView.Caret.Position.BufferPosition;
var info = XmlParser.Read(buffer.CurrentSnapshot.GetText(0, point.Position));
if (info.Mode == CompletionMode.Class)
try
{
var prevPoint = point - 1;
var prevCh = prevPoint.GetChar();
if (prevCh != '<' && prevCh != '.')
// read XML up to the cursor
var point = session.TextView.Caret.Position.BufferPosition;
var info = XmlParser.Read(buffer.CurrentSnapshot.GetText(0, point.Position));
if (info.Mode == CompletionMode.Class)
{
session.Dismiss();
return;
var prevPoint = point - 1;
var prevCh = prevPoint.GetChar();
if (prevCh != '<' && prevCh != '.')
{
session.Dismiss();
return;
}
}
}
var nodes = info.Nodes;
var ns = nodes.SelectMany(r => r.Namespaces ?? Enumerable.Empty<CompletionNamespace>());
var path = nodes.Where(r => r.Mode == CompletionMode.Class).Select(r => r.Name).ToList();
var last = nodes.LastOrDefault();
var nodes = info.Nodes;
var ns = nodes.SelectMany(r => r.Namespaces ?? Enumerable.Empty<CompletionNamespace>());
var path = nodes.Where(r => r.Mode == CompletionMode.Class).Select(r => r.Name).ToList();
var last = nodes.LastOrDefault();

// get available completion items
var items = Designer.Completion.Completion.GetCompletionItems(ns, info.Mode, path, last);

// get available completion items
var items = Designer.Completion.Completion.GetCompletionItems(ns, info.Mode, path, last);
// translate to VS completions
var completionList = new List<mvli.Completion>();
foreach (var cls in items.OrderBy(r => r.Name))
{
completionList.Add(new mvli.Completion(cls.Name, cls.Name, cls.Description, GetGlyph(cls.Type), null));
}

// translate to VS completions
var completionList = new List<mvli.Completion>();
foreach (var cls in items.OrderBy(r => r.Name))
completionSets.Insert(0, new CompletionSet(
"eto",
"Eto",
FindTokenSpanAtPosition(session.GetTriggerPoint(buffer), session, info.Mode),
completionList,
null));
return;
}
catch (Exception ex)
{
completionList.Add(new mvli.Completion(cls.Name, cls.Name, cls.Description, GetGlyph(cls.Type), null));
Debug.WriteLine($"Error doing autocomplete: {ex}");
throw;
}

completionSets.Insert(0, new CompletionSet(
"Eto",
"Eto",
FindTokenSpanAtPosition(session.GetTriggerPoint(buffer), session, info.Mode),
completionList,
null));
return;
}

System.Windows.Media.ImageSource GetGlyph(CompletionType type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<LanguageTag>CSharp</LanguageTag>
<Icon>App.ico</Icon>
<DefaultName>EtoApp</DefaultName>
<RequiredFrameworkVersion>4.5</RequiredFrameworkVersion>

<CreateNewFolder>true</CreateNewFolder>
<ProvideDefaultName>true</ProvideDefaultName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<LanguageTag>FSharp</LanguageTag>
<Icon>App.ico</Icon>
<DefaultName>EtoApp</DefaultName>
<RequiredFrameworkVersion>4.5</RequiredFrameworkVersion>

<CreateNewFolder>false</CreateNewFolder>
<ProvideDefaultName>true</ProvideDefaultName>
Expand Down
15 changes: 12 additions & 3 deletions src/Addins/Eto.Addin.VisualStudio/Wizards/ProjectWizard.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public Version TargetFrameworkVersion
{
get
{
Version ver;
if (Version.TryParse(replacements["$targetframeworkversion$"], out ver))
return ver;
// Version ver;
// if (Version.TryParse(replacements["$targetframeworkversion$"], out ver))
// return ver;
return new Version(4, 5);
}
}
Expand Down Expand Up @@ -74,6 +74,15 @@ public override void RunStarted(object automationObject, Dictionary<string, stri
var dialog = new BaseDialog { Content = panel, Title = model.Title, ClientSize = new Size(-1, 400), Style="themed" };
if (!dialog.ShowModal(Helpers.MainWindow))
throw new WizardBackoutException();

// super hack: Due to a bug in VS we cannot use item templates without it crashing..
// see Microsoft.VisualStudio.TemplateEngine.Wizard.TemplateEngineWizard.PostInvocationTelemetry
// for details on why it doesn't work...
if (customParams[0] is string str && !str.Contains("~PC"))
{
str = str.Replace("~IC", "~PC");
customParams[0] = str;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Addins/Eto.Addin.VisualStudio/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
Expand Down
Loading

0 comments on commit a6a0e53

Please sign in to comment.