Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Build and Publish

on:
push:
branches: [ master, publish ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
publish:
description: 'Publish the plugin to JetBrains Marketplace'
required: false
type: boolean
default: false

jobs:
build:
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:
run: ./gradlew testDotNet

- name: Publish Plugin
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
if: github.event_name == 'workflow_dispatch' && inputs.publish == true
shell: pwsh
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.1.0 - 2026-05-22
## [0.1.2] - 2026-05-24
### Added
- Support for `Ignore()` method for properties. Navigation to the source property is not suggested if the destination property is marked as ignored in the AutoMapper configuration.

## [0.1.1] - 2026-05-24
### Changed
- Minor changes.

## [0.1.0] - 2026-05-22
### Added
- Navigation from DTO property to source Model property via `Alt+Enter` (on `set`/`init` accessors).
- Support for `CreateMap<TSource, TDestination>` configurations.
- Support for `.ReverseMap()` allowing bidirectional navigation.
- Grouping of mappings by type when multiple mappings are found for the same property.
- Automatic use of full type names in the menu when multiple mappings are present.
- Integration with ReSharper 2025.3 SDK.

[0.1.2]: https://github.com/Backs/AutoMapper.FindUsage/compare/v0.1.1...v0.1.2
[0.1.1]: https://github.com/Backs/AutoMapper.FindUsage/compare/v0.1.0...v0.1.1
[0.1.0]: https://github.com/Backs/AutoMapper.FindUsage/releases/tag/v0.1.0
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# AutoMapper.FindUsage for Rider and ReSharper

[![Rider](https://img.shields.io/jetbrains/plugin/v/31907.svg?label=Rider&colorB=0A7BBB&style=for-the-badge&logo=rider)](https://plugins.jetbrains.com/plugin/31907)
[![ReSharper](https://img.shields.io/jetbrains/plugin/v/31907.svg?label=ReSharper&colorB=0A7BBB&style=for-the-badge&logo=resharper)](https://plugins.jetbrains.com/plugin/31907)
[![Build and Publish](https://github.com/Backs/AutoMapper.FindUsage/actions/workflows/build.yml/badge.svg)](https://github.com/Backs/AutoMapper.FindUsage/actions/workflows/build.yml)
[![Rider](https://img.shields.io/jetbrains/plugin/v/31907.svg?label=Rider&colorB=0A7BBB&style=flat&logo=rider)](https://plugins.jetbrains.com/plugin/31907)
[![ReSharper](https://img.shields.io/jetbrains/plugin/v/31908.svg?label=ReSharper&colorB=0A7BBB&style=flat&logo=resharper)](https://plugins.jetbrains.com/plugin/31908)

**AutoMapper.FindUsage** is a plugin for JetBrains Rider and ReSharper that provides seamless navigation between DTOs and Models based on your AutoMapper configurations.

Expand Down Expand Up @@ -38,15 +39,6 @@ CreateMap<Order, OrderDto>().ReverseMap();

You can install the plugin directly from the [JetBrains Marketplace](https://plugins.jetbrains.com/plugin/31907-automapper-findusage).

Alternatively, you can build it from source:

1. Clone the repository.
2. Build the solution:
```bash
dotnet build
```
3. Use the instructions in the [Development](#development) section to run and test it.

## Development

To test the plugin in a sandbox environment:
Expand Down
17 changes: 9 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ tasks.buildPlugin {

// TODO: See also org.jetbrains.changelog: https://github.com/JetBrains/gradle-changelog-plugin
val changelogText = file("${rootDir}/CHANGELOG.md").readText()
val changelogMatches = Regex("(?s)(-.+?)(?=##|$)").findAll(changelogText)
val changeNotes = changelogMatches.map {
it.groups[1]!!.value.replace("(?s)- ".toRegex(), "\u2022 ").replace("`", "").replace(",", "%2C").replace(";", "%3B")
}.take(1).joinToString()
val latestSection = changelogText.split(Regex("(?m)^## \\[")).drop(1).firstOrNull() ?: ""
val notesContent = latestSection.lines().drop(1).joinToString("\n").trim()

val changeNotes = Regex("(?m)^- (.*)").findAll(notesContent).map {
it.groups[1]!!.value.replace("`", "").replace(",", "%2C").replace(";", "%3B")
}.joinToString("\u2022 ", prefix = "\u2022 ")

val executable: String by setBuildTool.get().extra
val arguments = (setBuildTool.get().extra["args"] as List<String>).toMutableList()
Expand Down Expand Up @@ -158,11 +160,10 @@ tasks.runIde {
tasks.patchPluginXml {
// TODO: See also org.jetbrains.changelog: https://github.com/JetBrains/gradle-changelog-plugin
val changelogText = file("${rootDir}/CHANGELOG.md").readText()
val changelogMatches = Regex("(?s)(-.+?)(?=##|\$)").findAll(changelogText)
val latestSection = changelogText.split(Regex("(?m)^## \\[")).drop(1).firstOrNull() ?: ""
val notesContent = latestSection.lines().drop(1).joinToString("\n").trim()

changeNotes.set(changelogMatches.map {
it.groups[1]!!.value.replace("(?s)\r?\n".toRegex(), "<br />\n")
}.take(1).joinToString())
changeNotes.set(notesContent.replace("(?s)\r?\n".toRegex(), "<br />\n"))
}

tasks.prepareSandbox {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DotnetPluginId=ReSharperPlugin.AutoMapper.FindUsage
DotnetSolution=ReSharperPlugin.AutoMapper.FindUsage.sln
RiderPluginId=me.rogatnev.automapper.findusage
PluginVersion=0.1.1
PluginVersion=0.1.2

BuildConfiguration=Debug

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class AutoMapperNavigationActionAvailabilityTest

[Test] public void TestConfigurationExpression() => DoNamedTest();

[Test] public void TestIgnoreProperty() => DoNamedTest();

[Test] public void TestNotAvailableOnGetter() => DoNamedTest();

[Test] public void TestNotAvailableWithoutMapping() => DoNamedTest();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using AutoMapper;

namespace TestProject;

public class SourceDto
{
public string Name { get; set; }
}

public class DestinationDto
{
public string Name { get; set{off}; }
}

public class TestProfile : Profile
{
public TestProfile()
{
CreateMap<SourceDto, DestinationDto>()
.ForMember(it => it.Name, exp => exp.Ignore());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ private IEnumerable<IntentionAction> CreateBulbItemsInternal()

foreach (var mapping in mappings)
{
if (mapping.IgnoredProperties.Contains(property.ShortName))
continue;

var otherType = mapping.Source;
if (otherType == null) continue;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using JetBrains.ReSharper.Psi;
using JetBrains.ReSharper.Psi.Tree;

Expand All @@ -8,11 +10,14 @@ public sealed class AutoMapperMapping
public IType Source { get; }
public IType Destination { get; }
public ITreeNode Registration { get; }
public ISet<string> IgnoredProperties { get; }

public AutoMapperMapping(IType source, IType destination, ITreeNode registration)
public AutoMapperMapping(IType source, IType destination, ITreeNode registration,
ISet<string> ignoredProperties = null)
{
Source = source;
Destination = destination;
Registration = registration;
IgnoredProperties = ignoredProperties ?? ImmutableHashSet<string>.Empty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public FindExecution Merge(IReference result)
{
if (IsTargetType(tDest, _targetType))
{
var mapping = new AutoMapperMapping(tSource, tDest, invocation);
var ignoredProperties = GetIgnoredProperties(invocation);
var mapping = new AutoMapperMapping(tSource, tDest, invocation, ignoredProperties);
_results.Add(mapping);
}

Expand Down Expand Up @@ -171,4 +172,68 @@ private static bool HasReverseMap(IInvocationExpression invocation)

return false;
}

private static ISet<string> GetIgnoredProperties(IInvocationExpression invocation)
{
var ignoredProperties = new HashSet<string>();

var current = invocation.Parent;
while (current != null)
{
if (current is IInvocationExpression forMemberInvocation &&
forMemberInvocation.InvokedExpression is IReferenceExpression { Reference: var reference } &&
reference.GetName() == "ForMember")
{
if (IsIgnore(forMemberInvocation))
{
var propertyName = GetPropertyName(forMemberInvocation);
if (propertyName != null)
{
ignoredProperties.Add(propertyName);
}
}
}

if (current is IExpressionStatement) break;
current = current.Parent;
}

return ignoredProperties;
}

private static bool IsIgnore(IInvocationExpression forMemberInvocation)
{
// ForMember(it => it.Prop, opt => opt.Ignore())
if (forMemberInvocation.Arguments.Count < 2) return false;

var optArg = forMemberInvocation.Arguments[1].Expression;
if (optArg is ILambdaExpression lambda)
{
var body = lambda.BodyExpression;
// Handle opt => opt.Ignore()
if (body is IInvocationExpression
{
InvokedExpression: IReferenceExpression { Reference: var reference }
} && reference.GetName() == "Ignore")
{
return true;
}
}

return false;
}

private static string GetPropertyName(IInvocationExpression forMemberInvocation)
{
// ForMember(it => it.Prop, ...)
if (forMemberInvocation.Arguments.Count < 1) return null;

var propArg = forMemberInvocation.Arguments[0].Expression;
if (propArg is ILambdaExpression { BodyExpression: IReferenceExpression refExp })
{
return refExp.Reference.GetName();
}

return null;
}
}
2 changes: 1 addition & 1 deletion src/rider/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin require-restart="true">
<id>me.rogatnev.automapper.findusage</id>
<name>AutoMapper.FindUsage</name>
<version>0.1.1</version>
<version>0.1.2</version>
<vendor url="https://github.com/Backs/AutoMapper.FindUsage">Sergey Rogatnev</vendor>
<idea-version since-build="_PLACEHOLDER_" until-build="_PLACEHOLDER_" />
<depends>com.intellij.modules.rider</depends>
Expand Down
Loading