Skip to content

Commit

Permalink
Adjusted the way error messages are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
yt3trees committed Nov 18, 2023
1 parent 13881b9 commit 8ffc3b8
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 1 deletion.
90 changes: 90 additions & 0 deletions msbuild-gui/APISettings.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<Window
x:Class="msbuild_gui.APISettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:app="clr-namespace:msbuild_gui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:msbuild_gui"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="clr-namespace:msbuild_gui.Properties"
xmlns:sys="clr-namespace:System;assembly=netstandard"
xmlns:ui="http://schemas.modernwpf.com/2019"
Title="{Binding Resources.OpenAIAPISetting, Source={x:Static app:ResourceService.Current}, Mode=OneWay}"
Width="350"
Height="400"
ui:WindowHelper.UseModernWindowStyle="True"
Closing="Window_Closing"
KeyDown="Window_KeyDown"
ResizeMode="NoResize"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
WindowStyle="ToolWindow"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="5*" />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Margin="10,0,10,0">
<Label HorizontalAlignment="Left" Content="Provider" />
<ComboBox
x:Name="ProviderComboBox"
Width="120"
HorizontalAlignment="Left"
VerticalAlignment="Top"
SelectionChanged="ProviderComboBox_SelectionChanged">
<ComboBoxItem Content="OpenAI" />
<ComboBoxItem Content="Azure" />
</ComboBox>
<Label HorizontalAlignment="Left" Content="API Key" />
<PasswordBox
x:Name="APIKeyPasswordbox"
MinWidth="200"
VerticalAlignment="Top"
PasswordChar="*">
<PasswordBox.Background>
<SolidColorBrush Opacity="0.5" Color="{DynamicResource SystemChromeLowColor}" />
</PasswordBox.Background>
</PasswordBox>
<Label HorizontalAlignment="Left" Content="Model" />
<ComboBox
x:Name="ModelComboBox"
MinWidth="140"
HorizontalAlignment="Left"
VerticalAlignment="Top" />
<Label HorizontalAlignment="Left" Content="Deployment-ID" />
<TextBox
x:Name="DeploymentIdTextbox"
MinWidth="200"
VerticalAlignment="Top">
<TextBox.Background>
<SolidColorBrush Opacity="0.5" Color="{DynamicResource SystemChromeLowColor}" />
</TextBox.Background>
</TextBox>
<Label HorizontalAlignment="Left" Content="BaseDomain" />
<TextBox
x:Name="BaseDomainTextbox"
MinWidth="200"
VerticalAlignment="Top"
ui:ControlHelper.PlaceholderText="">
<TextBox.Background>
<SolidColorBrush Opacity="0.5" Color="{DynamicResource SystemChromeLowColor}" />
</TextBox.Background>
</TextBox>
</StackPanel>
<Button
x:Name="OkButton"
Grid.Row="2"
Width="120"
Height="30"
MinWidth="60"
Margin="0,0,10,10"
Padding="0,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Click="OkButton_Click"
Content="_OK"
IsDefault="True"
Style="{StaticResource AccentButtonStyle}" />
</Grid>
</Window>
84 changes: 84 additions & 0 deletions msbuild-gui/APISettings.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using ModernWpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;

namespace msbuild_gui
{
/// <summary>
/// ColorSettings.xaml の相互作用ロジック
/// </summary>
public partial class APISettings : Window
{
public static bool OkFlg { get; set; }

public APISettings()
{
InitializeComponent();
this.WindowStartupLocation = WindowStartupLocation.CenterOwner;
OkFlg = false;

ProviderComboBox.Text = Properties.Settings.Default.Provider;

Check failure on line 26 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'Provider' and no accessible extension method 'Provider' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
APIKeyPasswordbox.Password = Properties.Settings.Default.APIKey;

Check failure on line 27 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'APIKey' and no accessible extension method 'APIKey' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
DeploymentIdTextbox.Text = Properties.Settings.Default.AzDeploymentId;

Check failure on line 28 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'AzDeploymentId' and no accessible extension method 'AzDeploymentId' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
BaseDomainTextbox.Text = Properties.Settings.Default.AzBaseDomain;

Check failure on line 29 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'AzBaseDomain' and no accessible extension method 'AzBaseDomain' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
string[] modelList = Properties.Settings.Default.ModelList.Split(',');

Check failure on line 30 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'ModelList' and no accessible extension method 'ModelList' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
foreach(string model in modelList)
{
ModelComboBox.Items.Add(model);
}
ModelComboBox.Text = Properties.Settings.Default.Model;

Check failure on line 35 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'Model' and no accessible extension method 'Model' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
}
/// <summary>
/// 閉じるボタン押下時
/// </summary>
protected virtual void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (OkFlg == false)
{
}
}

private void OkButton_Click(object sender, RoutedEventArgs e)
{
OkFlg = true;

Properties.Settings.Default.Provider = ProviderComboBox.Text;

Check failure on line 51 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'Provider' and no accessible extension method 'Provider' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
Properties.Settings.Default.APIKey = APIKeyPasswordbox.Password;

Check failure on line 52 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'APIKey' and no accessible extension method 'APIKey' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
Properties.Settings.Default.Model = ModelComboBox.Text;

Check failure on line 53 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'Model' and no accessible extension method 'Model' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
Properties.Settings.Default.AzDeploymentId = DeploymentIdTextbox.Text;

Check failure on line 54 in msbuild-gui/APISettings.xaml.cs

View workflow job for this annotation

GitHub Actions / build

'Settings' does not contain a definition for 'AzDeploymentId' and no accessible extension method 'AzDeploymentId' accepting a first argument of type 'Settings' could be found (are you missing a using directive or an assembly reference?)
Properties.Settings.Default.AzBaseDomain = BaseDomainTextbox.Text;
Properties.Settings.Default.Save();
this.Close();
}
private void Window_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
}

private void ProviderComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ProviderComboBox.SelectedItem == null) return;
if (ProviderComboBox.SelectedItem.ToString() == "System.Windows.Controls.ComboBoxItem: OpenAI")
{
ModelComboBox.IsEnabled = true;
DeploymentIdTextbox.IsEnabled = false;
BaseDomainTextbox.IsEnabled = false;
}
else
{
ModelComboBox.IsEnabled = false;
DeploymentIdTextbox.IsEnabled = true;
BaseDomainTextbox.IsEnabled = true;
}
}
}
}
2 changes: 1 addition & 1 deletion msbuild-gui/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ private void ShowResult(string[,] list, string cmdErrorText)
resultErrorText.Close();
if (ShowLogCheck.IsChecked == true)
{
ShowResult(Properties.Resources.ExecutionResult + " ※" + Properties.Resources.Error, TargetList.Items.Count, list, cmdErrorText + errTxt);
ShowResult(Properties.Resources.ExecutionResult + " ※" + Properties.Resources.Error, TargetList.Items.Count, list, cmdErrorText + errTxt.Replace("\n", "\n\n"));
}
else
{
Expand Down
20 changes: 20 additions & 0 deletions msbuild-gui/Plugins/SemanticPlugins/ErrorAnalysis/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"schema": 1,
"type": "completion",
"description": "Analyze the cause of C# error messages received",
"completion": {
"temperature": 0.0,
"top_p": 0.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0
},
"input": {
"parameters": [
{
"name": "errorMessage",
"description": "error message",
"defaultValue": ""
}
]
}
}
11 changes: 11 additions & 0 deletions msbuild-gui/Plugins/SemanticPlugins/ErrorAnalysis/skprompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# System
Your role involves addressing all types of C# errors with a focus on providing complex and detailed explanations suitable for experienced programmers.
Accuracy is paramount in your responses. When analyzing error messages, offer in-depth technical insights and suggest advanced debugging techniques.
Your advice should be precise, catering to users with a strong understanding of programming concepts.
Ensure that your responses delve into the nuances of C# programming, providing high-level guidance and expert advice.
This approach will help experienced programmers gain a deeper understanding of the issues they are facing and how to resolve them effectively.
If the error message occurs in more than one .csproj, please explain each one separately.
Please answer in {{$language}}.

# Error message
{{$errorMessage}}

0 comments on commit 8ffc3b8

Please sign in to comment.