Browse Source

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

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

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

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

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

@ -7,10 +7,6 @@
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels" xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels"
xmlns:projects="clr-namespace:ICSharpCode.SharpDevelop.Project" xmlns:projects="clr-namespace:ICSharpCode.SharpDevelop.Project"
xmlns:core="http://icsharpcode.net/sharpdevelop/core"> xmlns:core="http://icsharpcode.net/sharpdevelop/core">
<optionpanels:ProjectOptionPanel.Resources>
<optionpanels:StringToBoolConverter
x:Key="strTobool"></optionpanels:StringToBoolConverter>
</optionpanels:ProjectOptionPanel.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto"> <ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel <StackPanel
Orientation="Vertical"> Orientation="Vertical">
@ -33,7 +29,7 @@
<CheckBox x:Name="signAssemblyCheckBox" <CheckBox x:Name="signAssemblyCheckBox"
Grid.Column="1" VerticalAlignment="Bottom" Grid.Column="1" VerticalAlignment="Bottom"
Content="{core:Localize Dialog.ProjectOptions.Signing.SignAssembly}" Content="{core:Localize Dialog.ProjectOptions.Signing.SignAssembly}"
IsChecked="{Binding SignAssembly.Value,Converter={StaticResource strTobool}}"> IsChecked="{Binding SignAssembly.Value}">
</CheckBox> </CheckBox>
<Label Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" <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
keyFileComboBox.SelectionChanged += KeyFileComboBox_SelectionChanged; keyFileComboBox.SelectionChanged += KeyFileComboBox_SelectionChanged;
} }
public ProjectProperty<String> SignAssembly { public ProjectProperty<bool> SignAssembly {
get { return GetProperty("SignAssembly","false", TextBoxEditMode.EditEvaluatedProperty); } get { return GetProperty("SignAssembly", false); }
} }

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

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

Loading…
Cancel
Save