Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Switch to FxCop analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Apr 21, 2020
1 parent e477b31 commit fa7428b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
26 changes: 0 additions & 26 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ jobs:
- script: dotnet publish src/ApiPort/ApiPort/ApiPort.csproj -r win7-x86 -f netcoreapp2.1 --self-contained true
displayName: publish self-contained apiport - win7-x86

- powershell: |
# Extract rule Ids into a plaintext file that is expected by the Roslyn Analyzer build task
$xdoc = [xml](Get-Content ".\rules.ruleset")
$xdoc.RuleSet.Rules.Rule.Id | Out-File "bin\RoslynAnalyzerSuppressions.txt"
# Add NoWarn Ids
$xdoc = [xml](Get-Content ".\Directory.Build.props")
$xdoc.Project.PropertyGroup.NoWarn -split "," | Select -skip 1 | Where {$_} | Add-Content ".\bin\RoslynAnalyzerSuppressions.txt"
displayName: Extract suppression ids for Roslyn Analyzer task
- task: VSTest@2
displayName: Test with VSTest
inputs:
Expand Down Expand Up @@ -118,11 +108,6 @@ jobs:
Contents: '**\*.pdb'
TargetFolder: $(Build.StagingDirectory)\symbols

- task: securedevelopmentteam.vss-secure-development-tools.build-task-roslynanalyzers.RoslynAnalyzers@2
displayName: Run Roslyn Analyzers
inputs:
suppressionFileForCompilerWarnings: bin\RoslynAnalyzerSuppressions.txt

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: Component Detection

Expand All @@ -131,17 +116,6 @@ jobs:
artifact: drop-$(Agent.JobName)
enabled: false

- task: securedevelopmentteam.vss-secure-development-tools.build-task-fxcop.FxCop@2
displayName: 'Run FxCop'
inputs:
inputType: Basic
targets: 'bin\$(BuildConfiguration)\ApiPort*\net4*\**\ApiPort*.*;bin\$(BuildConfiguration)\ApiPort.Offline\net4*\**\Microsoft.Fx.*.dll;'
recursive: false
directory: 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'
verbose: true
enabled: false
continueOnError: true

- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
displayName: 'Run BinSkim '
inputs:
Expand Down
4 changes: 4 additions & 0 deletions src/ApiPort/ApiPort.VisualStudio/AnalyzeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ private async Task AnalyzeProjectsAsync(ICollection<Project> projects)
_output.WriteLine();
_output.WriteLine(ex.Message);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
_output.WriteLine();
_output.WriteLine(LocalizedStrings.UnknownError);
Expand Down Expand Up @@ -140,7 +142,9 @@ public async void AnalyzeMenuItemCallback(object sender, EventArgs e)
_output.WriteLine();
_output.WriteLine(ex.Message);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
_output.WriteLine();
_output.WriteLine(LocalizedStrings.UnknownError);
Expand Down
4 changes: 3 additions & 1 deletion src/ApiPort/ApiPort.VisualStudio/OutputWindowWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class OutputWindowWriter : TextWriter, IOutputWindowWriter
public OutputWindowWriter(DTE dte, IVsOutputWindowPane outputWindow)
: base(CultureInfo.CurrentCulture)
{
_outputWindow = outputWindow;
_outputWindow = outputWindow ?? throw new ArgumentNullException(nameof(outputWindow));
_dte = dte;

_outputWindow.Clear();
Expand All @@ -43,7 +43,9 @@ public async Task ShowWindowAsync()
Window window = _dte.Windows.Item(Constants.VsWindowKindOutput);
window.Activate();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public VsBrowserReportViewer(IFileSystem fileSystem, TextWriter output, IVsWebBr

public async Task ViewAsync(IEnumerable<string> urls)
{
foreach (var url in urls)
foreach (var url in urls ?? throw new ArgumentNullException(nameof(urls)))
{
if (IsHtml(url))
{
Expand Down
15 changes: 5 additions & 10 deletions src/ApiPort/ApiPort.VisualStudio/ServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.Fx.Portability.Analyzer;
using Microsoft.Fx.Portability.Proxy;
using Microsoft.Fx.Portability.Reporting;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
Expand Down Expand Up @@ -172,20 +173,14 @@ public static IVsOutputWindowPane BuildPane(IVsOutputWindow outputWindow)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (outputWindow.GetPane(ref _outputWindowGuid, out var windowPane) == S_OK)
if (ErrorHandler.Succeeded(outputWindow.GetPane(ref _outputWindowGuid, out var windowPane)))
{
return windowPane;
}

if (outputWindow.CreatePane(ref _outputWindowGuid, LocalizedStrings.PortabilityOutputTitle, 1, 0) == S_OK)
{
if (outputWindow.GetPane(ref _outputWindowGuid, out windowPane) == S_OK)
{
return windowPane;
}
}

throw new InvalidOperationException("Could not create pane");
ErrorHandler.ThrowOnFailure(outputWindow.CreatePane(ref _outputWindowGuid, LocalizedStrings.PortabilityOutputTitle, 1, 0));
ErrorHandler.ThrowOnFailure(outputWindow.GetPane(ref _outputWindowGuid, out windowPane));
return windowPane;
}

private static OutputViewModel GetOutputViewModel(IComponentContext context)
Expand Down

0 comments on commit fa7428b

Please sign in to comment.