-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e240e0
commit f3444e8
Showing
39 changed files
with
581 additions
and
726 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
2 changes: 2 additions & 0 deletions
2
AssemblyToProcess/ClassWithAutoPropertiesInitializedInSeparateMethod.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
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
1 change: 1 addition & 0 deletions
1
AssemblyToProcess/ClassWithExplicitInitializedAutoPropertiesDerivedProperDesign.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
1 change: 1 addition & 0 deletions
1
AssemblyToProcess/ClassWithExplicitInitializedAutoPropertiesDerivedWeakDesign.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
1 change: 1 addition & 0 deletions
1
AssemblyToProcess/ClassWithExplicitInitializedBackingFieldProperties.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
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
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
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,4 +1,5 @@ | ||
using System; | ||
// ReSharper disable all | ||
using System; | ||
using System.Configuration; | ||
using System.Reflection; | ||
|
||
|
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
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
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,3 +1,4 @@ | ||
// ReSharper disable all | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/CSharpAnnotationTypingAssist/IsEnabledAfterTypeName/@EntryValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/CodeEditing/TypingAssist/CSharpAnnotationTypingAssist/IsEnabledAtOtherPositions/@EntryValue">True</s:Boolean> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateCanBeNullParameter/@EntryIndexedValue">DO_NOT_SHOW</s:String> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateCanBeNullTypeMember/@EntryIndexedValue">DO_NOT_SHOW</s:String> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateNotNullParameter/@EntryIndexedValue">DO_NOT_SHOW</s:String> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=AnnotateNotNullTypeMember/@EntryIndexedValue">DO_NOT_SHOW</s:String> | ||
<s:String x:Key="/Default/CodeInspection/Highlighting/ValueAnalysisMode/@EntryValue">OPTIMISTIC</s:String> | ||
<s:String x:Key="/Default/Environment/PerformanceGuide/SwitchBehaviour/=Antivirus/@EntryIndexedValue">DO_NOTHING</s:String></wpf:ResourceDictionary> |
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
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,65 +1,55 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using JetBrains.Annotations; | ||
namespace AutoProperties.Fody | ||
{ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
|
||
using Mono.Cecil; | ||
using Mono.Cecil; | ||
|
||
namespace AutoProperties.Fody | ||
{ | ||
internal class AutoPropertyToBackingFieldMap | ||
{ | ||
[NotNull] | ||
private readonly TypeDefinition _classDefinition; | ||
[CanBeNull] | ||
private IDictionary<string, AutoPropertyInfo> _map; | ||
private IDictionary<string, AutoPropertyInfo>? _map; | ||
|
||
public AutoPropertyToBackingFieldMap([NotNull] TypeDefinition classDefinition) | ||
public AutoPropertyToBackingFieldMap(TypeDefinition classDefinition) | ||
{ | ||
_classDefinition = classDefinition; | ||
} | ||
|
||
[ContractAnnotation("value:notnull => true")] | ||
public bool TryGetValue([NotNull] string propertyName, [CanBeNull] out AutoPropertyInfo value) | ||
public bool TryGetValue(string propertyName, [NotNullWhen(true)] out AutoPropertyInfo? value) | ||
{ | ||
var map = _map ?? (_map = CreateMap()); | ||
var map = _map ??= CreateMap(); | ||
|
||
return map.TryGetValue(propertyName, out value); | ||
} | ||
|
||
[NotNull] | ||
private IDictionary<string, AutoPropertyInfo> CreateMap() | ||
{ | ||
var fields = _classDefinition.Fields; | ||
var properties = _classDefinition.Properties; | ||
|
||
// ReSharper disable AssignNullToNotNullAttribute | ||
return CreateMap(properties, fields); | ||
// ReSharper restore AssignNullToNotNullAttribute | ||
} | ||
|
||
[NotNull] | ||
private static IDictionary<string, AutoPropertyInfo> CreateMap([NotNull, ItemNotNull] ICollection<PropertyDefinition> properties, [NotNull, ItemNotNull] ICollection<FieldDefinition> fields) | ||
private static IDictionary<string, AutoPropertyInfo> CreateMap(ICollection<PropertyDefinition> properties, ICollection<FieldDefinition> fields) | ||
{ | ||
return properties.Select(property => new { Property = property, BackingField = property.FindAutoPropertyBackingField(fields) }) | ||
.Where(item => item.BackingField != null) | ||
.Select(item => new AutoPropertyInfo(item.BackingField, item.Property)) | ||
.Select(item => new AutoPropertyInfo(item.BackingField!, item.Property)) | ||
.ToDictionary(item => item.Property.Name); | ||
} | ||
} | ||
|
||
internal class AutoPropertyInfo | ||
{ | ||
public AutoPropertyInfo([NotNull] FieldDefinition backingField, [NotNull] PropertyDefinition property) | ||
public AutoPropertyInfo(FieldDefinition backingField, PropertyDefinition property) | ||
{ | ||
BackingField = backingField; | ||
Property = property; | ||
} | ||
|
||
[NotNull] | ||
public FieldDefinition BackingField { get; } | ||
|
||
[NotNull] | ||
public PropertyDefinition Property { get; } | ||
} | ||
} |
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
Oops, something went wrong.