Cosmos property page.

This commit is contained in:
José Pedro 2018-04-03 19:55:11 +01:00
parent 18202a8654
commit 1df3dc19f5
No known key found for this signature in database
GPG key ID: B8247B9301707B83
3 changed files with 152 additions and 100 deletions

View file

@ -38,6 +38,9 @@
<DebugEnabled Condition="'$(DebugEnabled)' == '' AND '$(Configuration)' == 'Debug'">True</DebugEnabled> <DebugEnabled Condition="'$(DebugEnabled)' == '' AND '$(Configuration)' == 'Debug'">True</DebugEnabled>
<DebugEnabled Condition="'$(DebugEnabled)' == ''">False</DebugEnabled> <DebugEnabled Condition="'$(DebugEnabled)' == ''">False</DebugEnabled>
<DebugCom Condition="'$(DebugCom)' == ''">1</DebugCom>
<DebugCom Condition="'$(DebugEnabled)' == 'False'">0</DebugCom>
<BinFormat Condition="'$(BinFormat)' == ''">ELF</BinFormat> <BinFormat Condition="'$(BinFormat)' == ''">ELF</BinFormat>
<DebugMode Condition="'$(DebugMode)' == ''">Source</DebugMode> <DebugMode Condition="'$(DebugMode)' == ''">Source</DebugMode>
<TraceMode Condition="'$(TraceMode)' == ''">User</TraceMode> <TraceMode Condition="'$(TraceMode)' == ''">User</TraceMode>
@ -142,7 +145,7 @@
StackCorruptionDetectionLevel="$(StackCorruptionDetectionLevel)" StackCorruptionDetectionLevel="$(StackCorruptionDetectionLevel)"
TraceAssemblies="$(TraceAssemblies)" TraceAssemblies="$(TraceAssemblies)"
IgnoreDebugStubAttribute="$(IgnoreDebugStubAttribute)" IgnoreDebugStubAttribute="$(IgnoreDebugStubAttribute)"
DebugCom="1" DebugCom="$(DebugCom)"
References="$(TargetPath);@(PlugsReference)" References="$(TargetPath);@(PlugsReference)"
AssemblySearchDirs="@(AssemblySearchDir)" AssemblySearchDirs="@(AssemblySearchDir)"
OutputFilename="$(Il2cpuOutput)" OutputFilename="$(Il2cpuOutput)"

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Microsoft.VisualStudio.ProjectSystem; using Microsoft.VisualStudio.ProjectSystem;
using VSPropertyPages; using VSPropertyPages;
@ -8,32 +9,17 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages.ViewModels
{ {
internal class CosmosPropertyPageViewModel : PropertyPageViewModel internal class CosmosPropertyPageViewModel : PropertyPageViewModel
{ {
public CosmosPropertyPageViewModel( #region Static Items
IPropertyManager propertyManager,
IProjectThreadingService projectThreadingService)
: base(propertyManager, projectThreadingService)
{
}
public bool DebugEnabled private static readonly List<int> DebugComItemsList = new List<int>() { 1, 2, 3, 4 };
{
get => String.Equals(GetProperty(nameof(DebugEnabled)), "True", StringComparison.OrdinalIgnoreCase);
set => SetProperty(nameof(DebugEnabled), value.ToString(), nameof(DebugEnabled));
}
public Dictionary<string, string> DebugModeItems { get; } = new Dictionary<string, string>() private static readonly Dictionary<string, string> DebugModeItemsDictionary = new Dictionary<string, string>()
{ {
["IL"] = "IL", ["IL"] = "IL",
["Source"] = "Source" ["Source"] = "Source"
}; };
public string DebugMode private static readonly Dictionary<string, string> TraceModeItemsDictionary = new Dictionary<string, string>()
{
get => GetProperty(nameof(DebugMode));
set => SetProperty(nameof(DebugMode), value);
}
public Dictionary<string, string> TraceModeItems { get; } = new Dictionary<string, string>()
{ {
["None"] = "None", ["None"] = "None",
["User"] = "User", ["User"] = "User",
@ -41,23 +27,57 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages.ViewModels
["All"] = "All" ["All"] = "All"
}; };
private static readonly Dictionary<string, string> StackCorruptionDetectionLevelItemsDictionary = new Dictionary<string, string>()
{
["AllInstructions"] = "All Instructions",
["MethodFooters"] = "Method Footers"
};
#endregion
public bool DebugEnabled
{
get => String.Equals(GetProperty(nameof(DebugEnabled)), "True", StringComparison.OrdinalIgnoreCase);
set => SetProperty(nameof(DebugEnabled), value.ToString(), nameof(DebugEnabled));
}
public List<int> DebugComItems => DebugComItemsList;
public int DebugCom
{
get => Int32.Parse(GetProperty(nameof(DebugCom)));
set => SetProperty(nameof(DebugCom), value.ToString());
}
public Dictionary<string, string> DebugModeItems => DebugModeItemsDictionary;
public string DebugMode
{
get => GetProperty(nameof(DebugMode));
set => SetProperty(nameof(DebugMode), value);
}
public Dictionary<string, string> TraceModeItems => TraceModeItemsDictionary;
public string TraceMode public string TraceMode
{ {
get => GetProperty(nameof(TraceMode)); get => GetProperty(nameof(TraceMode));
set => SetProperty(nameof(TraceMode), value); set => SetProperty(nameof(TraceMode), value);
} }
public bool IgnoreDebugStubAttribute
{
get => String.Equals(GetProperty(nameof(IgnoreDebugStubAttribute)), "True", StringComparison.OrdinalIgnoreCase);
set => SetProperty(nameof(IgnoreDebugStubAttribute), value.ToString(), nameof(IgnoreDebugStubAttribute));
}
public bool StackCorruptionDetectionEnabled public bool StackCorruptionDetectionEnabled
{ {
get => String.Equals(GetProperty(nameof(StackCorruptionDetectionEnabled)), "True", StringComparison.OrdinalIgnoreCase); get => String.Equals(GetProperty(nameof(StackCorruptionDetectionEnabled)), "True", StringComparison.OrdinalIgnoreCase);
set => SetProperty(nameof(StackCorruptionDetectionEnabled), value.ToString(), nameof(StackCorruptionDetectionEnabled)); set => SetProperty(nameof(StackCorruptionDetectionEnabled), value.ToString(), nameof(StackCorruptionDetectionEnabled));
} }
public Dictionary<string, string> StackCorruptionDetectionLevelItems { get; } = new Dictionary<string, string>() public Dictionary<string, string> StackCorruptionDetectionLevelItems => StackCorruptionDetectionLevelItemsDictionary;
{
["AllInstructions"] = "All Instructions",
["MethodFooters"] = "Method Footers"
};
public string StackCorruptionDetectionLevel public string StackCorruptionDetectionLevel
{ {
@ -77,10 +97,20 @@ namespace Cosmos.VS.ProjectSystem.VS.PropertyPages.ViewModels
set => SetProperty(nameof(VisualStudioDebugPort), value); set => SetProperty(nameof(VisualStudioDebugPort), value);
} }
public bool IgnoreDebugStubAttribute public CosmosPropertyPageViewModel(
IPropertyManager propertyManager,
IProjectThreadingService projectThreadingService)
: base(propertyManager, projectThreadingService)
{ {
get => String.Equals(GetProperty(nameof(IgnoreDebugStubAttribute)), "True", StringComparison.OrdinalIgnoreCase); }
set => SetProperty(nameof(IgnoreDebugStubAttribute), value.ToString(), nameof(IgnoreDebugStubAttribute));
private void SetAndRaiseIfChanged<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (!EqualityComparer<T>.Default.Equals(field, value))
{
field = value;
OnPropertyChanged(propertyName);
}
} }
} }
} }

View file

@ -17,90 +17,109 @@
Padding="12" Padding="12"
Header="IL2CPU"> Header="IL2CPU">
<Grid> <StackPanel>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="16" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="TextBox">
<Setter Property="Padding" Value="2" />
</Style>
</Grid.Resources>
<CheckBox Grid.Column="0" <CheckBox x:Name="checkBoxDebugEnabled"
Grid.Column="0"
Grid.Row="0" Grid.Row="0"
IsChecked="{Binding DebugEnabled}" IsChecked="{Binding DebugEnabled}"
Margin="0,0,0,12"
Content="Enable debug" /> Content="Enable debug" />
<StackPanel Grid.Column="0" <GroupBox Padding="12"
Grid.Row="1"> Header="Debug Settings"
<Label Margin="0,12,0,0" IsEnabled="{Binding ElementName=checkBoxDebugEnabled}">
Content="Debug mode:" />
<ComboBox Margin="0,8,0,0"
SelectedValuePath="Key"
DisplayMemberPath="Value"
ItemsSource="{Binding DebugModeItems}"
SelectedValue="{Binding DebugMode}" />
</StackPanel>
<StackPanel Grid.Column="0" <Grid>
Grid.Row="2"> <Grid.ColumnDefinitions>
<Label Margin="0,12,0,0" <ColumnDefinition Width="Auto" />
Content="Trace mode:" /> <ColumnDefinition Width="16" />
<ComboBox Margin="0,8,0,0" <ColumnDefinition Width="Auto" />
SelectedValuePath="Key" </Grid.ColumnDefinitions>
DisplayMemberPath="Value" <Grid.RowDefinitions>
ItemsSource="{Binding TraceModeItems}" <RowDefinition Height="Auto" />
SelectedValue="{Binding TraceMode}" /> <RowDefinition Height="Auto" />
</StackPanel> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.Resources>
<Style TargetType="TextBox">
<Setter Property="Padding" Value="2" />
</Style>
</Grid.Resources>
<StackPanel Grid.Column="0" <StackPanel Grid.Column="0"
Grid.Row="3"> Grid.Row="0">
<Label Margin="0,12,0,0" <Label Content="Debug COM port:" />
Content="Visual Studio debug port:" /> <ComboBox Margin="0,8,0,0"
<TextBox Margin="0,8,0,0" ItemsSource="{Binding DebugComItems}"
Text="{Binding VisualStudioDebugPort}" /> SelectedItem="{Binding DebugCom}" />
</StackPanel> </StackPanel>
<CheckBox Grid.Column="2" <StackPanel Grid.Column="0"
Grid.Row="0" Grid.Row="1">
Content="Enable stack corruption detection" <Label Margin="0,12,0,0"
IsChecked="{Binding StackCorruptionDetectionEnabled}" /> Content="Debug mode:" />
<ComboBox Margin="0,8,0,0"
SelectedValuePath="Key"
DisplayMemberPath="Value"
ItemsSource="{Binding DebugModeItems}"
SelectedValue="{Binding DebugMode}" />
</StackPanel>
<StackPanel Grid.Column="2" <StackPanel Grid.Column="0"
Grid.Row="1"> Grid.Row="2">
<Label Margin="0,12,0,0" <Label Margin="0,12,0,0"
Content="Stack corruption detection level:" /> Content="Trace mode:" />
<ComboBox Margin="0,8,0,0" <ComboBox Margin="0,8,0,0"
SelectedValuePath="Key" SelectedValuePath="Key"
DisplayMemberPath="Value" DisplayMemberPath="Value"
ItemsSource="{Binding StackCorruptionDetectionLevelItems}" ItemsSource="{Binding TraceModeItems}"
SelectedValue="{Binding StackCorruptionDetectionLevel}" /> SelectedValue="{Binding TraceMode}" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" <StackPanel Grid.Column="0"
Grid.Row="2"> Grid.Row="3">
<Label Margin="0,12,0,0" <Label Margin="0,12,0,0"
Content="Cosmos debug port:" /> Content="Visual Studio debug port:" />
<TextBox Margin="0,8,0,0" <TextBox Margin="0,8,0,0"
Text="{Binding CosmosDebugPort}" /> Text="{Binding VisualStudioDebugPort}" />
</StackPanel> </StackPanel>
<CheckBox Grid.Column="2" <StackPanel Grid.Column="2"
Grid.Row="3" Grid.Row="0">
Margin="0,18,0,0" <CheckBox Margin="0,4,0,0"
Content="Ignore debug stub attribute" Content="Ignore debug stub attribute"
IsChecked="{Binding IgnoreDebugStubAttribute}" /> IsChecked="{Binding IgnoreDebugStubAttribute}" />
<CheckBox Margin="0,18,0,0"
Content="Enable stack corruption detection"
IsChecked="{Binding StackCorruptionDetectionEnabled}" />
</StackPanel>
</Grid> <StackPanel Grid.Column="2"
Grid.Row="1">
<Label Margin="0,12,0,0"
Content="Stack corruption detection level:" />
<ComboBox Margin="0,8,0,0"
SelectedValuePath="Key"
DisplayMemberPath="Value"
ItemsSource="{Binding StackCorruptionDetectionLevelItems}"
SelectedValue="{Binding StackCorruptionDetectionLevel}" />
</StackPanel>
<StackPanel Grid.Column="2"
Grid.Row="2">
<Label Margin="0,12,0,0"
Content="Cosmos debug port:" />
<TextBox Margin="0,8,0,0"
Text="{Binding CosmosDebugPort}" />
</StackPanel>
</Grid>
</GroupBox>
</StackPanel>
</GroupBox> </GroupBox>