Have the Roslyn Weaver to be more intelligent around surrounding code marked for Ignore
Intent has a way to tell the Roslyn Weaver not to overwrite methods during code generation runs which is very useful. It would also be useful to be able to target certain symbols not to be overwritten as well such as certain strings:
static class TeamIds
{
<# foreach (var team in DataSeedHelper.GetTeams(_metaDataManager, Project)) { #>
[IntentManaged(Mode.Ignore)]
public static readonly Guid <#= team.IdGuid #> = new Guid("<#= Guid.NewGuid().ToString() #>");
<# } #>
}
In this example I am getting the desired effect I'm looking for. Intent is generating the field once-off and applying a new Guid to the value of the field.
But when I try to apply comments to this field, it won't add them because (I suspect) the Ignore tag is preventing it.
So maybe a way around this would be to apply an Ignore tag on the symbol itself rather than the entire field or to have another way to specify how to handle comments instead:
static class TeamIds
{
<# foreach (var team in DataSeedHelper.GetTeams(_metaDataManager, Project)) { #>
/// <summary>
/// <#= team.Name #>
/// </summary>
public static readonly Guid <#= team.IdGuid #> = new Guid([IntentManaged(Mode.Ignore)]"<#= Guid.NewGuid().ToString() #>");
<# } #>
}
OR
static class TeamIds
{
<# foreach (var team in DataSeedHelper.GetTeams(_metaDataManager, Project)) { #>
/// <summary>
/// <#= team.Name #>
/// </summary>
[IntentManaged(Mode.Ignore, Comments = Mode.Fully)]
public static readonly Guid <#= team.IdGuid #> = new Guid("<#= Guid.NewGuid().ToString() #>");
<# } #>
}
I am not sure what the best way is to resolve this but I hope that we can figure something out in this ticket.
For the time being I'm opting for this "workaround":
static class TeamIds
{
<# foreach (var team in DataSeedHelper.GetTeams(_metaDataManager, Project)) { #>
/// <summary>
/// <#= team.Name #>
/// </summary>
public static Guid <#= team.IdGuid #> { get { return _<#= team.IdGuid #>; } }
<# } #>
<# foreach (var team in DataSeedHelper.GetTeams(_metaDataManager, Project)) { #>
[IntentManaged(Mode.Ignore)]
private static readonly Guid _<#= team.IdGuid #> = new Guid("<#= Guid.NewGuid().ToString() #>");
<# } #>
}
EDIT: Sorry, I realized that it doesn't seem possible to apply Attributes in C# outside of signature definitions, so I guess that option is out. However, I'm leaving it there for the idea to persist in coming to a solution.