Table of Contents

Class StringResourceReferencePatterns

Namespace
GroupeIsa.Neos.Shared.Localization
Assembly
GroupeIsa.Neos.Shared.dll

Provides the regex patterns and access-class prefixes used to locate string resource references in client C# code and UI templates. Shared between the generator's reference validation and the designer's find-usages/rename feature.

public static class StringResourceReferencePatterns
Inheritance
StringResourceReferencePatterns
Inherited Members

Fields

ApplicationPrefix

The access-class prefix for application-layer resources.

public const string ApplicationPrefix = "AppResources"

Field Value

string

CodeReferencePattern

Pattern matching a resource reference in C# code. Group 1 captures "Prefix.Module.Name".

public const string CodeReferencePattern = "((?<![A-Za-z0-9_.])(?:Resources|AppResources|UIResources)\\.(?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))"

Field Value

string

DomainPrefix

The access-class prefix for domain-layer resources.

public const string DomainPrefix = "Resources"

Field Value

string

FrontendPrefix

The access-class prefix for frontend-scoped resources.

public const string FrontendPrefix = "UIResources"

Field Value

string

TemplateReferencePattern

Pattern matching a resource reference in a UI template. Group 1 captures "Module.Name".

public const string TemplateReferencePattern = "\\@Resources\\.((?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))"

Field Value

string

Methods

CreateCodeReferenceRegex()

[GeneratedRegex("((?<![A-Za-z0-9_.])(?:Resources|AppResources|UIResources)\\.(?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))")]
public static Regex CreateCodeReferenceRegex()

Returns

Regex

Remarks

Pattern:

((?<![A-Za-z0-9_.])(?:Resources|AppResources|UIResources)\\.(?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))

Explanation:
○ 1st capture group.
    ○ Zero-width negative lookbehind.
        ○ Match a character in the set [.0-9A-Z_a-z] right-to-left.
    ○ Match with 3 alternative expressions.
        ○ Match the string "Resources".
        ○ Match the string "AppResources".
        ○ Match the string "UIResources".
    ○ Match '.'.
    ○ Match a character in the set [A-Z_a-z].
    ○ Match a character in the set [0-9A-Z_a-z] atomically any number of times.
    ○ Match '.'.
    ○ Match a character in the set [A-Z_a-z].
    ○ Match a character in the set [0-9A-Z_a-z] atomically any number of times.

CreateTemplateReferenceRegex()

[GeneratedRegex("\\@Resources\\.((?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))")]
public static Regex CreateTemplateReferenceRegex()

Returns

Regex

Remarks

Pattern:

\\@Resources\\.((?:[A-Za-z_][A-Za-z0-9_]*\\.[A-Za-z_][A-Za-z0-9_]*))

Explanation:
○ Match the string "@Resources.".
○ 1st capture group.
    ○ Match a character in the set [A-Z_a-z].
    ○ Match a character in the set [0-9A-Z_a-z] atomically any number of times.
    ○ Match '.'.
    ○ Match a character in the set [A-Z_a-z].
    ○ Match a character in the set [0-9A-Z_a-z] atomically any number of times.