Skip to content

Commit

Permalink
Fixed issue where the extension would create multiple output window p…
Browse files Browse the repository at this point in the history
…anes

Fixed issue where exceptions were not being written to the output window pane
Fixed issue when trying to get the file name of unloaded projects
  • Loading branch information
icnocop committed Nov 8, 2024
1 parent 9fd646f commit ed66a11
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ jobs:
uses: actions/upload-artifact@v4
# https://github.com/marketplace/actions/upload-a-build-artifact
with:
name: PackageReferenceVersionToAttributeExtension-${{ env.VERSION }} ${{matrix.Configuration}}
name: PackageReferenceVersionToAttribute-${{ env.VERSION }} ${{matrix.Configuration}}
path: |
.\src\PackageReferenceVersionToAttributeExtension\bin\${{matrix.Configuration}}\PackageReferenceVersionToAttributeExtension.vsix
.\src\PackageReferenceVersionToAttributeTool\bin\${{matrix.Configuration}}\PackageReferenceVersionToAttribute.Tool.${{ env.SEM_VERSION }}.nupkg
if-no-files-found: error
- name: Publish GitHub Release
if: ${{ matrix.Configuration == 'Release' && github.event.inputs.publishVsix == 'true' }}
Expand All @@ -174,7 +173,7 @@ jobs:
run: dotnet nuget push .\src\PackageReferenceVersionToAttributeTool\bin\${{matrix.Configuration}}\PackageReferenceVersionToAttribute.Tool.${{ env.SEM_VERSION }}.nupkg --api-key ${{ secrets.NUGET_KEY }} --source https://api.nuget.org/v3/index.json

- name: Publish to Open VSIX
if: ${{ matrix.Configuration == 'Release' && github.event_name != 'pull_request' && (github.event.inputs.skipPublishNupkg == '' || github.event.inputs.skipPublishNupkg == 'false') }}
if: ${{ matrix.Configuration == 'Release' && github.event_name != 'pull_request' && (github.event.inputs.publishVsix == 'true') }}
run: |
[Reflection.Assembly]::LoadWithPartialName("System.Web") | Out-Null
$vsixFile = ".\src\PackageReferenceVersionToAttributeExtension\bin\${{matrix.Configuration}}\PackageReferenceVersionToAttributeExtension.vsix"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## v1.0.1108.39 (November 8<sup>th</sup>, 2024)

- Fixed issue where the extension would create multiple output window panes
- Fixed issue where exceptions were not being written to the output window pane
- Fixed issue when trying to get the file name of unloaded projects

## v1.0.1105.37 (November 5<sup>th</sup>, 2024)

- Added support for converting projects within sln files on the command line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace PackageReferenceVersionToAttributeExtension.Logging
{
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PackageReferenceVersionToAttributeExtension.Services;

Expand All @@ -13,9 +14,20 @@ namespace PackageReferenceVersionToAttributeExtension.Logging
/// </summary>
internal sealed class CustomLoggerProvider : ILoggerProvider, IDisposable
{
private readonly IServiceProvider serviceProvider;

/// <summary>
/// Initializes a new instance of the <see cref="CustomLoggerProvider"/> class.
/// </summary>
/// <param name="serviceProvider">The service provider.</param>
public CustomLoggerProvider(IServiceProvider serviceProvider)
{
this.serviceProvider = serviceProvider;
}

/// <inheritdoc/>
public ILogger CreateLogger(string categoryName)
=> new OutputWindowLogger();
=> this.serviceProvider.GetRequiredService<OutputWindowLogger>();

/// <inheritdoc/>
public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public void Log<TState>(
if (formatter != null)
{
var message = formatter(state, exception);
if (exception != null)
{
message += " " + exception.ToString();
}

try
{
Expand Down
1 change: 1 addition & 0 deletions src/PackageReferenceVersionToAttributeExtension/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected override void InitializeServices(IServiceCollection services)
.AddSingleton<BaseCommand>()
.AddSingleton<ProjectService>()
.AddSingleton<ProjectConverter>()
.AddSingleton<OutputWindowLogger>()
.AddLogging(configure =>
{
configure.ClearProviders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PackageReferenceVersionToAttributeExtension.Services
{
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -42,7 +43,18 @@ public async Task CheckOutFileAsync(string filePath)
&& (!this.dte.Solution.Projects.Cast<Project>().Any(x =>
{
ThreadHelper.ThrowIfNotOnUIThread();
return x.FileName == filePath;

try
{
return x.FileName == filePath;
}
catch (NotImplementedException ex)
{
// ex. an unloaded project has type DteGenericProject
// ex. Exception thrown: 'System.NotImplementedException' in Microsoft.VisualStudio.CommonIDE.dll
this.logger.LogWarning(ex, $"Failed to get file name for project '{x.Name}'.");
return false;
}
}))))
{
return;
Expand Down

0 comments on commit ed66a11

Please sign in to comment.