Skip to content

Commit

Permalink
Add RegexGenerator to System.ComponentModel.TypeConverter. (#62325)
Browse files Browse the repository at this point in the history
* Add RegGen to System.ComponentModel.TypeConverter.

Added to src, not to test (no test found)

* Change to targets generator enablement

* Correct RegGen for System.ComponentModel.TypeConverter

* Remove extra space

Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com>

* Remove .NetF inclusion definition

* Remove implicit regex generator entrypoint

* Remove regex generator enabled variable target.

* Update eng/generators.targets

Co-authored-by: kasperk81 <83082615+kasperk81@users.noreply.github.com>
Co-authored-by: Jose Perez Rodriguez <joperezr@microsoft.com>
  • Loading branch information
3 people committed Feb 24, 2022
1 parent 6cc999f commit a06befc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
13 changes: 13 additions & 0 deletions eng/generators.targets
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@
and @(ProjectReference->AnyHaveMetadataValue('Identity', '$(CoreLibProject)'))))" Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\ArrayMarshaller.cs" />
</ItemGroup>

<ItemGroup>
<EnabledGenerators Include="RegexGenerator" Condition="'$(EnableRegexGenerator)' == 'true'" />
</ItemGroup>

<!-- Use this complex ItemGroup-based filtering to add the ProjectReference to make sure dotnet/runtime stays compatible with NuGet Static Graph Restore. -->
<ItemGroup Condition="'@(EnabledGenerators)' != ''
and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'RegexGenerator'))">
<ProjectReference
Include="$(LibrariesProjectRoot)System.Text.RegularExpressions/gen/System.Text.RegularExpressions.Generator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false" />
</ItemGroup>

<Target Name="ConfigureGenerators"
DependsOnTargets="ConfigureDllImportGenerator"
BeforeTargets="CoreCompile" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<IsPartialFacadeAssembly>true</IsPartialFacadeAssembly>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<Nullable>enable</Nullable>
<EnableRegexGenerator>true</EnableRegexGenerator>
</PropertyGroup>
<ItemGroup>
<ILLinkSubstitutionsXmls Include="$(ILLinkDirectory)ILLink.Substitutions.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ namespace System.ComponentModel.Design
/// <summary>
/// Represents a verb that can be executed by a component's designer.
/// </summary>
public class DesignerVerb : MenuCommand
public partial class DesignerVerb : MenuCommand
{
/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerVerb'/> class.
/// </summary>
public DesignerVerb(string text, EventHandler handler) : base(handler, StandardCommands.VerbFirst)
{
Properties["Text"] = text == null ? null : Regex.Replace(text, @"\(\&.\)", "");
}
public DesignerVerb(string text, EventHandler handler) : this(text, handler, StandardCommands.VerbFirst) { }

/// <summary>
/// Initializes a new instance of the <see cref='System.ComponentModel.Design.DesignerVerb'/>
/// class.
/// </summary>
public DesignerVerb(string text, EventHandler handler, CommandID startCommandID) : base(handler, startCommandID)
{
Properties["Text"] = text == null ? null : Regex.Replace(text, @"\(\&.\)", "");
Properties["Text"] = text == null ? null : GetParameterReplacementRegex().Replace(text, "");
}

[RegexGenerator(@"\(\&.\)")]
private static partial Regex GetParameterReplacementRegex();

/// <summary>
/// Gets or sets the description of the menu item for the verb.
/// </summary>
Expand Down

0 comments on commit a06befc

Please sign in to comment.