Yerel işlevlerlerde özniteliklerAttributes on local functions

ÖzniteliklerAttributes

Yerel işlev bildirimlerinin artık özniteliklereizin veriliyor.Local function declarations are now permitted to have attributes. Yerel işlevlerde parametre ve tür parametrelerinin de özniteliklere sahip olmasına izin verilir.Parameters and type parameters on local functions are also allowed to have attributes.

Bir yönteme uygulandığında belirtilen anlamı olan öznitelikler, parametreleri veya tür parametreleri yerel bir işleve, parametrelerine veya tür parametrelerine uygulandığında aynı anlama sahip olacaktır.Attributes with a specified meaning when applied to a method, its parameters, or its type parameters will have the same meaning when applied to a local function, its parameters, or its type parameters, respectively.

Yerel bir işlev, koşullu bir yöntem ile aynı anlamda, bir ile süsleyerek koşullu hale getirilebilir [ConditionalAttribute] .A local function can be made conditional in the same sense as a conditional method by decorating it with a [ConditionalAttribute]. Koşullu bir yerel işlev de olmalıdır static .A conditional local function must also be static. Koşullu yöntemlerle ilgili tüm kısıtlamalar, dönüş türü olması da dahil olmak üzere koşullu yerel işlevler için de geçerlidir void .All restrictions on conditional methods also apply to conditional local functions, including that the return type must be void.

DışExtern

externDeğiştiriciye artık yerel işlevlerde izin verilir.The extern modifier is now permitted on local functions. Bu, yerel işlevi dış bir yöntemleaynı anlamda harici hale getirir.This makes the local function external in the same sense as an external method.

Harici bir yönteme benzer şekilde, dış yerel işlevin yerel işlev gövdesi noktalı virgül olmalıdır.Similarly to an external method, the local-function-body of an external local function must be a semicolon. Noktalı virgülle yerel işlev gövdesine yalnızca dış yerel işlevde izin verilir.A semicolon local-function-body is only permitted on an external local function.

Dış yerel işlev de olmalıdır static .An external local function must also be static.

SyntaxSyntax

Yerel işlevlerin dil bilgisi aşağıdaki şekilde değiştirilmiştir:The local functions grammar is modified as follows:

local-function-header
    : attributes? local-function-modifiers? return-type identifier type-parameter-list?
        ( formal-parameter-list? ) type-parameter-constraints-clauses
    ;

local-function-modifiers
    : (async | unsafe | static | extern)*
    ;

local-function-body
    : block
    | arrow-expression-body
    | ';'
    ;