Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Remove compilation warnings #222

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions BuildEventsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public BuildEventsHandler(DTE dte)

private void OnBuildProjConfigBegin(string Project, string ProjectConfig, string Platform, string SolutionConfig)
{
ThreadHelper.ThrowIfNotOnUIThread();
// here we generate profiles for all projects but we probably should only generate profiles for
// the project marked as startup project
Project invokedProject = ProjectConfigurationManager.GetProjectByName(_dte, Project);
Expand All @@ -33,12 +34,12 @@ private void OnBuildProjConfigBegin(string Project, string ProjectConfig, string
// We always overrwrite the script for the prebuild event
// the ps1 is always overwritten but the event is only added if no conan_install.ps1 is found
// in the prebuild events
ProjectConfigurationManager.SaveConanPrebuildEventsAllConfig(invokedProject);
_ = ProjectConfigurationManager.SaveConanPrebuildEventsAllConfigAsync(invokedProject);
}

private void OnBuildProjConfigDone(string Project, string ProjectConfig, string Platform, string SolutionConfig, bool Success)
{
//ThreadHelper.ThrowIfNotOnUIThread();
ThreadHelper.ThrowIfNotOnUIThread();
var message = "OnBuildProjConfigDone";
System.Diagnostics.Debug.WriteLine(message);
Project invokedProject = ProjectConfigurationManager.GetProjectByName(_dte, Project);
Expand Down
12 changes: 9 additions & 3 deletions ConanToolWindowControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private async Task CopyJsonFileFromResourceIfNeededAsync()

private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
FilterListView(LibrarySearchTextBox.Text, ShowPackagesCheckbox.IsChecked ?? false);
}

Expand All @@ -114,8 +115,9 @@ private async Task LoadLibrariesFromJsonAsync()
string json = await Task.Run(() => File.ReadAllText(jsonFilePath));
_jsonData = JsonConvert.DeserializeObject<RootObject>(json);

Dispatcher.Invoke(() =>
{
await ThreadHelper.JoinableTaskFactory.RunAsync(async delegate {
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

PackagesListView.Items.Clear();
foreach (var library in _jsonData.Libraries.Keys)
{
Expand All @@ -126,6 +128,8 @@ private async Task LoadLibrariesFromJsonAsync()

private void FilterListView(string searchText, bool onlyInstalled)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (_jsonData == null || _jsonData.Libraries == null) return;

PackagesListView.Items.Clear();
Expand Down Expand Up @@ -162,6 +166,7 @@ private void FilterListView(string searchText, bool onlyInstalled)

private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
if (PackagesListView.SelectedItem is string selectedItem)
{
UpdateLibraryInfo(selectedItem);
Expand Down Expand Up @@ -227,7 +232,7 @@ private void InstallButton_Click(object sender, RoutedEventArgs e)
ConanFileManager.WriteNecessaryConanGuardedFiles(projectDirectory);
ConanFileManager.WriteNewRequirement(projectDirectory, selectedLibrary + "/" + selectedVersion);

ProjectConfigurationManager.SaveConanPrebuildEventsAllConfig(startupProject);
_ = ProjectConfigurationManager.SaveConanPrebuildEventsAllConfigAsync(startupProject);
VersionsComboBox.IsEnabled = false;
FilterListView(LibrarySearchTextBox.Text, ShowPackagesCheckbox.IsChecked ?? false);
}
Expand Down Expand Up @@ -317,6 +322,7 @@ private void Configuration_Click(object sender, RoutedEventArgs e)

private void ShowPackagesCheckbox_Click(object sender, RoutedEventArgs e)
{
ThreadHelper.ThrowIfNotOnUIThread();
FilterListView(LibrarySearchTextBox.Text, ShowPackagesCheckbox.IsChecked ?? false);
}

Expand Down
3 changes: 2 additions & 1 deletion ProjectConfigurationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public ProjectConfigurationManager()

static private bool conandataFileExists(Project project)
{
ThreadHelper.ThrowIfNotOnUIThread();
string projectDirectory = System.IO.Path.GetDirectoryName(project.FullName);
string path = Path.Combine(projectDirectory, "conandata.yml");
return File.Exists(path);
Expand Down Expand Up @@ -196,7 +197,7 @@ private static async Task SaveConanPrebuildEventAsync(Project project, VCConfigu
}
}

public static async void SaveConanPrebuildEventsAllConfig(Project project)
public static async Task SaveConanPrebuildEventsAllConfigAsync(Project project)
{
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
await GenerateConanInstallScriptAsync(project); // all the config share the same script
Expand Down
Loading