Browse Source

Merge remote-tracking branch 'remotes/sd/master'

pull/662/head
jkuehner 10 years ago
parent
commit
14a83e6917
  1. 78
      src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs
  2. 14
      src/AddIns/Misc/PackageManagement/Project/Src/PackageSourceConverter.cs
  3. 4
      src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs
  4. BIN
      src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Console.Types.dll
  5. BIN
      src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Core.dll
  6. BIN
      src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.exe
  7. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs
  8. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoPanel.xaml
  9. 21
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoProvider.cs
  10. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoViewModel.cs
  11. 8
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/VersionEditor.xaml
  12. 186
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/VersionEditor.xaml.cs
  13. 53
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs
  14. 24
      src/Main/Base/Test/ProjectOptions/AssemblyInfoProviderTests.cs

78
src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs

@ -26,18 +26,18 @@ namespace ICSharpCode.PackageManagement.Design @@ -26,18 +26,18 @@ namespace ICSharpCode.PackageManagement.Design
{
public class FakeSettings : ISettings
{
public List<KeyValuePair<string, string>> PackageSources
= new List<KeyValuePair<string, string>>();
public List<SettingValue> PackageSources
= new List<SettingValue> ();
public List<KeyValuePair<string, string>> DisabledPackageSources
= new List<KeyValuePair<string, string>>();
public List<SettingValue> DisabledPackageSources
= new List<SettingValue> ();
public List<KeyValuePair<string, string>> ActivePackageSourceSettings =
new List<KeyValuePair<string, string>>();
public List<SettingValue> ActivePackageSourceSettings =
new List<SettingValue> ();
public Dictionary<string, IList<SettingValue>> Sections
= new Dictionary<string, IList<SettingValue>> ();
public Dictionary<string, IList<KeyValuePair<string, string>>> Sections
= new Dictionary<string, IList<KeyValuePair<string, string>>>();
public const string ConfigSectionName = "config";
public FakeSettings()
@ -47,29 +47,24 @@ namespace ICSharpCode.PackageManagement.Design @@ -47,29 +47,24 @@ namespace ICSharpCode.PackageManagement.Design
Sections.Add(RegisteredPackageSourceSettings.DisabledPackageSourceSectionName, DisabledPackageSources);
}
public string GetValue(string section, string key)
public string GetValue(string section, string key, bool isPath)
{
if (!Sections.ContainsKey(section))
return null;
IList<KeyValuePair<string, string>> values = Sections[section];
foreach (KeyValuePair<string, string> keyPair in values) {
if (keyPair.Key == key) {
return keyPair.Value;
}
if (Sections.ContainsKey(section)) {
var matchedSection = Sections[section];
return matchedSection.FirstOrDefault(item => item.Key == key).Value;
}
return null;
}
public IList<KeyValuePair<string, string>> GetValues(string section)
public IList<SettingValue> GetValues(string section, bool isPath)
{
return Sections[section];
}
public void AddFakePackageSource(PackageSource packageSource)
{
var valuePair = new KeyValuePair<string, string>(packageSource.Name, packageSource.Source);
PackageSources.Add(valuePair);
var setting = new SettingValue (packageSource.Name, packageSource.Source, false);
PackageSources.Add(setting);
}
public Dictionary<string, KeyValuePair<string, string>> SavedSectionValues =
@ -134,8 +129,8 @@ namespace ICSharpCode.PackageManagement.Design @@ -134,8 +129,8 @@ namespace ICSharpCode.PackageManagement.Design
public void SetFakeActivePackageSource(PackageSource packageSource)
{
ActivePackageSourceSettings.Clear();
var valuePair = new KeyValuePair<string, string>(packageSource.Name, packageSource.Source);
ActivePackageSourceSettings.Add(valuePair);
var setting = new SettingValue(packageSource.Name, packageSource.Source, false);
ActivePackageSourceSettings.Add(setting);
}
public void MakeActivePackageSourceSectionNull()
@ -157,9 +152,9 @@ namespace ICSharpCode.PackageManagement.Design @@ -157,9 +152,9 @@ namespace ICSharpCode.PackageManagement.Design
}
}
public IList<KeyValuePair<string, string>> GetNestedValues(string section, string key)
public IList<SettingValue> GetNestedValues(string section, string key)
{
return new List<KeyValuePair<string, string>>();
return new List<SettingValue>();
}
public virtual void SetNestedValues(string section, string key, IList<KeyValuePair<string, string>> values)
@ -169,8 +164,8 @@ namespace ICSharpCode.PackageManagement.Design @@ -169,8 +164,8 @@ namespace ICSharpCode.PackageManagement.Design
public void AddDisabledPackageSource(PackageSource packageSource)
{
var valuePair = new KeyValuePair<string, string>(packageSource.Name, packageSource.Source);
DisabledPackageSources.Add(valuePair);
var setting = new SettingValue(packageSource.Name, packageSource.Source, false);
DisabledPackageSources.Add(setting);
}
public IList<KeyValuePair<string, string>> GetValuesPassedToSetValuesForDisabledPackageSourcesSection()
@ -186,8 +181,8 @@ namespace ICSharpCode.PackageManagement.Design @@ -186,8 +181,8 @@ namespace ICSharpCode.PackageManagement.Design
public virtual void SetPackageRestoreSetting(bool enabled)
{
var items = new List<KeyValuePair<string, string>>();
items.Add(new KeyValuePair<string, string>("enabled", enabled.ToString()));
var items = new List<SettingValue> ();
items.Add(new SettingValue("enabled", enabled.ToString(), false));
Sections.Add("packageRestore", items);
}
@ -202,31 +197,10 @@ namespace ICSharpCode.PackageManagement.Design @@ -202,31 +197,10 @@ namespace ICSharpCode.PackageManagement.Design
}
}
public string GetValue(string section, string key, bool isPath)
{
if (Sections.ContainsKey(section)) {
var matchedSection = Sections[section];
return matchedSection.FirstOrDefault(item => item.Key == key).Value;
}
return null;
}
public IList<KeyValuePair<string, string>> GetValues(string section, bool isPath)
{
throw new NotImplementedException();
}
public IList<SettingValue> GetSettingValues(string section, bool isPath)
{
return Sections[section]
.Select(item => new SettingValue(item.Key, item.Value, false))
.ToList();
}
public void SetRepositoryPathSetting(string fullPath)
{
var items = new List<KeyValuePair<string, string>> ();
items.Add (new KeyValuePair<string, string>("repositoryPath", fullPath));
var items = new List<SettingValue>();
items.Add (new SettingValue("repositoryPath", fullPath, false));
Sections.Add(ConfigSectionName, items);
}
}

14
src/AddIns/Misc/PackageManagement/Project/Src/PackageSourceConverter.cs

@ -25,16 +25,16 @@ namespace ICSharpCode.PackageManagement @@ -25,16 +25,16 @@ namespace ICSharpCode.PackageManagement
{
public static class PackageSourceConverter
{
public static IEnumerable<PackageSource> ConvertFromKeyValuePairs(IEnumerable<KeyValuePair<string, string>> packageSources)
public static IEnumerable<PackageSource> ConvertFromSettings(IEnumerable<SettingValue> packageSources)
{
if (HasAny(packageSources)) {
foreach (KeyValuePair<string, string> packageSource in packageSources) {
yield return CreatePackageSourceFromKeyValuePair(packageSource);
foreach (SettingValue packageSource in packageSources) {
yield return CreatePackageSourceFromSetting(packageSource);
}
}
}
static bool HasAny(IEnumerable<KeyValuePair<string, string>> packageSources)
static bool HasAny(IEnumerable<SettingValue> packageSources)
{
if (packageSources != null) {
return packageSources.Any();
@ -42,17 +42,17 @@ namespace ICSharpCode.PackageManagement @@ -42,17 +42,17 @@ namespace ICSharpCode.PackageManagement
return false;
}
static PackageSource CreatePackageSourceFromKeyValuePair(KeyValuePair<string, string> savedPackageSource)
static PackageSource CreatePackageSourceFromSetting(SettingValue savedPackageSource)
{
string source = savedPackageSource.Value;
string name = savedPackageSource.Key;
return new PackageSource(source, name);
}
public static PackageSource ConvertFromFirstKeyValuePair(IEnumerable<KeyValuePair<string, string>> packageSources)
public static PackageSource ConvertFromFirstSetting(IEnumerable<SettingValue> packageSources)
{
if (HasAny(packageSources)) {
return CreatePackageSourceFromKeyValuePair(packageSources.First());
return CreatePackageSourceFromSetting(packageSources.First());
}
return null;
}

4
src/AddIns/Misc/PackageManagement/Project/Src/RegisteredPackageSourceSettings.cs

@ -76,8 +76,8 @@ namespace ICSharpCode.PackageManagement @@ -76,8 +76,8 @@ namespace ICSharpCode.PackageManagement
void ReadActivePackageSource()
{
IList<KeyValuePair<string, string>> packageSources = settings.GetValues(ActivePackageSourceSectionName);
activePackageSource = PackageSourceConverter.ConvertFromFirstKeyValuePair(packageSources);
IList<SettingValue> packageSources = settings.GetValues(ActivePackageSourceSectionName, false);
activePackageSource = PackageSourceConverter.ConvertFromFirstSetting(packageSources);
}
public RegisteredPackageSources PackageSources {

BIN
src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Console.Types.dll

Binary file not shown.

BIN
src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.Core.dll

Binary file not shown.

BIN
src/AddIns/Misc/PackageManagement/RequiredLibraries/NuGet.exe

Binary file not shown.

4
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs

@ -39,9 +39,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -39,9 +39,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
public string DefaultAlias { get; set; }
public Version AssemblyVersion { get; set; }
public string AssemblyVersion { get; set; }
public Version AssemblyFileVersion { get; set; }
public string AssemblyFileVersion { get; set; }
public string InformationalVersion { get; set; }

4
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoPanel.xaml

@ -88,10 +88,10 @@ @@ -88,10 +88,10 @@
<TextBox Text="{Binding DefaultAlias, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="6"/>
<Label Content="{core:Localize Dialog.ProjectOptions.AssemblyInfo.AssemblyVersion}" Grid.Column="0" Grid.Row="7"/>
<projectOptions:VersionEditor Version="{Binding AssemblyVersion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="7"/>
<projectOptions:VersionEditor Version="{Binding AssemblyVersion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Type="Assembly" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="7"/>
<Label Content="{core:Localize Dialog.ProjectOptions.AssemblyInfo.FileVersion}" Grid.Column="0" Grid.Row="8"/>
<projectOptions:VersionEditor Version="{Binding AssemblyFileVersion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="8"/>
<projectOptions:VersionEditor Version="{Binding AssemblyFileVersion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Type="File" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="8"/>
<Label Content="{core:Localize Dialog.ProjectOptions.AssemblyInfo.InformationalVersion}" Grid.Column="0" Grid.Row="9"/>
<TextBox Text="{Binding InformationalVersion, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="9"/>

21
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoProvider.cs

@ -122,11 +122,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -122,11 +122,11 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
break;
case AssemblyVersion:
case AssemblyVersion + Attribute:
assemblyInfo.AssemblyVersion = GetAttributeValueAsVersion(attribute);
assemblyInfo.AssemblyVersion = GetAttributeValue<string>(attribute);
break;
case AssemblyFileVersion:
case AssemblyFileVersion + Attribute:
assemblyInfo.AssemblyFileVersion = GetAttributeValueAsVersion(attribute);
assemblyInfo.AssemblyFileVersion = GetAttributeValue<string>(attribute);
break;
case AssemblyInformationalVersion:
case AssemblyInformationalVersion + Attribute:
@ -268,23 +268,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -268,23 +268,6 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
return null;
}
private Version GetAttributeValueAsVersion(Attribute attribute)
{
var attributeArguments = attribute.Arguments.OfType<PrimitiveExpression>().ToArray();
if (attributeArguments.Length == 1)
{
var versionString = attributeArguments[0].Value as string;
if (!string.IsNullOrEmpty(versionString))
{
Version version;
if (Version.TryParse(versionString, out version))
return version;
}
}
return null;
}
private AssemblyNameFlags GetAssemblyFlagsFromAttribute(Attribute attribute)
{
if (attribute.Arguments.Count == 1)

4
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfoViewModel.cs

@ -92,13 +92,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -92,13 +92,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
set { assemblyInfo.DefaultAlias = value; OnPropertyChanged(); }
}
public Version AssemblyVersion
public string AssemblyVersion
{
get { return assemblyInfo.AssemblyVersion; }
set { assemblyInfo.AssemblyVersion = value; OnPropertyChanged(); }
}
public Version AssemblyFileVersion
public string AssemblyFileVersion
{
get { return assemblyInfo.AssemblyFileVersion; }
set { assemblyInfo.AssemblyFileVersion = value; OnPropertyChanged(); }

8
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/VersionEditor.xaml

@ -11,9 +11,9 @@ @@ -11,9 +11,9 @@
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Name="majorTextBox" Grid.Column="0" PreviewTextInput="OnTextBoxPreviewTextInput" TextChanged="OnTextChanged"/>
<TextBox Name="minorTextBox" Grid.Column="1" PreviewTextInput="OnTextBoxPreviewTextInput" TextChanged="OnTextChanged"/>
<TextBox Name="buildTextBox" Grid.Column="2" PreviewTextInput="OnTextBoxPreviewTextInput" TextChanged="OnTextChanged"/>
<TextBox Name="revisionTextBox" Grid.Column="3" PreviewTextInput="OnTextBoxPreviewTextInput" TextChanged="OnTextChanged"/>
<TextBox Name="majorTextBox" Grid.Column="0" TextChanged="OnTextChanged"/>
<TextBox Name="minorTextBox" Grid.Column="1" TextChanged="OnTextChanged"/>
<TextBox Name="buildTextBox" Grid.Column="2" TextChanged="OnTextChanged"/>
<TextBox Name="revisionTextBox" Grid.Column="3" TextChanged="OnTextChanged"/>
</Grid>
</UserControl>

186
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/VersionEditor.xaml.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
@ -30,26 +31,129 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.ProjectOptions @@ -30,26 +31,129 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.ProjectOptions
public partial class VersionEditor
{
public static DependencyProperty VersionProperty =
DependencyProperty.Register("Version", typeof(Version), typeof(VersionEditor), new PropertyMetadata(OnVersionChanged));
DependencyProperty.Register("Version", typeof(string), typeof(VersionEditor), new PropertyMetadata(OnVersionChanged));
public static DependencyProperty TypeProperty =
DependencyProperty.Register("Type", typeof(VersionType), typeof(VersionEditor));
public VersionEditor()
{
InitializeComponent();
}
public Version Version
public string Version
{
get { return GetValue(VersionProperty) as Version; }
get { return GetValue(VersionProperty) as string; }
set { SetValue(VersionProperty, value); }
}
private void OnTextBoxPreviewTextInput(object sender, TextCompositionEventArgs e)
public VersionType Type
{
// Block any non-character input
if (!e.Text.All(char.IsDigit))
get { return (VersionType)GetValue(TypeProperty); }
set { SetValue(TypeProperty, value); }
}
public enum VersionType
{
Assembly,
File,
Info,
}
enum AllowedType
{
Integer,
Star,
Empty,
String,
}
static readonly AllowedType[][] assemblyVersionTypes =
{
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Integer, AllowedType.Integer },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Integer, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Integer, AllowedType.Star },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Empty, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Star, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Empty, AllowedType.Empty, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Star, AllowedType.Empty, AllowedType.Empty },
};
static readonly AllowedType[][] fileVersionTypes =
{
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Integer, AllowedType.Integer },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Integer, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Integer, AllowedType.Empty, AllowedType.Empty },
new [] { AllowedType.Integer, AllowedType.Empty, AllowedType.Empty, AllowedType.Empty },
};
static readonly AllowedType[][] infoVersionTypes =
{
new [] { AllowedType.String, AllowedType.String, AllowedType.String, AllowedType.String },
new [] { AllowedType.String, AllowedType.String, AllowedType.String, AllowedType.Empty },
new [] { AllowedType.String, AllowedType.String, AllowedType.Empty, AllowedType.Empty },
new [] { AllowedType.String, AllowedType.Empty, AllowedType.Empty, AllowedType.Empty },
};
static readonly int[] assemblyVersionRange = { 0, 65534 };
static readonly int[] fileVersionRange = { 0, 65535 };
AllowedType[] GetAllowedType(string[] parts)
{
AllowedType[][] types = GetAllowedTypes();
int[] range = GetAllowedRange();
bool allowed = false;
foreach (var element in types)
{
e.Handled = true;
allowed = true;
for (int i = 0; i < parts.Length; i++)
{
int t;
switch (element[i])
{
case AllowedType.Integer:
if (!int.TryParse(parts[i], out t))
allowed = false;
if (range != null && (t < range[0] || t > range[1]))
allowed = false;
break;
case AllowedType.Star:
if (parts[i] != "*")
allowed = false;
break;
case AllowedType.Empty:
if (!string.IsNullOrEmpty(parts[i]))
allowed = false;
break;
case AllowedType.String:
if (string.IsNullOrEmpty(parts[i]))
allowed = false;
break;
}
if (!allowed)
break;
}
if (allowed)
return element;
}
return null;
}
AllowedType[][] GetAllowedTypes()
{
if (this.Type == VersionType.Assembly)
return assemblyVersionTypes;
if (this.Type == VersionType.File)
return fileVersionTypes;
return infoVersionTypes;
}
int[] GetAllowedRange()
{
if (this.Type == VersionType.Assembly)
return assemblyVersionRange;
if (this.Type == VersionType.File)
return fileVersionRange;
return null;
}
private void OnTextChanged(object sender, TextChangedEventArgs e)
@ -60,39 +164,67 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.ProjectOptions @@ -60,39 +164,67 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.OptionPanels.ProjectOptions
string buildPart = buildTextBox.Text;
string revisionPart = revisionTextBox.Text;
int majorVersion = 0, minorVersion = 0, build = 0, revision = 0;
var majorVersionWasSet = !string.IsNullOrEmpty(majorPart) && int.TryParse(majorPart, out majorVersion);
var minorVersionWasSet = !string.IsNullOrEmpty(minorPart) && int.TryParse(minorPart, out minorVersion);
var buildWasSet = !string.IsNullOrEmpty(buildPart) && int.TryParse(buildPart, out build);
var revisionWasSet = !string.IsNullOrEmpty(revisionPart) && int.TryParse(revisionPart, out revision);
AllowedType[] type = GetAllowedType(new string[] { majorPart, minorPart, buildPart, revisionPart });
if (type == null)
type = GetAllowedType(new string[] { majorPart, minorPart, buildPart, "" });
if (type == null)
type = GetAllowedType(new string[] { majorPart, minorPart, "", "" });
if (type == null)
type = GetAllowedType(new string[] { majorPart, "", "", "" });
Version newVersion;
if (revisionWasSet)
newVersion = new Version(majorVersion, minorVersion, build, revision);
else if (buildWasSet)
newVersion = new Version(majorVersion, minorVersion, build);
else if (majorVersionWasSet || minorVersionWasSet)
newVersion = new Version(majorVersion, minorVersion);
string newVersion;
if (type != null)
{
if (type[3] != AllowedType.Empty)
newVersion = majorPart + "." + minorPart + "." + buildPart + "." + revisionPart;
else if (type[2] != AllowedType.Empty)
newVersion = majorPart + "." + minorPart + "." + buildPart;
else if (type[1] != AllowedType.Empty)
newVersion = majorPart + "." + minorPart;
else if (type[0] != AllowedType.Empty)
newVersion = majorPart;
else
newVersion = "";
}
else
newVersion = new Version();
newVersion = "";
if (!newVersion.Equals(Version))
Version = newVersion;
}
static string[] SplitNParts(string s, char c, int count)
{
var parts = new List<string>();
int pos = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] == c)
{
if (parts.Count + 1 == count)
break;
parts.Add(s.Substring(pos, i - pos));
pos = i + 1;
}
}
parts.Add(s.Substring(pos));
return parts.ToArray();
}
private static void OnVersionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var versionEditor = d as VersionEditor;
var newVersion = e.NewValue as Version;
var newVersion = e.NewValue as string;
if (versionEditor != null && newVersion != null)
{
var parts = SplitNParts(newVersion, '.', 4);
// Update textboxes values when version property changes
versionEditor.majorTextBox.Text = newVersion.Major >= 0 ? newVersion.Major.ToString() : string.Empty;
versionEditor.minorTextBox.Text = newVersion.Minor >= 0 ? newVersion.Minor.ToString() : string.Empty;
versionEditor.buildTextBox.Text = newVersion.Build >= 0 ? newVersion.Build.ToString() : string.Empty;
versionEditor.revisionTextBox.Text = newVersion.Revision >= 0 ? newVersion.Revision.ToString() : string.Empty;
versionEditor.majorTextBox.Text = parts.Length > 0 ? parts[0] : string.Empty;
versionEditor.minorTextBox.Text = parts.Length > 1 ? parts[1] : string.Empty;
versionEditor.buildTextBox.Text = parts.Length > 2 ? parts[2] : string.Empty;
versionEditor.revisionTextBox.Text = parts.Length > 3 ? parts[3] : string.Empty;
}
}
}

53
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ProjectReferencePanel.cs

@ -24,36 +24,45 @@ using ICSharpCode.SharpDevelop.Project; @@ -24,36 +24,45 @@ using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Gui
{
public class ProjectReferencePanel : ListView, IReferencePanel
public class ProjectReferencePanel : UserControl, IReferencePanel
{
ISelectReferenceDialog selectDialog;
TextBox filterTextBox;
ListView listView;
public ProjectReferencePanel(ISelectReferenceDialog selectDialog)
{
this.selectDialog = selectDialog;
listView = new ListView();
ColumnHeader nameHeader = new ColumnHeader();
nameHeader.Text = ResourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.NameHeader");
nameHeader.Text = ResourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.NameHeader");
nameHeader.Width = 170;
Columns.Add(nameHeader);
listView.Columns.Add(nameHeader);
ColumnHeader directoryHeader = new ColumnHeader();
directoryHeader.Text = ResourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.DirectoryHeader");
directoryHeader.Text = ResourceService.GetString("Dialog.SelectReferenceDialog.ProjectReferencePanel.DirectoryHeader");
directoryHeader.Width = 290;
Columns.Add(directoryHeader);
View = View.Details;
Dock = DockStyle.Fill;
FullRowSelect = true;
ItemActivate += delegate { AddReference(); };
listView.Columns.Add(directoryHeader);
listView.View = View.Details;
listView.Dock = DockStyle.Fill;
listView.FullRowSelect = true;
this.Dock = DockStyle.Fill;
this.Controls.Add(listView);
listView.ItemActivate += delegate {
AddReference();
};
PopulateListView();
Panel upperPanel = new Panel { Dock = DockStyle.Top, Height = 20 };
filterTextBox = new TextBox { Width = 150, Dock = DockStyle.Right };
filterTextBox.TextChanged += delegate { Search(); };
filterTextBox.TextChanged += delegate {
Search();
};
upperPanel.Controls.Add(filterTextBox);
@ -62,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -62,7 +71,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public void AddReference()
{
foreach (ListViewItem item in SelectedItems) {
foreach (ListViewItem item in listView.SelectedItems) {
IProject project = (IProject)item.Tag;
selectDialog.AddReference(
@ -82,17 +91,16 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -82,17 +91,16 @@ namespace ICSharpCode.SharpDevelop.Gui
foreach (IProject project in ProjectService.OpenSolution.Projects.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase)) {
ListViewItem newItem = new ListViewItem(new string[] { project.Name, project.Directory });
newItem.Tag = project;
Items.Add(newItem);
listView.Items.Add(newItem);
}
}
static bool ContainsAnyOfTokens(string bigText, string[] tokens)
{
if(tokens.Length==0)
if (tokens.Length == 0)
return true;
foreach(var token in tokens)
{
if(bigText.IndexOf(token, StringComparison.OrdinalIgnoreCase)<0)
foreach (var token in tokens) {
if (bigText.IndexOf(token, StringComparison.OrdinalIgnoreCase) < 0)
return false;
}
return true;
@ -100,16 +108,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -100,16 +108,15 @@ namespace ICSharpCode.SharpDevelop.Gui
void Search()
{
Items.Clear();
var tokens = filterTextBox.Text.Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries);
listView.Items.Clear();
var tokens = filterTextBox.Text.Split(new []{ ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach (IProject project in ProjectService.OpenSolution.Projects.
Where(pr=>ContainsAnyOfTokens(pr.Name, tokens))
.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase)
) {
.OrderBy(p => p.Name, StringComparer.OrdinalIgnoreCase)) {
ListViewItem newItem = new ListViewItem(new string[] { project.Name, project.Directory });
newItem.Tag = project;
Items.Add(newItem);
listView.Items.Add(newItem);
}
}
}

24
src/Main/Base/Test/ProjectOptions/AssemblyInfoProviderTests.cs

@ -101,8 +101,8 @@ using System.Runtime.InteropServices; @@ -101,8 +101,8 @@ using System.Runtime.InteropServices;
Assert.AreEqual("Copyright 2014", assemblyInfo.Copyright);
Assert.AreEqual("Trademark", assemblyInfo.Trademark);
Assert.AreEqual("Alias", assemblyInfo.DefaultAlias);
Assert.AreEqual(new Version(1, 2, 3, 1), assemblyInfo.AssemblyVersion);
Assert.AreEqual(new Version(1, 2, 3, 2), assemblyInfo.AssemblyFileVersion);
Assert.AreEqual(new Version(1, 2, 3, 1).ToString(), assemblyInfo.AssemblyVersion);
Assert.AreEqual(new Version(1, 2, 3, 2).ToString(), assemblyInfo.AssemblyFileVersion);
Assert.AreEqual(new Version(1, 2, 3, 3).ToString(), assemblyInfo.InformationalVersion);
Assert.AreEqual(new Guid("0c8c889f-ced2-4167-b155-2d48a99d8c72"), assemblyInfo.Guid);
Assert.AreEqual("ru-RU", assemblyInfo.NeutralLanguage);
@ -134,8 +134,8 @@ using System.Runtime.InteropServices; @@ -134,8 +134,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyInformationalVersion (""Incorrect version"")]";
var assemblyInfo = ReadAssemblyInfo(assemblyInfoFile);
Assert.IsNull(assemblyInfo.AssemblyVersion);
Assert.IsNull(assemblyInfo.AssemblyFileVersion);
Assert.AreEqual("Incorrect version", assemblyInfo.AssemblyVersion);
Assert.AreEqual("Incorrect version", assemblyInfo.AssemblyFileVersion);
Assert.AreEqual("Incorrect version", assemblyInfo.InformationalVersion);
}
@ -200,8 +200,8 @@ using System.Runtime.InteropServices; @@ -200,8 +200,8 @@ using System.Runtime.InteropServices;
Assert.AreEqual("", assemblyInfo.Copyright);
Assert.AreEqual("", assemblyInfo.Trademark);
Assert.AreEqual("", assemblyInfo.DefaultAlias);
Assert.IsNull(assemblyInfo.AssemblyVersion);
Assert.IsNull(assemblyInfo.AssemblyFileVersion);
Assert.AreEqual("", assemblyInfo.AssemblyVersion);
Assert.AreEqual("", assemblyInfo.AssemblyFileVersion);
Assert.AreEqual("", assemblyInfo.InformationalVersion);
Assert.IsNull(assemblyInfo.Guid);
Assert.AreEqual("", assemblyInfo.NeutralLanguage);
@ -289,8 +289,8 @@ using System.Runtime.InteropServices; @@ -289,8 +289,8 @@ using System.Runtime.InteropServices;
Assert.AreEqual("Copyright 2014", assemblyInfo.Copyright);
Assert.AreEqual("Trademark", assemblyInfo.Trademark);
Assert.AreEqual("Alias", assemblyInfo.DefaultAlias);
Assert.AreEqual(new Version(1, 2, 3, 1), assemblyInfo.AssemblyVersion);
Assert.AreEqual(new Version(1, 2, 3, 2), assemblyInfo.AssemblyFileVersion);
Assert.AreEqual(new Version(1, 2, 3, 1).ToString(), assemblyInfo.AssemblyVersion);
Assert.AreEqual(new Version(1, 2, 3, 2).ToString(), assemblyInfo.AssemblyFileVersion);
Assert.AreEqual(new Version(1, 2, 3, 3).ToString(), assemblyInfo.InformationalVersion);
Assert.AreEqual(new Guid("0c8c889f-ced2-4167-b155-2d48a99d8c72"), assemblyInfo.Guid);
Assert.AreEqual("ru-RU", assemblyInfo.NeutralLanguage);
@ -398,8 +398,8 @@ using System.Reflection; @@ -398,8 +398,8 @@ using System.Reflection;
Copyright = "Copyright 2014",
Trademark = "Trademark",
DefaultAlias = "Alias",
AssemblyVersion = new Version(1, 2, 3, 4),
AssemblyFileVersion = new Version(1, 2, 3, 4),
AssemblyVersion = new Version(1, 2, 3, 4).ToString(),
AssemblyFileVersion = new Version(1, 2, 3, 4).ToString(),
InformationalVersion = new Version(1, 2, 3, 4).ToString(),
Guid = new Guid("0c8c889f-ced2-4167-b155-2d48a99d8c72"),
NeutralLanguage = "ru-RU",
@ -449,8 +449,8 @@ using System.Runtime.InteropServices; @@ -449,8 +449,8 @@ using System.Runtime.InteropServices;
Copyright = "Copyright 2014-changed",
Trademark = "Trademark-changed",
DefaultAlias = "Alias-changed",
AssemblyVersion = new Version(4, 3, 2, 1),
AssemblyFileVersion = new Version(4, 3, 2, 1),
AssemblyVersion = new Version(4, 3, 2, 1).ToString(),
AssemblyFileVersion = new Version(4, 3, 2, 1).ToString(),
InformationalVersion = new Version(4, 3, 2, 1).ToString(),
Guid = new Guid("dc8c889f-ced2-4167-b155-2d48a99d8c72"),
NeutralLanguage = "en-US",

Loading…
Cancel
Save