Browse Source

Fixed MSBuildBasedProject.GetPropertyValue() for properties that are replaced by imported .targets files.

Use ProjectProperty<bool> where possible.
pull/30/head
Daniel Grunwald 13 years ago
parent
commit
8ff3f109b0
  1. 14
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml
  2. 70
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml.cs
  3. 6
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.xaml
  4. 4
      src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.xaml.cs
  5. 51
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

14
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml

@ -13,8 +13,6 @@ @@ -13,8 +13,6 @@
<optionpanels:ProjectOptionPanel.Resources>
<optionpanels:StorageLocationConverter
x:Key="converter" />
<optionpanels:StringToBoolConverter
x:Key="strTobool"></optionpanels:StringToBoolConverter>
</optionpanels:ProjectOptionPanel.Resources>
<ScrollViewer
@ -53,7 +51,7 @@ @@ -53,7 +51,7 @@
<!--x:Name="optimizeCodeCheckBox"-->
<CheckBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"
IsChecked="{Binding Optimize.Value,Converter={StaticResource strTobool}}"
IsChecked="{Binding Optimize.Value}"
Content="{core:Localize Dialog.ProjectOptions.BuildOptions.OptimizeCode}"></CheckBox>
<optionpanels:StorageLocationPicker Grid.Row="3" DockPanel.Dock="Left"
@ -61,21 +59,21 @@ @@ -61,21 +59,21 @@
<!--x:Name="allowUnsafeCodeCheckBox"-->
<CheckBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"
IsChecked="{Binding AllowUnsafeBlocks.Value,Converter={StaticResource strTobool}}"
IsChecked="{Binding AllowUnsafeBlocks.Value}"
Content="{core:Localize Dialog.ProjectOptions.BuildOptions.AllowUnsafeCode}"></CheckBox>
<optionpanels:StorageLocationPicker Grid.Row="4" DockPanel.Dock="Left" Location="{Binding CheckForOverflowUnderflow.Location}"/>
<!--x:Name="checkForOverflowCheckBox"-->
<CheckBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"
IsChecked="{Binding CheckForOverflowUnderflow.Value,Converter={StaticResource strTobool}}"
IsChecked="{Binding CheckForOverflowUnderflow.Value}"
Content="{core:Localize Dialog.ProjectOptions.BuildOptions.CheckForOverflow}"></CheckBox>
<optionpanels:StorageLocationPicker Grid.Row="5" DockPanel.Dock="Left" Location="{Binding NoStdLib.Location}"/>
<!--x:Name="noCorlibCheckBox"-->
<CheckBox Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
IsChecked="{Binding NoStdLib.Value,Converter={StaticResource strTobool}}"
IsChecked="{Binding NoStdLib.Value}"
Content="{core:Localize Dialog.ProjectOptions.BuildOptions.NoCorlib}"></CheckBox>
</Grid>
</GroupBox>
@ -188,7 +186,7 @@ @@ -188,7 +186,7 @@
<!--x:Name="registerCOMInteropCheckBox"-->
<CheckBox Grid.Column="2"
IsChecked="{Binding RegisterForComInterop.Value,Converter={StaticResource strTobool}}"
IsChecked="{Binding RegisterForComInterop.Value}"
Content="{core:Localize Dialog.ProjectOptions.Build.RegisterForCOM}"></CheckBox>
<Label Grid.Row="1" Grid.Column="1"
@ -289,7 +287,7 @@ @@ -289,7 +287,7 @@
<!--x:Name="warningLevelComboBox"-->
<ComboBox Grid.Column="2" Width="40" VerticalAlignment="Center" HorizontalAlignment="Left"
ItemsSource="{Binding Path=DataContext.WarnLevel}"
SelectedValue="{Binding Path=DataContext.SelectedWarningLevel}"
SelectedValue="{Binding Path=WarningLevel.Value}"
DisplayMemberPath="DisplayValue"
SelectedValuePath="Key"
SelectedIndex="4"></ComboBox>

70
src/AddIns/BackendBindings/CSharpBinding/Project/Src/OptionPanels/BuildOptions.xaml.cs

@ -94,23 +94,20 @@ namespace CSharpBinding.OptionPanels @@ -94,23 +94,20 @@ namespace CSharpBinding.OptionPanels
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.ConfigurationSpecific); }
}
public ProjectProperty<string> Optimize {
get {return GetProperty("Optimize", "",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.ConfigurationSpecific); }
public ProjectProperty<bool> Optimize {
get { return GetProperty("Optimize", false, PropertyStorageLocations.ConfigurationSpecific); }
}
public ProjectProperty<string> AllowUnsafeBlocks {
get {return GetProperty("AllowUnsafeBlocks", "", TextBoxEditMode.EditRawProperty); }
public ProjectProperty<bool> AllowUnsafeBlocks {
get { return GetProperty("AllowUnsafeBlocks", false); }
}
public ProjectProperty<string> CheckForOverflowUnderflow {
get {return GetProperty("CheckForOverflowUnderflow", "",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.ConfigurationSpecific); }
public ProjectProperty<bool> CheckForOverflowUnderflow {
get { return GetProperty("CheckForOverflowUnderflow", false, PropertyStorageLocations.ConfigurationSpecific); }
}
public ProjectProperty<string> NoStdLib {
get {return GetProperty("NoStdLib", "", TextBoxEditMode.EditRawProperty); }
public ProjectProperty<bool> NoStdLib {
get { return GetProperty("NoStdLib", false); }
}
@ -128,32 +125,29 @@ namespace CSharpBinding.OptionPanels @@ -128,32 +125,29 @@ namespace CSharpBinding.OptionPanels
}
// used in multibinding
public ProjectProperty<string> RegisterForComInterop {
get {return GetProperty("RegisterForComInterop","",
TextBoxEditMode.EditRawProperty, PropertyStorageLocations.PlatformSpecific ); }
public ProjectProperty<bool> RegisterForComInterop {
get {return GetProperty("RegisterForComInterop", false, PropertyStorageLocations.PlatformSpecific ); }
}
public ProjectProperty<string> GenerateSerializationAssemblies {
get {return GetProperty("GenerateSerializationAssemblies","Auto",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.PlatformSpecific ); }
TextBoxEditMode.EditEvaluatedProperty, PropertyStorageLocations.PlatformSpecific ); }
}
public ProjectProperty<string> PlatformTarget {
get {return GetProperty("PlatformTarget","AnyCPU",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.PlatformSpecific ); }
TextBoxEditMode.EditEvaluatedProperty, PropertyStorageLocations.PlatformSpecific ); }
}
public ProjectProperty<string> FileAlignment {
get {return GetProperty("FileAlignment","4096",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.PlatformSpecific ); }
TextBoxEditMode.EditEvaluatedProperty, PropertyStorageLocations.PlatformSpecific ); }
}
public ProjectProperty<string> BaseAddress {
get {return GetProperty("BaseAddress","0x400000",
TextBoxEditMode.EditRawProperty,PropertyStorageLocations.PlatformSpecific ); }
TextBoxEditMode.EditEvaluatedProperty,PropertyStorageLocations.PlatformSpecific ); }
}
@ -164,12 +158,12 @@ namespace CSharpBinding.OptionPanels @@ -164,12 +158,12 @@ namespace CSharpBinding.OptionPanels
public ProjectProperty<string> IntermediateOutputPath {
get {return GetProperty("IntermediateOutputPath",@"obj\",TextBoxEditMode.EditRawProperty ); }
get {return GetProperty("IntermediateOutputPath",@"obj\$(Configuration)\",TextBoxEditMode.EditRawProperty ); }
}
public ProjectProperty<string> WarningLevel {
get {return GetProperty("WarningLevel","4",TextBoxEditMode.EditRawProperty ); }
get {return GetProperty("WarningLevel","4",TextBoxEditMode.EditEvaluatedProperty ); }
}
@ -183,8 +177,8 @@ namespace CSharpBinding.OptionPanels @@ -183,8 +177,8 @@ namespace CSharpBinding.OptionPanels
}
public ProjectProperty<string> TreatWarningsAsErrors {
get {return GetProperty("TreatWarningsAsErrors","false",TextBoxEditMode.EditRawProperty ); }
public ProjectProperty<bool> TreatWarningsAsErrors {
get {return GetProperty("TreatWarningsAsErrors", false); }
}
@ -311,16 +305,6 @@ namespace CSharpBinding.OptionPanels @@ -311,16 +305,6 @@ namespace CSharpBinding.OptionPanels
}
}
public string SelectedFileAlign
{
get {return this.FileAlignment.Value;}
set {this.FileAlignment.Value = value;
base.RaisePropertyChanged(()=> SelectedFileAlign);
}
}
#endregion
#region BaseIntermediateOutputPath
@ -367,16 +351,6 @@ namespace CSharpBinding.OptionPanels @@ -367,16 +351,6 @@ namespace CSharpBinding.OptionPanels
base.RaisePropertyChanged(() => WarnLevel);
}
}
public string SelectedWarningLevel {
get {
return this.WarningLevel.Value; }
set {
WarningLevel.Value = value;
base.RaisePropertyChanged(() => SelectedWarningLevel);
}
}
#endregion
@ -384,9 +358,7 @@ namespace CSharpBinding.OptionPanels @@ -384,9 +358,7 @@ namespace CSharpBinding.OptionPanels
private void SetTreatWarningAsErrorRadioButtons()
{
bool result;
bool.TryParse(this.TreatWarningsAsErrors.Value,out result);
if (result) {
if (this.TreatWarningsAsErrors.Value) {
this.allRadioButton.IsChecked = true;
} else {
if (WarningsAsErrors.Value.Length > 0) {
@ -411,9 +383,9 @@ namespace CSharpBinding.OptionPanels @@ -411,9 +383,9 @@ namespace CSharpBinding.OptionPanels
}
if ((bool)this.allRadioButton.IsChecked) {
this.TreatWarningsAsErrors.Value = "true";
this.TreatWarningsAsErrors.Value = true;
} else {
this.TreatWarningsAsErrors.Value = "false";
this.TreatWarningsAsErrors.Value = false;
}
this.noneRadioButton.Checked -= ErrorButton_Checked;
this.allRadioButton.Checked -= ErrorButton_Checked;

6
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/Signing.xaml

@ -7,10 +7,6 @@ @@ -7,10 +7,6 @@
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"
xmlns:projects="clr-namespace:ICSharpCode.SharpDevelop.Project"
xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<optionpanels:ProjectOptionPanel.Resources>
<optionpanels:StringToBoolConverter
x:Key="strTobool"></optionpanels:StringToBoolConverter>
</optionpanels:ProjectOptionPanel.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel
Orientation="Vertical">
@ -33,7 +29,7 @@ @@ -33,7 +29,7 @@
<CheckBox x:Name="signAssemblyCheckBox"
Grid.Column="1" VerticalAlignment="Bottom"
Content="{core:Localize Dialog.ProjectOptions.Signing.SignAssembly}"
IsChecked="{Binding SignAssembly.Value,Converter={StaticResource strTobool}}">
IsChecked="{Binding SignAssembly.Value}">
</CheckBox>
<Label Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"

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

@ -54,8 +54,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels @@ -54,8 +54,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
keyFileComboBox.SelectionChanged += KeyFileComboBox_SelectionChanged;
}
public ProjectProperty<String> SignAssembly {
get { return GetProperty("SignAssembly","false", TextBoxEditMode.EditEvaluatedProperty); }
public ProjectProperty<bool> SignAssembly {
get { return GetProperty("SignAssembly", false); }
}

51
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -255,10 +255,17 @@ namespace ICSharpCode.SharpDevelop.Project @@ -255,10 +255,17 @@ namespace ICSharpCode.SharpDevelop.Project
out PropertyStorageLocations location)
{
using (var c = OpenConfiguration(configuration, platform)) {
var prop = c.GetNonImportedProperty(propertyName);
bool wasHiddenByImportedProperty;
var prop = c.GetNonImportedProperty(propertyName, out wasHiddenByImportedProperty);
if (prop != null) {
location = c.GetLocation(prop);
return prop.EvaluatedValue;
} else if (wasHiddenByImportedProperty) {
string unevaluated = GetAnyUnevaluatedPropertyValue(configuration, platform, propertyName, out location);
if (unevaluated != null) {
return c.Project.ExpandString(unevaluated);
}
return null;
} else {
location = PropertyStorageLocations.Unknown;
return null;
@ -306,10 +313,13 @@ namespace ICSharpCode.SharpDevelop.Project @@ -306,10 +313,13 @@ namespace ICSharpCode.SharpDevelop.Project
out PropertyStorageLocations location)
{
using (var c = OpenConfiguration(configuration, platform)) {
var prop = c.GetNonImportedProperty(propertyName);
bool wasHiddenByImportedProperty;
var prop = c.GetNonImportedProperty(propertyName, out wasHiddenByImportedProperty);
if (prop != null) {
location = c.GetLocation(prop);
return prop.UnevaluatedValue;
} else if (wasHiddenByImportedProperty) {
return GetAnyUnevaluatedPropertyValue(configuration, platform, propertyName, out location);
} else {
location = PropertyStorageLocations.Unknown;
return null;
@ -418,12 +428,15 @@ namespace ICSharpCode.SharpDevelop.Project @@ -418,12 +428,15 @@ namespace ICSharpCode.SharpDevelop.Project
this.unloadProjectOnDispose = unloadProjectOnDispose;
}
public MSBuild.ProjectProperty GetNonImportedProperty(string name)
public MSBuild.ProjectProperty GetNonImportedProperty(string name, out bool wasHiddenByImportedProperty)
{
wasHiddenByImportedProperty = false;
var prop = Project.GetProperty(name);
if (prop != null && prop.Xml != null) {
if (prop.Xml.ContainingProject == p.projectFile || prop.Xml.ContainingProject == p.userProjectFile)
return prop;
else
wasHiddenByImportedProperty = true;
}
return null;
}
@ -467,7 +480,8 @@ namespace ICSharpCode.SharpDevelop.Project @@ -467,7 +480,8 @@ namespace ICSharpCode.SharpDevelop.Project
out PropertyStorageLocations location)
{
using (var c = OpenConfiguration(configuration, platform)) {
var prop = c.GetNonImportedProperty(propertyName);
bool wasHiddenByImportedProperty;
var prop = c.GetNonImportedProperty(propertyName, out wasHiddenByImportedProperty);
if (prop != null) {
group = (ProjectPropertyGroupElement)prop.Xml.Parent;
location = c.GetLocation(prop);
@ -489,16 +503,26 @@ namespace ICSharpCode.SharpDevelop.Project @@ -489,16 +503,26 @@ namespace ICSharpCode.SharpDevelop.Project
/// Use <c>null</c> to allow properties from all platforms.</param>
/// <param name="propertyName">The name of the property</param>
string GetAnyUnevaluatedPropertyValue(string configuration, string platform, string propertyName)
{
PropertyStorageLocations tmp;
return GetAnyUnevaluatedPropertyValue(configuration, platform, propertyName, out tmp);
}
string GetAnyUnevaluatedPropertyValue(string configuration, string platform, string propertyName, out PropertyStorageLocations location)
{
// first try main project file, then try user project file
ProjectPropertyElement p = GetAnyUnevaluatedProperty(projectFile, configuration, platform, propertyName);
if (p == null)
p = GetAnyUnevaluatedProperty(userProjectFile, configuration, platform, propertyName);
ProjectPropertyElement p = GetAnyUnevaluatedProperty(projectFile, configuration, platform, propertyName, out location);
if (p == null) {
p = GetAnyUnevaluatedProperty(userProjectFile, configuration, platform, propertyName, out location);
if (p != null)
location |= PropertyStorageLocations.UserFile;
}
return p != null ? p.Value : null;
}
static ProjectPropertyElement GetAnyUnevaluatedProperty(ProjectRootElement project, string configuration, string platform, string propertyName)
static ProjectPropertyElement GetAnyUnevaluatedProperty(ProjectRootElement project, string configuration, string platform, string propertyName, out PropertyStorageLocations location)
{
location = PropertyStorageLocations.Unknown;
foreach (var g in project.PropertyGroups) {
var property = g.Properties.FirstOrDefault(p => MSBuildInternals.PropertyNameComparer.Equals(p.Name, propertyName));
if (property == null)
@ -510,6 +534,15 @@ namespace ICSharpCode.SharpDevelop.Project @@ -510,6 +534,15 @@ namespace ICSharpCode.SharpDevelop.Project
if ((configuration == null || configuration == gConfiguration || gConfiguration == null)
&& (platform == null || platform == gPlatform || gPlatform == null))
{
if (gConfiguration == null && gPlatform == null) {
location = PropertyStorageLocations.Base;
} else {
location = 0;
if (gConfiguration != null)
location |= PropertyStorageLocations.ConfigurationSpecific;
if (gPlatform != null)
location |= PropertyStorageLocations.PlatformSpecific;
};
return property;
}
}
@ -1625,6 +1658,6 @@ namespace ICSharpCode.SharpDevelop.Project @@ -1625,6 +1658,6 @@ namespace ICSharpCode.SharpDevelop.Project
}
return formattedText.ToString();
}
#endregion
#endregion
}
}

Loading…
Cancel
Save