Skip to content

Commit

Permalink
Merge pull request #3763 from sharwell/remove-vsix
Browse files Browse the repository at this point in the history
Remove VSIX project and unnecessary build outputs
  • Loading branch information
sharwell authored Dec 27, 2023
2 parents 73b34ac + cdb5e0f commit f139428
Show file tree
Hide file tree
Showing 27 changed files with 139 additions and 175 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard1.1;net452</TargetFrameworks>
<TargetFramework>netstandard1.1</TargetFramework>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
<RootNamespace>StyleCop.Analyzers</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
Expand All @@ -16,14 +18,6 @@
<NoWarn>$(NoWarn),NU5105</NoWarn>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'netstandard1.1'">
<PropertyGroup>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
</When>
</Choose>

<PropertyGroup>
<CodeAnalysisRuleSet>..\StyleCop.Analyzers.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace StyleCop.Analyzers.Test.LightJson
{
using System;
using System.Diagnostics;
using System.Reflection;
using global::LightJson;
using Xunit;
using IEnumerable = System.Collections.IEnumerable;
Expand Down Expand Up @@ -141,5 +143,22 @@ public void TestEnumerators()
}
}
}

[Fact]
public void TestDebugView()
{
var obj = new JsonArray("a", "b", "c");
var proxyAttribute = obj.GetType().GetCustomAttribute<DebuggerTypeProxyAttribute>();
Assert.NotNull(proxyAttribute);

var proxyType = Type.GetType(proxyAttribute.ProxyTypeName);
Assert.NotNull(proxyType);

var proxy = Activator.CreateInstance(proxyType, obj);
Assert.NotNull(proxy);

var items = proxyType.GetTypeInfo().GetDeclaredProperty("Items").GetValue(proxy);
Assert.IsType<JsonValue[]>(items);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace StyleCop.Analyzers.Test.LightJson
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using global::LightJson;
using Xunit;
using IEnumerable = System.Collections.IEnumerable;
Expand Down Expand Up @@ -109,6 +111,35 @@ public void TestRename()
Assert.Same(value, obj["y"].AsString);
}

[Fact]
public void TestDebugView()
{
var obj = new JsonObject
{
["x"] = "string value",
["y"] = new JsonObject(),
["z"] = new JsonArray("a", "b", "c"),
};
var proxyAttribute = obj.GetType().GetCustomAttribute<DebuggerTypeProxyAttribute>();
Assert.NotNull(proxyAttribute);

var proxyType = Type.GetType(proxyAttribute.ProxyTypeName);
Assert.NotNull(proxyType);

var proxy = Activator.CreateInstance(proxyType, obj);
Assert.NotNull(proxy);

var keys = proxyType.GetTypeInfo().GetDeclaredProperty("Keys").GetValue(proxy);
var keysArray = Assert.IsAssignableFrom<Array>(keys);

Assert.NotEmpty(keysArray);
foreach (var key in keysArray)
{
var view = key.GetType().GetTypeInfo().GetDeclaredProperty("View").GetValue(key);
Assert.NotNull(view);
}
}

#pragma warning disable IDE0060 // Remove unused parameter
private static Type StaticType<T>(T value) => typeof(T);
#pragma warning restore IDE0060 // Remove unused parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
namespace StyleCop.Analyzers.Test.LightJson
{
using System;
using System.Diagnostics;
using System.Reflection;
using global::LightJson;
using global::LightJson.Serialization;
using StyleCop.Analyzers.Test.Helpers;
Expand Down Expand Up @@ -351,5 +353,86 @@ public void TestParse()
Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse(string.Empty));
Assert.ThrowsAny<JsonParseException>(() => JsonValue.Parse("{"));
}

[Fact]
public void TestDebugViewOfObject()
{
var obj = JsonValue.Parse("{}");
var proxyAttribute = obj.GetType().GetCustomAttribute<DebuggerTypeProxyAttribute>();
Assert.NotNull(proxyAttribute);

var proxyType = Type.GetType(proxyAttribute.ProxyTypeName);
Assert.NotNull(proxyType);

var proxy = Activator.CreateInstance(proxyType, obj);
Assert.NotNull(proxy);

var objectView = proxyType.GetTypeInfo().GetDeclaredProperty("ObjectView").GetValue(proxy);
var arrayView = proxyType.GetTypeInfo().GetDeclaredProperty("ArrayView").GetValue(proxy);
var jsonValueType = proxyType.GetTypeInfo().GetDeclaredProperty("Type").GetValue(proxy);
var value = proxyType.GetTypeInfo().GetDeclaredProperty("Value").GetValue(proxy);

Assert.Same(obj.AsJsonObject, objectView);
Assert.Same(obj.AsJsonArray, arrayView);

Assert.IsType<JsonObject>(objectView);
Assert.Null(arrayView);
Assert.Equal(obj.Type, jsonValueType);
Assert.Same(obj.AsJsonObject, value);
}

[Fact]
public void TestDebugViewOfArray()
{
var obj = JsonValue.Parse("[]");
var proxyAttribute = obj.GetType().GetCustomAttribute<DebuggerTypeProxyAttribute>();
Assert.NotNull(proxyAttribute);

var proxyType = Type.GetType(proxyAttribute.ProxyTypeName);
Assert.NotNull(proxyType);

var proxy = Activator.CreateInstance(proxyType, obj);
Assert.NotNull(proxy);

var objectView = proxyType.GetTypeInfo().GetDeclaredProperty("ObjectView").GetValue(proxy);
var arrayView = proxyType.GetTypeInfo().GetDeclaredProperty("ArrayView").GetValue(proxy);
var jsonValueType = proxyType.GetTypeInfo().GetDeclaredProperty("Type").GetValue(proxy);
var value = proxyType.GetTypeInfo().GetDeclaredProperty("Value").GetValue(proxy);

Assert.Same(obj.AsJsonObject, objectView);
Assert.Same(obj.AsJsonArray, arrayView);

Assert.Null(objectView);
Assert.IsType<JsonArray>(arrayView);
Assert.Equal(obj.Type, jsonValueType);
Assert.Same(obj.AsJsonArray, value);
}

[Fact]
public void TestDebugViewOfBoolean()
{
var obj = JsonValue.Parse("true");
var proxyAttribute = obj.GetType().GetCustomAttribute<DebuggerTypeProxyAttribute>();
Assert.NotNull(proxyAttribute);

var proxyType = Type.GetType(proxyAttribute.ProxyTypeName);
Assert.NotNull(proxyType);

var proxy = Activator.CreateInstance(proxyType, obj);
Assert.NotNull(proxy);

var objectView = proxyType.GetTypeInfo().GetDeclaredProperty("ObjectView").GetValue(proxy);
var arrayView = proxyType.GetTypeInfo().GetDeclaredProperty("ArrayView").GetValue(proxy);
var jsonValueType = proxyType.GetTypeInfo().GetDeclaredProperty("Type").GetValue(proxy);
var value = proxyType.GetTypeInfo().GetDeclaredProperty("Value").GetValue(proxy);

Assert.Same(obj.AsJsonObject, objectView);
Assert.Same(obj.AsJsonArray, arrayView);

Assert.Null(objectView);
Assert.Null(arrayView);
Assert.Equal(obj.Type, jsonValueType);
Assert.Equal(obj, value);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#nullable disable

namespace StyleCop.Analyzers
{
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;

internal static class AnalyzerConstants
{
static AnalyzerConstants()
{
#if DEBUG
// In DEBUG builds, the tests are enabled to simplify development and testing.
DisabledNoTests = true;
#else
DisabledNoTests = false;
#endif
}

/// <summary>
/// Gets a reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to disable a diagnostic which is currently untested.
/// </summary>
/// <value>
/// A reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to disable a diagnostic which is currently untested.
/// </value>
[ExcludeFromCodeCoverage]
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation should match accessors.", Justification = "This property behaves more like an opaque value than a Boolean.")]
internal static bool DisabledNoTests { get; }

/// <summary>
/// Gets a reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;

Expand Down Expand Up @@ -43,7 +42,6 @@ internal class SA1603DocumentationMustContainValidXml : DiagnosticAnalyzer
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
[ExcludeFromCodeCoverage]
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;

Expand Down Expand Up @@ -59,7 +58,6 @@ internal class SA1628DocumentationTextMustBeginWithACapitalLetter : DiagnosticAn
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
[ExcludeFromCodeCoverage]
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;

Expand Down Expand Up @@ -59,7 +58,6 @@ internal class SA1630DocumentationTextMustContainWhitespace : DiagnosticAnalyzer
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
[ExcludeFromCodeCoverage]
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
namespace StyleCop.Analyzers.DocumentationRules
{
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;

Expand Down Expand Up @@ -60,7 +59,6 @@ internal class SA1631DocumentationMustMeetCharacterPercentage : DiagnosticAnalyz
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
[ExcludeFromCodeCoverage]
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
Expand Down
Loading

0 comments on commit f139428

Please sign in to comment.