-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply all code fixes; no functional changes.
- Loading branch information
Showing
13 changed files
with
762 additions
and
775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
src/ReSharper.ExportAnnotations.Core/AnnotationsExporter - Export.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
// ----------------------------------------------------------------------------------- | ||
// --------------------------------------------------------------------------------------- | ||
// Copyright (C) Riccardo De Agostini and Tenacom. All rights reserved. | ||
// Licensed under the MIT license. | ||
// See LICENSE file in the project root for full license information. | ||
// See the LICENSE file in the project root for full license information. | ||
// | ||
// Part of this file may be third-party code, distributed under a compatible license. | ||
// See THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// ----------------------------------------------------------------------------------- | ||
// See the THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// --------------------------------------------------------------------------------------- | ||
|
||
using System.Xml.Linq; | ||
using JetBrains.Annotations; | ||
using Mono.Cecil; | ||
|
||
namespace ReSharper.ExportAnnotations | ||
namespace ReSharper.ExportAnnotations; | ||
|
||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
/// <content /> | ||
public partial class AnnotationsExporter | ||
[PublicAPI] | ||
private static void ExportAnnotations(AssemblyDefinition assembly, string xmlPath) | ||
{ | ||
[PublicAPI] | ||
private static void ExportAnnotations(AssemblyDefinition assembly, string xmlPath) | ||
{ | ||
var xml = new XDocument(AssemblyToXml(assembly)); | ||
xml.Save(xmlPath, SaveOptions.None); | ||
} | ||
var xml = new XDocument(AssemblyToXml(assembly)); | ||
xml.Save(xmlPath, SaveOptions.None); | ||
} | ||
} |
59 changes: 29 additions & 30 deletions
59
src/ReSharper.ExportAnnotations.Core/AnnotationsExporter-BuildXml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,50 @@ | ||
// ----------------------------------------------------------------------------------- | ||
// --------------------------------------------------------------------------------------- | ||
// Copyright (C) Riccardo De Agostini and Tenacom. All rights reserved. | ||
// Licensed under the MIT license. | ||
// See LICENSE file in the project root for full license information. | ||
// See the LICENSE file in the project root for full license information. | ||
// | ||
// Part of this file may be third-party code, distributed under a compatible license. | ||
// See THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// ----------------------------------------------------------------------------------- | ||
// See the THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// --------------------------------------------------------------------------------------- | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Xml.Linq; | ||
using Mono.Cecil; | ||
using ReSharper.ExportAnnotations.Internal; | ||
|
||
namespace ReSharper.ExportAnnotations | ||
namespace ReSharper.ExportAnnotations; | ||
|
||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
private static IEnumerable<XElement> GetCustomAttributeArgumentsXml(ICustomAttribute customAttribute) | ||
=> customAttribute.ConstructorArguments.Select(CustomAttributeArgumentToXml); | ||
private static IEnumerable<XElement> GetCustomAttributeArgumentsXml(ICustomAttribute customAttribute) | ||
=> customAttribute.ConstructorArguments.Select(CustomAttributeArgumentToXml); | ||
|
||
private static IEnumerable<XElement> GetAnnotationsXml(ICustomAttributeProvider member) | ||
=> member.CustomAttributes.Where(IsExportableJetBrainsAnnotation).Select(CustomAttributeToXml); | ||
private static IEnumerable<XElement> GetAnnotationsXml(ICustomAttributeProvider member) | ||
=> member.CustomAttributes.Where(IsExportableJetBrainsAnnotation).Select(CustomAttributeToXml); | ||
|
||
private static IEnumerable<XElement> GetGenericParametersXml(IGenericParameterProvider provider) | ||
=> provider.GenericParameters | ||
.Where(p => p.HasCustomAttributes) | ||
.Select(GenericParameterToXml) | ||
.WhereNotNull(); | ||
private static IEnumerable<XElement> GetGenericParametersXml(IGenericParameterProvider provider) | ||
=> provider.GenericParameters | ||
.Where(p => p.HasCustomAttributes) | ||
.Select(GenericParameterToXml) | ||
.WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetParametersXml(IEnumerable<ParameterDefinition> parameters) | ||
=> parameters.Where(p => p.HasCustomAttributes).Select(ParameterToXml).WhereNotNull(); | ||
private static IEnumerable<XElement> GetParametersXml(IEnumerable<ParameterDefinition> parameters) | ||
=> parameters.Where(p => p.HasCustomAttributes).Select(ParameterToXml).WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetMethodsXml(TypeDefinition type) | ||
=> type.Methods.Select(MethodToXml).WhereNotNull(); | ||
private static IEnumerable<XElement> GetMethodsXml(TypeDefinition type) | ||
=> type.Methods.Select(MethodToXml).WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetPropertiesXml(TypeDefinition type) | ||
=> type.Properties.Select(PropertyToXml).WhereNotNull(); | ||
private static IEnumerable<XElement> GetPropertiesXml(TypeDefinition type) | ||
=> type.Properties.Select(PropertyToXml).WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetFieldsXml(TypeDefinition type) | ||
=> type.Fields.Select(FieldToXml).WhereNotNull(); | ||
private static IEnumerable<XElement> GetFieldsXml(TypeDefinition type) | ||
=> type.Fields.Select(FieldToXml).WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetEventsXml(TypeDefinition type) | ||
=> type.Events.Select(EventToXml).WhereNotNull(); | ||
private static IEnumerable<XElement> GetEventsXml(TypeDefinition type) | ||
=> type.Events.Select(EventToXml).WhereNotNull(); | ||
|
||
private static IEnumerable<XElement> GetTypesXml(AssemblyDefinition assembly) | ||
=> assembly.Modules.SelectMany(m => m.GetTypes()).Where(IsExportedType).SelectMany(TypeToXml); | ||
} | ||
private static IEnumerable<XElement> GetTypesXml(AssemblyDefinition assembly) | ||
=> assembly.Modules.SelectMany(m => m.GetTypes()).Where(IsExportedType).SelectMany(TypeToXml); | ||
} |
61 changes: 30 additions & 31 deletions
61
src/ReSharper.ExportAnnotations.Core/AnnotationsExporter-Filters.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,48 @@ | ||
// ----------------------------------------------------------------------------------- | ||
// --------------------------------------------------------------------------------------- | ||
// Copyright (C) Riccardo De Agostini and Tenacom. All rights reserved. | ||
// Licensed under the MIT license. | ||
// See LICENSE file in the project root for full license information. | ||
// See the LICENSE file in the project root for full license information. | ||
// | ||
// Part of this file may be third-party code, distributed under a compatible license. | ||
// See THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// ----------------------------------------------------------------------------------- | ||
// See the THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// --------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Mono.Cecil; | ||
|
||
namespace ReSharper.ExportAnnotations | ||
namespace ReSharper.ExportAnnotations; | ||
|
||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
/// <content /> | ||
public partial class AnnotationsExporter | ||
private static readonly IReadOnlyList<string> NonExportableAttributeNames = new[] | ||
{ | ||
private static readonly IReadOnlyList<string> NonExportableAttributeNames = new[] | ||
{ | ||
"AspMvcSuppressViewErrorAttribute", | ||
"LocalizationRequiredAttribute", | ||
"MeansImplicitUseAttribute", | ||
"NoReorderAttribute", | ||
"PublicAPIAttribute", | ||
"UsedImplicitlyAttribute", | ||
}; | ||
"AspMvcSuppressViewErrorAttribute", | ||
"LocalizationRequiredAttribute", | ||
"MeansImplicitUseAttribute", | ||
"NoReorderAttribute", | ||
"PublicAPIAttribute", | ||
"UsedImplicitlyAttribute", | ||
}; | ||
|
||
private static bool IsExportableJetBrainsAnnotation(CustomAttribute attribute) | ||
=> attribute.AttributeType.Namespace == "JetBrains.Annotations" | ||
&& !NonExportableAttributeNames.Contains(attribute.AttributeType.Name, StringComparer.Ordinal); | ||
private static bool IsExportableJetBrainsAnnotation(CustomAttribute attribute) | ||
=> attribute.AttributeType.Namespace == "JetBrains.Annotations" | ||
&& !NonExportableAttributeNames.Contains(attribute.AttributeType.Name, StringComparer.Ordinal); | ||
|
||
private static bool IsExportedType(TypeDefinition type) | ||
private static bool IsExportedType(TypeDefinition type) | ||
{ | ||
// ReSharper disable once SwitchStatementMissingSomeCases | ||
switch (type.Attributes & TypeAttributes.VisibilityMask) | ||
{ | ||
// ReSharper disable once SwitchStatementMissingSomeCases | ||
switch (type.Attributes & TypeAttributes.VisibilityMask) | ||
{ | ||
case TypeAttributes.Public: | ||
case TypeAttributes.NestedPublic: | ||
case TypeAttributes.NestedFamily: | ||
case TypeAttributes.NestedFamORAssem: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
case TypeAttributes.Public: | ||
case TypeAttributes.NestedPublic: | ||
case TypeAttributes.NestedFamily: | ||
case TypeAttributes.NestedFamORAssem: | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
} |
25 changes: 12 additions & 13 deletions
25
src/ReSharper.ExportAnnotations.Core/AnnotationsExporter-GetXmlName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
// ----------------------------------------------------------------------------------- | ||
// --------------------------------------------------------------------------------------- | ||
// Copyright (C) Riccardo De Agostini and Tenacom. All rights reserved. | ||
// Licensed under the MIT license. | ||
// See LICENSE file in the project root for full license information. | ||
// See the LICENSE file in the project root for full license information. | ||
// | ||
// Part of this file may be third-party code, distributed under a compatible license. | ||
// See THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// ----------------------------------------------------------------------------------- | ||
// See the THIRD-PARTY-NOTICES file in the project root for third-party copyright notices. | ||
// --------------------------------------------------------------------------------------- | ||
|
||
using System.Text; | ||
using Cecil.XmlDocNames; | ||
using Mono.Cecil; | ||
|
||
namespace ReSharper.ExportAnnotations | ||
namespace ReSharper.ExportAnnotations; | ||
|
||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
/// <content /> | ||
public partial class AnnotationsExporter | ||
{ | ||
private static string GetXmlName(AssemblyDefinition assembly) => assembly.Name.Name; | ||
private static string GetXmlName(AssemblyDefinition assembly) => assembly.Name.Name; | ||
|
||
private static string GetXmlName(ParameterReference parameter) => parameter.Name; | ||
private static string GetXmlName(ParameterReference parameter) => parameter.Name; | ||
|
||
private static string GetXmlName(MemberReference member) | ||
=> new StringBuilder().AppendXmlDocName(member).ToString(); | ||
} | ||
private static string GetXmlName(MemberReference member) | ||
=> new StringBuilder().AppendXmlDocName(member).ToString(); | ||
} |
Oops, something went wrong.