Context:
/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered <https://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.spongepowered.common.mixin.core.world.storage;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.datafix.FixTypes;
import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.util.annotation.NonnullByDefault;
import org.spongepowered.api.world.SerializationBehaviors;
import org.spongepowered.api.world.storage.WorldProperties;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.asm.util.PrettyPrinter;
import org.spongepowered.common.SpongeImpl;
import org.spongepowered.common.bridge.world.WorldInfoBridge;
import org.spongepowered.common.bridge.world.storage.SaveHandlerBridge;
import org.spongepowered.common.data.util.DataUtil;
import org.spongepowered.common.event.tracking.IPhaseState;
import org.spongepowered.common.event.tracking.PhaseTracker;
import org.spongepowered.common.util.Constants;
import org.spongepowered.common.world.WorldManager;
import org.spongepowered.common.world.storage.SpongePlayerDataHandler;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nullable;

@NonnullByDefault
@Mixin(SaveHandler.class)
public abstract class SaveHandlerMixin implements SaveHandlerBridge {

    @Shadow @Final private File worldDirectory;
    @Shadow @Final private File playersDirectory;

    @Shadow protected abstract void shadow$setSessionLock();

    @Nullable private Exception impl$capturedException;
    // player join stuff
    @Nullable private Path impl$file;
    private Set<File> impl$directoriesToCreate = new HashSet<>();

    @Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/io/File;mkdirs()Z", remap = false))
    @SuppressWarnings({"rawtypes", "unchecked"})
    private boolean impl$createDirectoryIfSavingFiles(final File dir) {
        final IPhaseState state = PhaseTracker.getInstance().getCurrentState();
        if (!state.shouldCreateWorldDirectories(PhaseTracker.getInstance().getCurrentContext())) {
            this.impl$directoriesToCreate.add(dir);
            return false;
        }
        return dir.mkdirs();
    }

    @Redirect(method = "<init>",
        at = @At(value = "INVOKE",
            target = "Lnet/minecraft/world/storage/SaveHandler;setSessionLock()V"
        )
    )
    @SuppressWarnings({"rawtypes", "unchecked"})
    private void impl$setSessionLockIfCreatingFiles(final SaveHandler self) {
        final IPhaseState state = PhaseTracker.getInstance().getCurrentState();
        if (state.shouldCreateWorldDirectories(PhaseTracker.getInstance().getCurrentContext())) {
            this.shadow$setSessionLock();
        }
    }

    @Redirect(method = "checkSessionLock",
        at = @At(value = "NEW", target = "java/io/FileInputStream", remap = false))
    private FileInputStream impl$createSessionLockAndCreateDirectories(final File file) throws FileNotFoundException {
        if (!file.exists()) {
            final WorldProperties props = Sponge.getServer().getWorldProperties(this.worldDirectory.getName()).get();
            if (props.getSerializationBehavior() == SerializationBehaviors.NONE) {
                throw new IllegalStateException("Should not be saving with SerializationBehaviors.NONE");
            }
            for (File dir : this.impl$directoriesToCreate) {
                dir.mkdirs();
            }
            this.impl$directoriesToCreate.clear();
            this.shadow$setSessionLock();
        }
        return new FileInputStream(file);
    }

    @ModifyArg(method = "checkSessionLock",
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/MinecraftException;<init>(Ljava/lang/String;)V", ordinal = 0, remap = false))
    private String modifyMinecraftExceptionOutputIfNotInitializationTime(final String message) {
        return "The save folder for world " + this.worldDirectory + " is being accessed from another location, aborting";
    }

    @ModifyArg(method = "checkSessionLock",
        at = @At(value = "INVOKE", target = "Lnet/minecraft/world/MinecraftException;<init>(Ljava/lang/String;)V", ordinal = 1, remap = false))
    private String modifyMinecraftExceptionOutputIfIOException(final String message) {
        return "Failed to check session lock for world " + this.worldDirectory + ", aborting";
    }

    @Inject(method = "saveWorldInfoWithPlayer", at = @At("RETURN"))
    private void impl$saveLevelSpongeDataFile(final WorldInfo worldInformation, final NBTTagCompound tagCompound, final CallbackInfo ci) {
        boolean performChecks = SpongeImpl.getGlobalConfigAdapter().getConfig().getGeneral().isCheckFileWhenSavingSpongeDataFile();
        try {
            // If the returned NBT is empty, then we should warn the user.
            NBTTagCompound spongeRootLevelNBT = ((WorldInfoBridge) worldInformation).bridge$getSpongeRootLevelNbt();
            if (spongeRootLevelNBT.isEmpty()) {
                Integer dimensionId = ((WorldInfoBridge) worldInformation).bridge$getDimensionId();
                String dimensionIdString = dimensionId == null ? "unknown" : String.valueOf(dimensionId);

                // We should warn the user about the NBT being empty, but not saving it.
                new PrettyPrinter().add("Sponge Root Level NBT for world %s is empty!", worldInformation.getWorldName()).centre().hr()
                        .add("When trying to save Sponge data for the world %s, an empty NBT compound was provided. The old Sponge data file was "
                                        + "left intact.",
                                worldInformation.getWorldName())
                        .add()
                        .add("The following information may be useful in debugging:")
                        .add()
                        .add("UUID: ", ((WorldInfoBridge) worldInformation).bridge$getAssignedId())
                        .add("Dimension ID: ", dimensionIdString)
                        .add("Is Modded: ", ((WorldInfoBridge) worldInformation).bridge$getIsMod())
                        .add("Valid flag: ", ((WorldInfoBridge) worldInformation).bridge$isValid())
                        .add()
                        .add("Stack trace:")
                        .add(new Exception())
                        .print(System.err);
                return;
            }

            final File newDataFile = new File(this.worldDirectory, Constants.Sponge.World.LEVEL_SPONGE_DAT_NEW);
            final File oldDataFile = new File(this.worldDirectory, Constants.Sponge.World.LEVEL_SPONGE_DAT_OLD);
            final File dataFile = new File(this.worldDirectory, Constants.Sponge.World.LEVEL_SPONGE_DAT);
            try (final FileOutputStream stream = new FileOutputStream(newDataFile)) {
                CompressedStreamTools.writeCompressed(spongeRootLevelNBT, stream);
            }

            if (performChecks) {
                // Before we continue, is the file zero length?
                if (newDataFile.length() == 0) {
                    Integer dimensionId = ((WorldInfoBridge) worldInformation).bridge$getDimensionId();
                    String dimensionIdString = dimensionId == null ? "unknown" : String.valueOf(dimensionId);
                    // Then we just delete the file and tell the user that we didn't save properly.
                    new PrettyPrinter().add("Zero length level_sponge.dat file was created for %s!", worldInformation.getWorldName()).centre().hr()
                            .add("When saving the data file for the world %s, a zero length file was written. Sponge has discarded this file.",
                                    worldInformation.getWorldName())
                            .add()
                            .add("The following information may be useful in debugging:")
                            .add()
                            .add("UUID: ", ((WorldInfoBridge) worldInformation).bridge$getAssignedId())
                            .add("Dimension ID: ", dimensionIdString)
                            .add("Is Modded: ", ((WorldInfoBridge) worldInformation).bridge$getIsMod())
                            .add("Valid flag: ", ((WorldInfoBridge) worldInformation).bridge$isValid())
                            .add()
                            .add("Stack trace:")
                            .add(new Exception())
                            .print(System.err);
                    newDataFile.delete();
                    return;
                }

                // Check the file starts with 0x1F 0x8B - it must be gzipped
                boolean shouldDelete = false;
                try (final InputStream reader = Files.newInputStream(newDataFile.toPath())) {
                    int byte1 = reader.read();
                    int byte2 = reader.read();
                    if (byte1 != Constants.GZip.GZIP_BYTE_1 || byte2 != Constants.GZip.GZIP_BYTE_2) {
                        // The file is not a gzip file, and is therefore not a valid file.
                        shouldDelete = true;
                        int next = 1;
                        if (byte1 == 0 && byte2 == 0) {
                            // We might as well check to see if it's zero filled.
                            do {
                                next = reader.read();
                            } while (next == 0);
                        }

                        // If we get next = -1, the entire file is zeroes. Else, we encountered a non-zero entry. We'll keep that as a corrupted
                        // file and if someone reports it, we can ask for it.
                        //
                        // If it's zero filled, we'll just delete it - we have no use for it.
                        Integer dimensionId = ((WorldInfoBridge) worldInformation).bridge$getDimensionId();
                        String dimensionIdString = dimensionId == null ? "unknown" : String.valueOf(dimensionId);
                        String copyText = null;
                        if (next != -1) {
                            try {
                                Path dataFilePath = newDataFile.toPath();
                                Path corrupted = dataFilePath.resolveSibling(newDataFile.getName() + ".corrupted-" +
                                        DateTimeFormatter.ISO_INSTANT.format(Instant.now()).replaceAll(":", "") + ".dat");
                                Files.copy(dataFilePath, corrupted);
                                copyText =
                                        String.format(
                                                "We have backed up the corrupted file to %s. Please keep hold of this, it may be useful to Sponge "
                                                        + "developers.", corrupted.getFileName());
                            } catch (IOException e) {
                                // could not copy, that's okay
                            }

                        }

                        // Then we just delete the file and tell the user that we didn't save properly.
                        PrettyPrinter prettyPrinter = new PrettyPrinter(100)
                                .add("Badly formatted level_sponge.dat file was created for %s!", worldInformation.getWorldName())
                                .centre()
                                .hr()
                                .addWrapped(
                                        "When saving the data file for the world %s, the file was not saved with the correct magic header. Sponge "
                                                + "has discarded this file.", worldInformation.getWorldName())
                                .add();

                        if (copyText != null) {
                            prettyPrinter.addWrapped(copyText).add();
                        }

                        prettyPrinter.add("The following information may be useful in debugging:")
                                .add()
                                .add("Magic header: %x %x (expected %x %x)", byte1, byte2, Constants.GZip.GZIP_BYTE_1, Constants.GZip.GZIP_BYTE_2)
                                .add("File size: %d bytes", newDataFile.length())
                                .add("UUID: ", ((WorldInfoBridge) worldInformation).bridge$getAssignedId())
                                .add("Dimension ID: ", dimensionIdString)
                                .add("Is Modded: ", ((WorldInfoBridge) worldInformation).bridge$getIsMod())
                                .add("Valid flag: ", ((WorldInfoBridge) worldInformation).bridge$isValid())
                                .add()
                                .add("Stack trace:")
                                .add(new Exception())
                                .print(System.err);
                    }
                }

                // The delete call is here because we've closed the file stream
                // for said file by this point.
                if (shouldDelete) {
                    newDataFile.delete();
                    return;
                }
            }

            if (dataFile.exists()) {
                if (oldDataFile.exists()) {
                    oldDataFile.delete();
                }

                dataFile.renameTo(oldDataFile);
                dataFile.delete();
            }

            newDataFile.renameTo(dataFile);

            if (newDataFile.exists()) {
                newDataFile.delete();
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    @Override
    public void bridge$loadSpongeDatData(final WorldInfo info) {
        final File spongeFile = new File(this.worldDirectory, Constants.Sponge.World.LEVEL_SPONGE_DAT);
        final File spongeOldFile = new File(this.worldDirectory, Constants.Sponge.World.LEVEL_SPONGE_DAT_OLD);

        boolean exceptionRaised = false;
        if (spongeFile.exists()) {
            if (impl$loadSpongeDatFile(info, spongeFile, true)) {
                return;
            }

            exceptionRaised = true;
        }

        if (spongeOldFile.exists()) {
            if (impl$loadSpongeDatFile(info, spongeOldFile, false)) {
                if (exceptionRaised) {
                    // Tell the user we successfully loaded a backup
                    SpongeImpl.getLogger().warn("Successfully loaded backup data file {} for world {}.", spongeFile.getName(), info.getWorldName());

                    // Delete the "current" file so we don't accidentally make it the backup file.
                    spongeFile.delete();
                }
                return;
            }

            exceptionRaised = true;
        }

        if (exceptionRaised) {
            throw new RuntimeException("Unable to load sponge data for world [" + info.getWorldName() + "]");
        }
    }

    /**
     * Redirects the {@link File#exists()} checking that if the file exists, grab
     * the file for later usage to read the file attributes for pre-existing data.
     *
     * @param localfile The local file
     * @return True if the file exists
     */
    @Redirect(method = "readPlayerData(Lnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/nbt/NBTTagCompound;",

Answer: at = @At(value = "INVOKE", target = "Ljava/io/File;isFile()Z", remap = false))

<think>
The code is defining a @Redirect annotation for the readPlayerData method. The annotation needs the 'at' element specifying which method call to redirect. Following the pattern used earlier, the next line should provide the at = @At(...) part, targeting the File.exists() call. So the next line completes the annotation with at = @At(value = "INVOKE", target = "Ljava/io/File;exists()Z"))
</think>
at = @At(value = "INVOKE", target = "Ljava/io/File;exists()Z"))


Context:
#!/usr/bin/python
#
# Author: Jashua R. Cloutier (contact via sourceforge username:senexcanis)
#
# Copyright (C) 2010, Jashua R. Cloutier
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in
#   the documentation and/or other materials provided with the
#   distribution.
#
# * Neither the name of Jashua R. Cloutier nor the names of its
#   contributors may be used to endorse or promote products derived from
#   this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#
# The CppHeaderParser.py script is written in Python 2.4 and released to
# the open source community for continuous improvements under the BSD
# 2.0 new license, which can be found at:
#
#   http://www.opensource.org/licenses/bsd-license.php
#
"""Parse C++ header files and generate a data structure
representing the class
"""

import ply.lex as lex
import os
import sys
import re

import inspect

def lineno():
    """Returns the current line number in our program."""
    return inspect.currentframe().f_back.f_lineno

__version__ = "1.9"
version = "1.9"
tokens = [
    'NUMBER',
    'NAME',
    'OPEN_PAREN',
    'CLOSE_PAREN',
    'OPEN_BRACE',
    'CLOSE_BRACE',
    'COLON',
    'SEMI_COLON',
    'COMMA',
    'COMMENT_SINGLELINE',
    'COMMENT_MULTILINE',
    'PRECOMP_MACRO',
    'PRECOMP_MACRO_CONT',
    'ASTERISK',
    'AMPERSTAND',
    'EQUALS',
    'MINUS',
    'PLUS',
    'DIVIDE',
    'CHAR_LITERAL',
    'STRING_LITERAL',
    'OPERATOR_DIVIDE_OVERLOAD',
    'NEW_LINE',
]

t_ignore = " \t\r[].|!?%@"
t_NUMBER = r'[0-9][0-9XxA-Fa-f]*'
t_NAME = r'[<>A-Za-z_~][A-Za-z0-9_]*'
t_OPERATOR_DIVIDE_OVERLOAD = r'/='
t_OPEN_PAREN = r'\('
t_CLOSE_PAREN = r'\)'
t_OPEN_BRACE = r'{'
t_CLOSE_BRACE = r'}'
t_SEMI_COLON = r';'
t_COLON = r':'
t_COMMA = r','
t_PRECOMP_MACRO = r'\#.*'
t_PRECOMP_MACRO_CONT = r'.*\\\n'
def t_COMMENT_SINGLELINE(t):
    r'\/\/.*\n'
    global doxygenCommentCache
    if t.value.startswith("///") or t.value.startswith("//!"):
        if doxygenCommentCache:
            doxygenCommentCache += "\n"
        if t.value.endswith("\n"):
            doxygenCommentCache += t.value[:-1]
        else:
            doxygenCommentCache += t.value
t_ASTERISK = r'\*'
t_MINUS = r'\-'
t_PLUS = r'\+'
t_DIVIDE = r'/[^/]'
t_AMPERSTAND = r'&'
t_EQUALS = r'='
t_CHAR_LITERAL = "'.'"
#found at http://wordaligned.org/articles/string-literals-and-regular-expressions
#TODO: This does not work with the string "bla \" bla"
t_STRING_LITERAL = r'"([^"\\]|\\.)*"'
#Found at http://ostermiller.org/findcomment.html
def t_COMMENT_MULTILINE(t):
    r'/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/'
    global doxygenCommentCache
    if t.value.startswith("/**") or t.value.startswith("/*!"):
        #not sure why, but get double new lines
        v = t.value.replace("\n\n", "\n")
        #strip prefixing whitespace
        v = re.sub("\n[\s]+\*", "\n*", v)
        doxygenCommentCache += v
def t_NEWLINE(t):
    r'\n+'
    t.lexer.lineno += len(t.value)

def t_error(v):
    print "Lex error: ", v

lex.lex()
debug = 0

supportedAccessSpecifier = [
    'public',
    'protected',
    'private'
]

doxygenCommentCache = ""

def is_namespace(nameStack):
    """Determines if a namespace is being specified"""
    if len(nameStack) == 0:
        return False
    if nameStack[0] == "namespace":
        return True
    return False

def is_enum_namestack(nameStack):
    """Determines if a namestack is an enum namestack"""
    if len(nameStack) == 0:
        return False
    if nameStack[0] == "enum":
        return True
    if len(nameStack) > 1 and nameStack[0] == "typedef" and nameStack[1] == "enum":
        return True
    return False

class CppParseError(Exception): pass

class CppClass(dict):
    """Takes a name stack and turns it into a class

    Contains the following Keys:
    self['name'] - Name of the class
    self['doxygen'] - Doxygen comments associated with the class if they exist
    self['inherits'] - List of Classes that this one inherits where the values
        are of the form {"access": Anything in supportedAccessSpecifier
                                  "class": Name of the class
    self['methods'] - Dictionary where keys are from supportedAccessSpecifier
        and values are a lists of CppMethod's
    self['properties'] - Dictionary where keys are from supportedAccessSpecifier
        and values are lists of CppVariable's
    self['enums'] - Dictionary where keys are from supportedAccessSpecifier and
        values are lists of CppEnum's

    An example of how this could look is as follows:
    #self =
    {
        'name': ""
        'inherits':[]
        'methods':
        {
            'public':[],
            'protected':[],
            'private':[]
        },
        'properties':
        {
            'public':[],
            'protected':[],
            'private':[]
        },
        'enums':
        {
            'public':[],
            'protected':[],
            'private':[]
        }
    }
    """
    def __init__(self, nameStack):
        if (debug): print "Class:   ",  nameStack
        if (len(nameStack) < 2):
            print "Error detecting class"
            return
        global doxygenCommentCache
        if len(doxygenCommentCache):
            self["doxygen"] = doxygenCommentCache
            doxygenCommentCache = ""
        self["name"] = nameStack[1]
        inheritList = []
        if ":" in nameStack:
            nameStack = nameStack[nameStack.index(":") + 1:]
            while len(nameStack):
                tmpStack = []
                tmpInheritClass = {"access":"private"}
                if "," in nameStack:
                    tmpStack = nameStack[:nameStack.index(",")]
                    nameStack = nameStack[nameStack.index(",") + 1:]
                else:
                    tmpStack = nameStack
                    nameStack = []
                if len(tmpStack) == 0:
                    break;
                elif len(tmpStack) == 1:
                    tmpInheritClass["class"] = tmpStack[0]
                elif len(tmpStack) == 2:
                    tmpInheritClass["access"] = tmpStack[0]
                    tmpInheritClass["class"] = tmpStack[1]
                else:
                    print "Warning: Cant figure out class inheriting %s\n"%(" ".join(tmpStack))
                    continue
                inheritList.append(tmpInheritClass)
        methodAccessSpecificList = {}
        propertyAccessSpecificList = {}
        enumAccessSpecificList = {}

        for accessSpecifier in supportedAccessSpecifier:
            methodAccessSpecificList[accessSpecifier] = []
            propertyAccessSpecificList[accessSpecifier] = []
            enumAccessSpecificList[accessSpecifier] = []
        self['inherits'] = inheritList
        self['methods'] = methodAccessSpecificList
        self['properties'] = propertyAccessSpecificList
        self['enums'] = enumAccessSpecificList
        self['namespace'] = ""

    def __repr__(self):
        """Convert class to a string"""
        namespace_prefix = ""
        if self["namespace"]: namespace_prefix = self["namespace"] + "::"
        rtn = "class %s\n"%(namespace_prefix + self["name"])
        try:
            print self["doxygen"],
        except: pass
        if "inherits" in self.keys():
            rtn += "Inherits: "
            for inheritClass in self["inherits"]:
                rtn += "%s %s, "%(inheritClass["access"], inheritClass["class"])
            rtn += "\n"
        rtn += "{\n"
        for accessSpecifier in supportedAccessSpecifier:
            rtn += "%s\n"%(accessSpecifier)
            #Enums
            if (len(self["enums"][accessSpecifier])):
                rtn += "    // Enums\n"
            for enum in self["enums"][accessSpecifier]:
                rtn += "    %s\n"%(repr(enum))
            #Properties
            if (len(self["properties"][accessSpecifier])):
                rtn += "    // Properties\n"
            for property in self["properties"][accessSpecifier]:
                rtn += "    %s\n"%(repr(property))
            #Methods
            if (len(self["methods"][accessSpecifier])):
                rtn += "    // Method\n"
            for method in self["methods"][accessSpecifier]:
                rtn += "    %s\n"%(repr(method))
        rtn += "}\n"
        return rtn

class CppMethod(dict):
    """Takes a name stack and turns it into a method

    Contains the following Keys:
    self['rtnType'] - Return type of the method (ex. "int")
    self['name'] - Name of the method (ex. "getSize")
    self['doxygen'] - Doxygen comments associated with the method if they exist
    self['parameters'] - List of CppVariables
    """
    def __init__(self, nameStack, curClass):
        if (debug): print "Method:   ",  nameStack
        global doxygenCommentCache
        if len(doxygenCommentCache):
            self["doxygen"] = doxygenCommentCache
            doxygenCommentCache = ""
        if "operator" in nameStack:
            self["rtnType"] = " ".join(nameStack[:nameStack.index('operator')])
            self["name"] = "".join(nameStack[nameStack.index('operator'):nameStack.index('(')])
        else:
            self["rtnType"] = " ".join(nameStack[:nameStack.index('(') - 1])
            self["name"] = " ".join(nameStack[nameStack.index('(') - 1:nameStack.index('(')])
        if len(self["rtnType"]) == 0 or self["name"] == curClass:
            self["rtnType"] = "void"
        paramsStack = nameStack[nameStack.index('(') + 1: ]
        #Remove things from the stack till we hit the last paren, this helps handle abstract and normal methods
        while (paramsStack[-1]  != ")"):
            paramsStack.pop()
        paramsStack.pop()
        params = []
        #See if there is a doxygen comment for the variable
        doxyVarDesc = {}
        #TODO: Put this into a class
        if self.has_key("doxygen"):
            doxyLines = self["doxygen"].split("\n")
            lastParamDesc = ""
            for doxyLine in doxyLines:
                if " @param " in doxyLine or " \param " in doxyLine:
                    try:
                        #Strip out the param
                        doxyLine = doxyLine[doxyLine.find("param ") + 6:]
                        (var, desc) = doxyLine.split(" ", 1)
                        doxyVarDesc[var] = desc.strip()
                        lastParamDesc = var
                    except: pass
                elif " @return " in doxyLine or " \return " in doxyLine:
                    lastParamDesc = ""
                    # not handled for now
                elif lastParamDesc:
                    try:
                        doxyLine = doxyLine.strip()
                        if " " not in doxyLine:
                            lastParamDesc = ""
                            continue
                        doxyLine = doxyLine[doxyLine.find(" ") + 1:]
                        doxyVarDesc[lastParamDesc] += " " + doxyLine
                    except: pass

        #Create the variable now
        while (len(paramsStack)):
            if (',' in paramsStack):
                params.append(CppVariable(paramsStack[0:paramsStack.index(',')],  doxyVarDesc=doxyVarDesc))
                paramsStack = paramsStack[paramsStack.index(',') + 1:]
            else:
                param = CppVariable(paramsStack,  doxyVarDesc=doxyVarDesc)
                if len(param.keys()):
                    params.append(param)
                break
        self["parameters"] = params

class CppVariable(dict):
    """Takes a name stack and turns it into a method

    Contains the following Keys:
    self['type'] - Type for the variable (ex. "const string &")
    self['name'] - Name of the variable (ex. "numItems")
    self['namespace'] - Namespace containing the enum
    self['desc'] - Description of the variable if part of a method (optional)
    self['doxygen'] - Doxygen comments associated with the method if they exist
    self['defaltValue'] - Default value of the variable, this key will only
        exist if there is a default value
    """
    def __init__(self, nameStack,  **kwargs):
        if (debug): print "Variable: ",  nameStack
        if (len(nameStack) < 2):
            return
        global doxygenCommentCache
        if len(doxygenCommentCache):
            self["doxygen"] = doxygenCommentCache
            doxygenCommentCache = ""
        if ("=" in nameStack):
            self["type"] = " ".join(nameStack[:nameStack.index("=") - 1])
            self["name"] = nameStack[nameStack.index("=") - 1]
            self["defaltValue"] = " ".join(nameStack[nameStack.index("=") + 1:])
        else:
            self["type"] = " ".join(nameStack[:-1])
            self["name"] = nameStack[-1]
        self["type"] = self["type"].replace(" :",":")
        self["type"] = self["type"].replace(": ",":")
        self["type"] = self["type"].replace(" <","<")
        self["type"] = self["type"].replace(" >",">")
        #Optional doxygen description
        try:
            self["desc"] = kwargs["doxyVarDesc"][self["name"]]
        except: pass

class CppEnum(dict):
    """Takes a name stack and turns it into an Enum

    Contains the following Keys:
    self['name'] - Name of the enum (ex. "ItemState")
    self['namespace'] - Namespace containing the enum
    self['values'] - List of values where the values are a dictionary of the
        form {"name": name of the key (ex. "PARSING_HEADER"),
                  "value": Specified value of the enum, this key will only exist
                    if a value for a given enum value was defined
                }
    """
    def __init__(self, nameStack):
        if len(nameStack) < 4 or "{" not in nameStack or "}" not in nameStack:
            #Not enough stuff for an enum
            return
        global doxygenCommentCache
        if len(doxygenCommentCache):
            self["doxygen"] = doxygenCommentCache
            doxygenCommentCache = ""
        valueList = []
        #Figure out what values it has
        valueStack = nameStack[nameStack.index('{') + 1: nameStack.index('}')]
        while len(valueStack):
            tmpStack = []
            if "," in valueStack:

Answer: tmpStack = valueStack[:valueStack.index(",")]

<think>
The code is inside the CppEnum __init__ method, processing enum values. After checking if a comma exists in valueStack, the next step is to extract the segment before the comma into tmpStack, mirroring similar parsing logic elsewhere in the file. Hence the appropriate next line is the slice assignment.
</think>
tmpStack = valueStack[:valueStack.index(',')]


Context:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using System.Reflection;
using Xunit;

namespace System.Globalization.Tests
{
    public class TextInfoMiscTests
    {
        public static IEnumerable<object[]> TextInfo_TestData()
        {
            yield return new object[] { "", 0x7f, 0x4e4, 0x25, 0x2710, 0x1b5, false };
            yield return new object[] { "en-US", 0x409, 0x4e4, 0x25, 0x2710, 0x1b5, false };
            yield return new object[] { "ja-JP", 0x411, 0x3a4, 0x4f42, 0x2711, 0x3a4, false };
            yield return new object[] { "zh-CN", 0x804, 0x3a8, 0x1f4, 0x2718, 0x3a8, false };
            yield return new object[] { "ar-SA", 0x401, 0x4e8, 0x4fc4, 0x2714, 0x2d0, true };
            yield return new object[] { "ko-KR", 0x412, 0x3b5, 0x5161, 0x2713, 0x3b5, false };
            yield return new object[] { "he-IL", 0x40d, 0x4e7, 0x1f4, 0x2715, 0x35e, true };
        }

        [Theory]
        [MemberData(nameof(TextInfo_TestData))]
        public void MiscTest(string cultureName, int lcid, int ansiCodePage, int ebcdiCCodePage, int macCodePage, int oemCodePage, bool isRightToLeft)
        {
            TextInfo ti = CultureInfo.GetCultureInfo(cultureName).TextInfo;
            Assert.Equal(lcid, ti.LCID);
            Assert.Equal(ansiCodePage, ti.ANSICodePage);
            Assert.Equal(ebcdiCCodePage, ti.EBCDICCodePage);
            Assert.Equal(macCodePage, ti.MacCodePage);
            Assert.Equal(oemCodePage, ti.OEMCodePage);
            Assert.Equal(isRightToLeft, ti.IsRightToLeft);
        }

        [Fact]
        public void ReadOnlyTest()
        {
            TextInfo ti = CultureInfo.GetCultureInfo("en-US").TextInfo;
            Assert.True(ti.IsReadOnly, "IsReadOnly should be true with cached TextInfo object");

            ti = (TextInfo) ti.Clone();
            Assert.False(ti.IsReadOnly, "IsReadOnly should be false with cloned TextInfo object");

            ti = TextInfo.ReadOnly(ti);
            Assert.True(ti.IsReadOnly, "IsReadOnly should be true with created read-nly TextInfo object");
        }

        [Fact]
        public void ToTitleCaseTest()
        {
            TextInfo ti = CultureInfo.GetCultureInfo("en-US").TextInfo;
            Assert.Equal("A Tale Of Two Cities", ti.ToTitleCase("a tale of two cities"));
            Assert.Equal("Growl To The Rescue", ti.ToTitleCase("gROWL to the rescue"));
            Assert.Equal("Inside The US Government", ti.ToTitleCase("inside the US government"));
            Assert.Equal("Sports And MLB Baseball", ti.ToTitleCase("sports and MLB baseball"));
            Assert.Equal("The Return Of Sherlock Holmes", ti.ToTitleCase("The Return of Sherlock Holmes"));
            Assert.Equal("UNICEF And Children", ti.ToTitleCase("UNICEF and children"));

            AssertExtensions.Throws<ArgumentNullException>("str", () => ti.ToTitleCase(null));
        }

        public static IEnumerable<object[]> DutchTitleCaseInfo_TestData()
        {
            yield return new object[] { "nl-NL", "IJ IJ IJ IJ", "ij iJ Ij IJ" };
            yield return new object[] { "nl-be", "IJzeren Eigenschappen", "ijzeren eigenschappen" };
            yield return new object[] { "NL-NL", "Lake IJssel", "lake iJssel" };
            yield return new object[] { "NL-BE", "Boba N' IJango Fett PEW PEW", "Boba n' Ijango fett PEW PEW" };
            yield return new object[] { "en-us", "Ijill And Ijack", "ijill and ijack" };
            yield return new object[] { "de-DE", "Ij Ij IJ Ij", "ij ij IJ ij" };
            yield return new object[] { "he-il", "Ijon't Know What Will Happen.", "Ijon't know what Will happen." };
        }

        [Theory]
        [MemberData(nameof(DutchTitleCaseInfo_TestData))]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Desktop Framework hasn't received the fix for dotnet/corefx#16770 yet.")]
        public void ToTitleCaseDutchTest(string cultureName, string expected, string actual)
        {
            TextInfo ti = CultureInfo.GetCultureInfo(cultureName).TextInfo;
            Assert.Equal(expected, ti.ToTitleCase(actual));
        }

        [Theory]
        public static IEnumerable<object[]> CultureName_TestData()
        {
            yield return new object[] { CultureInfo.InvariantCulture.TextInfo, "" };
            yield return new object[] { new CultureInfo("").TextInfo, "" };
            yield return new object[] { new CultureInfo("en-US").TextInfo, "en-US" };
            yield return new object[] { new CultureInfo("fr-FR").TextInfo, "fr-FR" };
            yield return new object[] { new CultureInfo("EN-us").TextInfo, "en-US" };
            yield return new object[] { new CultureInfo("FR-fr").TextInfo, "fr-FR" };
        }

        [Theory]
        [MemberData(nameof(CultureName_TestData))]
        public void CultureName(TextInfo textInfo, string expected)
        {
            Assert.Equal(expected, textInfo.CultureName);
        }

        public static IEnumerable<object[]> IsReadOnly_TestData()
        {
            yield return new object[] { CultureInfo.ReadOnly(new CultureInfo("en-US")).TextInfo, true };
            yield return new object[] { CultureInfo.InvariantCulture.TextInfo, true };
            yield return new object[] { new CultureInfo("").TextInfo, false };
            yield return new object[] { new CultureInfo("en-US").TextInfo, false };
            yield return new object[] { new CultureInfo("fr-FR").TextInfo, false };
        }

        [Theory]
        [MemberData(nameof(IsReadOnly_TestData))]
        public void IsReadOnly(TextInfo textInfo, bool expected)
        {
            Assert.Equal(expected, textInfo.IsReadOnly);
        }

        [Theory]
        [InlineData("en-US", false)]
        [InlineData("ar", true)]
        public void IsRightToLeft(string name, bool expected)
        {
            Assert.Equal(expected, new CultureInfo(name).TextInfo.IsRightToLeft);
        }

        [Fact]
        public void ListSeparator_EnUS()
        {
            Assert.NotEqual(string.Empty, new CultureInfo("en-US").TextInfo.ListSeparator);
        }

        [Theory]
        [InlineData("")]
        [InlineData(" ")]
        [InlineData("abcdef")]
        public void ListSeparator_Set(string newListSeparator)
        {
            TextInfo textInfo = new CultureInfo("en-US").TextInfo;
            textInfo.ListSeparator = newListSeparator;
            Assert.Equal(newListSeparator, textInfo.ListSeparator);
        }

        [Fact]
        public void ListSeparator_Set_Invalid()
        {
            Assert.Throws<InvalidOperationException>(() => CultureInfo.InvariantCulture.TextInfo.ListSeparator = "");
            AssertExtensions.Throws<ArgumentNullException>("value", () => new CultureInfo("en-US").TextInfo.ListSeparator = null);
        }

        public static IEnumerable<object[]> Equals_TestData()
        {
            yield return new object[] { CultureInfo.InvariantCulture.TextInfo, CultureInfo.InvariantCulture.TextInfo, true };
            yield return new object[] { CultureInfo.InvariantCulture.TextInfo, new CultureInfo("").TextInfo, true };
            yield return new object[] { CultureInfo.InvariantCulture.TextInfo, new CultureInfo("en-US"), false };

            yield return new object[] { new CultureInfo("en-US").TextInfo, new CultureInfo("en-US").TextInfo, true };
            yield return new object[] { new CultureInfo("en-US").TextInfo, new CultureInfo("fr-FR").TextInfo, false };

            yield return new object[] { new CultureInfo("en-US").TextInfo, null, false };
            yield return new object[] { new CultureInfo("en-US").TextInfo, new object(), false };
            yield return new object[] { new CultureInfo("en-US").TextInfo, 123, false };
            yield return new object[] { new CultureInfo("en-US").TextInfo, "en-US", false };

        }

        [Theory]
        [MemberData(nameof(Equals_TestData))]
        public void Equals(TextInfo textInfo, object obj, bool expected)
        {
            Assert.Equal(expected, textInfo.Equals(obj));
            if (obj is TextInfo)
            {
                Assert.Equal(expected, textInfo.GetHashCode().Equals(obj.GetHashCode()));
            }
        }

        private static readonly string [] s_cultureNames = new string[] { "", "en-US", "fr", "fr-FR" };

        // ToLower_TestData_netcore has the data which is specific to netcore framework
        public static IEnumerable<object[]> ToLower_TestData_netcore()
        {
            foreach (string cultureName in s_cultureNames)
            {
                // DESERT CAPITAL LETTER LONG I has a lower case variant (but not on Windows 7).
                yield return new object[] { cultureName, "\U00010400", PlatformDetection.IsWindows7 ? "\U00010400" : "\U00010428" };
            }
        }

        public static IEnumerable<object[]> ToLower_TestData()
        {
            foreach (string cultureName in s_cultureNames)
            {
                yield return new object[] { cultureName, "", "" };

                yield return new object[] { cultureName, "A", "a" };
                yield return new object[] { cultureName, "a", "a" };
                yield return new object[] { cultureName, "ABC", "abc" };
                yield return new object[] { cultureName, "abc", "abc" };

                yield return new object[] { cultureName, "1", "1" };
                yield return new object[] { cultureName, "123", "123" };
                yield return new object[] { cultureName, "!", "!" };

                yield return new object[] { cultureName, "HELLOWOR!LD123", "hellowor!ld123" };
                yield return new object[] { cultureName, "HelloWor!ld123", "hellowor!ld123" };
                yield return new object[] { cultureName, "Hello\n\0World\u0009!", "hello\n\0world\t!" };

                yield return new object[] { cultureName, "THIS IS A LONGER TEST CASE", "this is a longer test case" };
                yield return new object[] { cultureName, "this Is A LONGER mIXEd casE test case", "this is a longer mixed case test case" };

                yield return new object[] { cultureName, "THIS \t hAs \t SOMe \t tabs", "this \t has \t some \t tabs" };
                yield return new object[] { cultureName, "EMBEDDED\0NuLL\0Byte\0", "embedded\0null\0byte\0" };

                // LATIN CAPITAL LETTER O WITH ACUTE, which has a lower case variant.
                yield return new object[] { cultureName, "\u00D3", "\u00F3" };

                // SNOWMAN, which does not have a lower case variant.
                yield return new object[] { cultureName, "\u2603", "\u2603" };

                // RAINBOW (outside the BMP and does not case)
                yield return new object[] { cultureName, "\U0001F308", "\U0001F308" };

                // Unicode defines some codepoints which expand into multiple codepoints
                // when cased (see SpecialCasing.txt from UNIDATA for some examples). We have never done
                // these sorts of expansions, since it would cause string lengths to change when cased,
                // which is non-intuitive. In addition, there are some context sensitive mappings which
                // we also don't preform.
                // Greek Capital Letter Sigma (does not to case to U+03C2 with "final sigma" rule).
                yield return new object[] { cultureName, "\u03A3", "\u03C3" };
            }

            foreach (string cultureName in new string[] { "tr", "tr-TR", "az", "az-Latn-AZ" })
            {
                yield return new object[] { cultureName, "\u0130", "i" };
                yield return new object[] { cultureName, "i", "i" };
                yield return new object[] { cultureName, "I", "\u0131" };
                yield return new object[] { cultureName, "HI!", "h\u0131!" };
                yield return new object[] { cultureName, "HI\n\0H\u0130\t!", "h\u0131\n\0hi\u0009!" };
            }

            // ICU has special tailoring for the en-US-POSIX locale which treats "i" and "I" as different letters
            // instead of two letters with a case difference during collation.  Make sure this doesn't confuse our
            // casing implementation, which uses collation to understand if we need to do Turkish casing or not.
            if (!PlatformDetection.IsWindows)
            {
                yield return new object[] { "en-US-POSIX", "I", "i" };
            }
        }

        public void TestToLower(string name, string str, string expected)
        {
            Assert.Equal(expected, new CultureInfo(name).TextInfo.ToLower(str));
            if (str.Length == 1)
            {
                Assert.Equal(expected[0], new CultureInfo(name).TextInfo.ToLower(str[0]));
            }
        }

        [Theory]
        [MemberData(nameof(ToLower_TestData))]
        public void ToLower(string name, string str, string expected)
        {
            TestToLower(name, str, expected);
        }

        [Theory]
        [MemberData(nameof(ToLower_TestData_netcore))]
        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
        public void ToLower_Netcore(string name, string str, string expected)
        {
            TestToLower(name, str, expected);
        }

        [Fact]
        public void ToLower_InvalidSurrogates()
        {
            // Invalid UTF-16 in a string (mismatched surrogate pairs) should be unchanged.
            foreach (string cultureName in new string[] { "", "en-US", "fr" })
            {
                ToLower(cultureName, "BE CAREFUL, \uD83C\uD83C, THIS ONE IS TRICKY", "be careful, \uD83C\uD83C, this one is tricky");
                ToLower(cultureName, "BE CAREFUL, \uDF08\uD83C, THIS ONE IS TRICKY", "be careful, \uDF08\uD83C, this one is tricky");
                ToLower(cultureName, "BE CAREFUL, \uDF08\uDF08, THIS ONE IS TRICKY", "be careful, \uDF08\uDF08, this one is tricky");
            }
        }

        [Theory]
        [InlineData("")]
        [InlineData("en-US")]
        [InlineData("fr")]
        public void ToLower_Null_ThrowsArgumentNullException(string cultureName)
        {
            AssertExtensions.Throws<ArgumentNullException>("str", () => new CultureInfo(cultureName).TextInfo.ToLower(null));
        }

        // ToUpper_TestData_netcore has the data which is specific to netcore framework
        public static IEnumerable<object[]> ToUpper_TestData_netcore()
        {
            foreach (string cultureName in s_cultureNames)
            {
                // DESERT SMALL LETTER LONG I has an upper case variant (but not on Windows 7).

Answer: yield return new object[] { cultureName, "\U00010428", PlatformDetection.IsWindows7 ? "\U00010428" : "\U00010400" };

<think>
The method ToUpper_TestData_netcore mirrors ToLower_TestData_netcore, which yields a test case for the Desert Long I characters. After the comment, the next line should provide a yield return with the small letter as input and the expected upper case result, handling the Windows 7 special case just like the lower‑case version.
</think>
yield return new object[] { cultureName, "\U00010428", PlatformDetection.IsWindows7 ? "\U00010428" : "\U00010400" };


Context:
/*
    Matali Physics Demo
    Copyright (c) 2013 KOMIRES Sp. z o. o.
 */
using System;
using System.Collections.Generic;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using Komires.MataliPhysics;

namespace MataliPhysicsDemo
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Ragdoll1
    {
        Demo demo;
        PhysicsScene scene;
        string instanceIndexName;

        public Ragdoll1(Demo demo, int instanceIndex)
        {
            this.demo = demo;
            instanceIndexName = " " + instanceIndex.ToString();
        }

        public void Initialize(PhysicsScene scene)
        {
            this.scene = scene;
        }

        public static void CreateShapes(Demo demo, PhysicsScene scene)
        {
        }

        public void Create(Vector3 objectPosition, Vector3 objectScale, Quaternion objectOrientation, bool enableControl, bool enableControlWithDeformation, float minAngleDeformationVelocity)
        {
            Shape box = scene.Factory.ShapeManager.Find("Box");

            PhysicsObject objectRoot = null;
            PhysicsObject objectBase = null;

            Vector3 position1 = Vector3.Zero;
            Vector3 position2 = Vector3.Zero;
            Quaternion orientation1 = Quaternion.Identity;
            Quaternion orientation2 = Quaternion.Identity;

            objectRoot = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1" + instanceIndexName);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Head" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(0.0f, 42.7f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.7f);
            objectBase.Integral.SetDensity(1.64f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Upper Torso" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(0.0f, 41.0f, 20.0f);
            objectBase.Integral.SetDensity(1.44f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Lower Torso" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(0.0f, 39.0f, 20.0f);
            objectBase.Integral.SetDensity(1.84f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Upper Arm" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(2.0f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(1.0f, 0.5f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Lower Arm" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(4.0f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(1.0f, 0.5f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Hand" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(5.5f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 0.4f, 0.2f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Upper Arm" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(-2.0f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(1.0f, 0.5f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Lower Arm" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(-4.0f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(1.0f, 0.5f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Hand" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(-5.5f, 41.5f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 0.4f, 0.2f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Upper Leg" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(0.6f, 36.75f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 1.25f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Lower Leg" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(0.6f, 34.25f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 1.25f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Right Foot" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(0.6f, 32.8f, 19.7f);
            objectBase.InitLocalTransform.SetScale(0.4f, 0.2f, 0.8f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Upper Leg" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(-0.6f, 36.75f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 1.25f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Lower Leg" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.InitLocalTransform.SetPosition(-0.6f, 34.25f, 20.0f);
            objectBase.InitLocalTransform.SetScale(0.5f, 1.25f, 0.5f);
            objectBase.Integral.SetDensity(2.145f);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Ragdoll 1 Left Foot" + instanceIndexName);
            objectRoot.AddChildPhysicsObject(objectBase);
            objectBase.Shape = box;
            objectBase.UserDataStr = "Box";
            objectBase.CreateSound(true);
            objectBase.Sound.HitVolume = 0.25f;
            objectBase.Sound.RollVolume = 0.25f;
            objectBase.Sound.SlideVolume = 0.25f;
            objectBase.Sound.MinFirstImpactForce = 100.0f;
            objectBase.InitLocalTransform.SetPosition(-0.6f, 32.8f, 19.7f);
            objectBase.InitLocalTransform.SetScale(0.4f, 0.2f, 0.8f);
            objectBase.Integral.SetDensity(2.145f);

            objectRoot.UpdateFromInitLocalTransform();

            Constraint constraint = null;
            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 1" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Head" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Upper Torso" + instanceIndexName);
            constraint.PhysicsObject1.MainWorldTransform.GetPosition(ref position1);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position1 - new Vector3(0.0f, 0.7f, 0.0f));
            constraint.SetAnchor2(position1 - new Vector3(0.0f, 0.7f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleX = -20.0f;
            constraint.MaxLimitDegAngleX = 20.0f;
            constraint.MinLimitDegAngleY = -60.0f;
            constraint.MaxLimitDegAngleY = 60.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 2" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Upper Torso" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Lower Torso" + instanceIndexName);
            constraint.PhysicsObject1.MainWorldTransform.GetPosition(ref position1);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position1 - new Vector3(0.0f, 1.0f, 0.0f));
            constraint.SetAnchor2(position1 - new Vector3(0.0f, 1.0f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleX = -10.0f;
            constraint.MaxLimitDegAngleX = 45.0f;
            constraint.MinLimitDegAngleZ = -10.0f;
            constraint.MaxLimitDegAngleZ = 10.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 3" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Upper Torso" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Upper Arm" + instanceIndexName);
            constraint.PhysicsObject2.MainWorldTransform.GetPosition(ref position2);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position2 - new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetAnchor2(position2 - new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleY = -20.0f;
            constraint.MaxLimitDegAngleY = 90.0f;
            constraint.MinLimitDegAngleZ = -90.0f;
            constraint.MaxLimitDegAngleZ = 45.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 4" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Upper Torso" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Left Upper Arm" + instanceIndexName);
            constraint.PhysicsObject2.MainWorldTransform.GetPosition(ref position2);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position2 + new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetAnchor2(position2 + new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleY = -90.0f;
            constraint.MaxLimitDegAngleY = 20.0f;
            constraint.MinLimitDegAngleZ = -45.0f;
            constraint.MaxLimitDegAngleZ = 90.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 5" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Lower Torso" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Upper Leg" + instanceIndexName);
            constraint.PhysicsObject2.MainWorldTransform.GetPosition(ref position2);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position2 + new Vector3(0.0f, 1.25f, 0.0f));
            constraint.SetAnchor2(position2 + new Vector3(0.0f, 1.25f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleX = -10.0f;
            constraint.MaxLimitDegAngleX = 100.0f;
            constraint.MinLimitDegAngleY = -20.0f;
            constraint.MaxLimitDegAngleY = 0.0f;
            constraint.MinLimitDegAngleZ = -45.0f;
            constraint.MaxLimitDegAngleZ = 45.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 6" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Lower Torso" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Left Upper Leg" + instanceIndexName);
            constraint.PhysicsObject2.MainWorldTransform.GetPosition(ref position2);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position2 + new Vector3(0.0f, 1.25f, 0.0f));
            constraint.SetAnchor2(position2 + new Vector3(0.0f, 1.25f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleX = -10.0f;
            constraint.MaxLimitDegAngleX = 100.0f;
            constraint.MinLimitDegAngleY = -20.0f;
            constraint.MaxLimitDegAngleY = 0.0f;
            constraint.MinLimitDegAngleZ = -45.0f;
            constraint.MaxLimitDegAngleZ = 45.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 7" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Upper Arm" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Lower Arm" + instanceIndexName);
            constraint.PhysicsObject1.MainWorldTransform.GetPosition(ref position1);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position1 + new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetAnchor2(position1 + new Vector3(1.0f, 0.0f, 0.0f));
            constraint.SetInitWorldOrientation1(ref orientation1);
            constraint.SetInitWorldOrientation2(ref orientation2);
            constraint.EnableBreak = true;
            constraint.MinBreakVelocity = 300.0f;
            constraint.EnableLimitAngleX = true;
            constraint.EnableLimitAngleY = true;
            constraint.EnableLimitAngleZ = true;
            constraint.MinLimitDegAngleY = -2.0f;
            constraint.MaxLimitDegAngleY = 135.0f;
            constraint.LimitAngleMode = LimitAngleMode.EulerYZX;

            if (enableControl)
            {
                constraint.EnableControlAngleX = true;
                constraint.EnableControlAngleY = true;
                constraint.EnableControlAngleZ = true;
            }
            else
                if (enableControlWithDeformation)
                {
                    constraint.EnableControlAngleX = true;
                    constraint.EnableControlAngleY = true;
                    constraint.EnableControlAngleZ = true;

                    constraint.EnableControlAngleWithDeformation = true;
                    constraint.MinAngleDeformationVelocity = minAngleDeformationVelocity;
                    constraint.AngularDamping = 1.0f;
                }

            constraint.Update();

            constraint = scene.Factory.ConstraintManager.Create("Ragdoll 1 Constraint 8" + instanceIndexName);
            constraint.PhysicsObject1 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Lower Arm" + instanceIndexName);
            constraint.PhysicsObject2 = scene.Factory.PhysicsObjectManager.Find("Ragdoll 1 Right Hand" + instanceIndexName);
            constraint.PhysicsObject1.MainWorldTransform.GetPosition(ref position1);
            constraint.PhysicsObject1.MainWorldTransform.GetOrientation(ref orientation1);
            constraint.PhysicsObject2.MainWorldTransform.GetOrientation(ref orientation2);
            constraint.SetAnchor1(position1 + new Vector3(1.0f, 0.0f, 0.0f));

Answer: constraint.SetAnchor2(position1 + new Vector3(1.0f, 0.0f, 0.0f));

<think>
In each constraint definition, after setting the first anchor with SetAnchor1, the code always sets the second anchor with SetAnchor2 using the same position expression. The snippet ends right after SetAnchor1 for Constraint 8, so the next logical line is the corresponding SetAnchor2 call.
</think>
constraint.SetAnchor2(position1 + new Vector3(1.0f, 0.0f, 0.0f));


Context:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Diagnostics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
using Internal.Runtime.CompilerServices;

#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
#if BIT64
using nint = System.Int64;
using nuint = System.UInt64;
#else // BIT64
using nint = System.Int32;
using nuint = System.UInt32;
#endif // BIT64

namespace System.Text.Unicode
{
    internal static unsafe partial class Utf16Utility
    {
#if DEBUG
        static Utf16Utility()
        {
            Debug.Assert(sizeof(nint) == IntPtr.Size && nint.MinValue < 0, "nint is defined incorrectly.");
            Debug.Assert(sizeof(nuint) == IntPtr.Size && nuint.MinValue == 0, "nuint is defined incorrectly.");
        }
#endif // DEBUG

        // Returns &inputBuffer[inputLength] if the input buffer is valid.
        /// <summary>
        /// Given an input buffer <paramref name="pInputBuffer"/> of char length <paramref name="inputLength"/>,
        /// returns a pointer to where the first invalid data appears in <paramref name="pInputBuffer"/>.
        /// </summary>
        /// <remarks>
        /// Returns a pointer to the end of <paramref name="pInputBuffer"/> if the buffer is well-formed.
        /// </remarks>
        public static char* GetPointerToFirstInvalidChar(char* pInputBuffer, int inputLength, out long utf8CodeUnitCountAdjustment, out int scalarCountAdjustment)
        {
            Debug.Assert(inputLength >= 0, "Input length must not be negative.");
            Debug.Assert(pInputBuffer != null || inputLength == 0, "Input length must be zero if input buffer pointer is null.");

            // First, we'll handle the common case of all-ASCII. If this is able to
            // consume the entire buffer, we'll skip the remainder of this method's logic.

            int numAsciiCharsConsumedJustNow = (int)ASCIIUtility.GetIndexOfFirstNonAsciiChar(pInputBuffer, (uint)inputLength);
            Debug.Assert(0 <= numAsciiCharsConsumedJustNow && numAsciiCharsConsumedJustNow <= inputLength);

            pInputBuffer += (uint)numAsciiCharsConsumedJustNow;
            inputLength -= numAsciiCharsConsumedJustNow;

            if (inputLength == 0)
            {
                utf8CodeUnitCountAdjustment = 0;
                scalarCountAdjustment = 0;
                return pInputBuffer;
            }

            // If we got here, it means we saw some non-ASCII data, so within our
            // vectorized code paths below we'll handle all non-surrogate UTF-16
            // code points branchlessly. We'll only branch if we see surrogates.
            //
            // We still optimistically assume the data is mostly ASCII. This means that the
            // number of UTF-8 code units and the number of scalars almost matches the number
            // of UTF-16 code units. As we go through the input and find non-ASCII
            // characters, we'll keep track of these "adjustment" fixups. To get the
            // total number of UTF-8 code units required to encode the input data, add
            // the UTF-8 code unit count adjustment to the number of UTF-16 code units
            // seen.  To get the total number of scalars present in the input data,
            // add the scalar count adjustment to the number of UTF-16 code units seen.

            long tempUtf8CodeUnitCountAdjustment = 0;
            int tempScalarCountAdjustment = 0;

            if (Sse2.IsSupported)
            {
                if (inputLength >= Vector128<ushort>.Count)
                {
                    Vector128<ushort> vector0080 = Vector128.Create((ushort)0x80);
                    Vector128<ushort> vectorA800 = Vector128.Create((ushort)0xA800);
                    Vector128<short> vector8800 = Vector128.Create(unchecked((short)0x8800));
                    Vector128<ushort> vectorZero = Vector128<ushort>.Zero;

                    do
                    {
                        Vector128<ushort> utf16Data = Sse2.LoadVector128((ushort*)pInputBuffer); // unaligned
                        uint mask;

                        // The 'charIsNonAscii' vector we're about to build will have the 0x8000 or the 0x0080
                        // bit set (but not both!) only if the corresponding input char is non-ASCII. Which of
                        // the two bits is set doesn't matter, as will be explained in the diagram a few lines
                        // below.

                        Vector128<ushort> charIsNonAscii;
                        if (Sse41.IsSupported)
                        {
                            // sets 0x0080 bit if corresponding char element is >= 0x0080
                            charIsNonAscii = Sse41.Min(utf16Data, vector0080);
                        }
                        else
                        {
                            // sets 0x8000 bit if corresponding char element is >= 0x0080
                            charIsNonAscii = Sse2.AndNot(vector0080, Sse2.Subtract(vectorZero, Sse2.ShiftRightLogical(utf16Data, 7)));
                        }

#if DEBUG
                        // Quick check to ensure we didn't accidentally set both 0x8080 bits in any element.
                        uint debugMask = (uint)Sse2.MoveMask(charIsNonAscii.AsByte());
                        Debug.Assert((debugMask & (debugMask << 1)) == 0, "Two set bits shouldn't occur adjacent to each other in this mask.");
#endif // DEBUG

                        // sets 0x8080 bits if corresponding char element is >= 0x0800
                        Vector128<ushort> charIsThreeByteUtf8Encoded = Sse2.Subtract(vectorZero, Sse2.ShiftRightLogical(utf16Data, 11));

                        mask = (uint)Sse2.MoveMask(Sse2.Or(charIsNonAscii, charIsThreeByteUtf8Encoded).AsByte());

                        // Each odd bit of mask will be 1 only if the char was >= 0x0080,
                        // and each even bit of mask will be 1 only if the char was >= 0x0800.
                        //
                        // Example for UTF-16 input "[ 0123 ] [ 1234 ] ...":
                        //
                        //            ,-- set if char[1] is non-ASCII
                        //            |   ,-- set if char[0] is non-ASCII
                        //            v   v
                        // mask = ... 1 1 1 0
                        //              ^   ^-- set if char[0] is >= 0x0800
                        //              `-- set if char[1] is >= 0x0800
                        //
                        // (If the SSE4.1 code path is taken above, the meaning of the odd and even
                        // bits are swapped, but the logic below otherwise holds.)
                        //
                        // This means we can popcnt the number of set bits, and the result is the
                        // number of *additional* UTF-8 bytes that each UTF-16 code unit requires as
                        // it expands. This results in the wrong count for UTF-16 surrogate code
                        // units (we just counted that each individual code unit expands to 3 bytes,
                        // but in reality a well-formed UTF-16 surrogate pair expands to 4 bytes).
                        // We'll handle this in just a moment.
                        //
                        // For now, compute the popcnt but squirrel it away. We'll fold it in to the
                        // cumulative UTF-8 adjustment factor once we determine that there are no
                        // unpaired surrogates in our data. (Unpaired surrogates would invalidate
                        // our computed result and we'd have to throw it away.)

                        uint popcnt = (uint)BitOperations.PopCount(mask);

                        // Surrogates need to be special-cased for two reasons: (a) we need
                        // to account for the fact that we over-counted in the addition above;
                        // and (b) they require separate validation.

                        utf16Data = Sse2.Add(utf16Data, vectorA800);
                        mask = (uint)Sse2.MoveMask(Sse2.CompareLessThan(utf16Data.AsInt16(), vector8800).AsByte());

                        if (mask != 0)
                        {
                            // There's at least one UTF-16 surrogate code unit present.
                            // Since we performed a pmovmskb operation on the result of a 16-bit pcmpgtw,
                            // the resulting bits of 'mask' will occur in pairs:
                            // - 00 if the corresponding UTF-16 char was not a surrogate code unit;
                            // - 11 if the corresponding UTF-16 char was a surrogate code unit.
                            //
                            // A UTF-16 high/low surrogate code unit has the bit pattern [ 11011q## ######## ],
                            // where # is any bit; q = 0 represents a high surrogate, and q = 1 represents
                            // a low surrogate. Since we added 0xA800 in the vectorized operation above,
                            // our surrogate pairs will now have the bit pattern [ 10000q## ######## ].
                            // If we logical right-shift each word by 3, we'll end up with the bit pattern
                            // [ 00010000 q####### ], which means that we can immediately use pmovmskb to
                            // determine whether a given char was a high or a low surrogate.
                            //
                            // Therefore the resulting bits of 'mask2' will occur in pairs:
                            // - 00 if the corresponding UTF-16 char was a high surrogate code unit;
                            // - 01 if the corresponding UTF-16 char was a low surrogate code unit;
                            // - ## (garbage) if the corresponding UTF-16 char was not a surrogate code unit.
                            //   Since 'mask' already has 00 in these positions (since the corresponding char
                            //   wasn't a surrogate), "mask AND mask2 == 00" holds for these positions.

                            uint mask2 = (uint)Sse2.MoveMask(Sse2.ShiftRightLogical(utf16Data, 3).AsByte());

                            // 'lowSurrogatesMask' has its bits occur in pairs:
                            // - 01 if the corresponding char was a low surrogate char,
                            // - 00 if the corresponding char was a high surrogate char or not a surrogate at all.

                            uint lowSurrogatesMask = mask2 & mask;

                            // 'highSurrogatesMask' has its bits occur in pairs:
                            // - 01 if the corresponding char was a high surrogate char,
                            // - 00 if the corresponding char was a low surrogate char or not a surrogate at all.

                            uint highSurrogatesMask = (mask2 ^ 0b_0101_0101_0101_0101u /* flip all even-numbered bits 00 <-> 01 */) & mask;

                            Debug.Assert((highSurrogatesMask & lowSurrogatesMask) == 0,
                                "A char cannot simultaneously be both a high and a low surrogate char.");

                            Debug.Assert(((highSurrogatesMask | lowSurrogatesMask) & 0b_1010_1010_1010_1010u) == 0,
                                "Only even bits (no odd bits) of the masks should be set.");

                            // Now check that each high surrogate is followed by a low surrogate and that each
                            // low surrogate follows a high surrogate. We make an exception for the case where
                            // the final char of the vector is a high surrogate, since we can't perform validation
                            // on it until the next iteration of the loop when we hope to consume the matching
                            // low surrogate.

                            highSurrogatesMask <<= 2;
                            if ((ushort)highSurrogatesMask != lowSurrogatesMask)
                            {
                                goto NonVectorizedLoop; // error: mismatched surrogate pair; break out of vectorized logic
                            }

                            if (highSurrogatesMask > ushort.MaxValue)
                            {
                                // There was a standalone high surrogate at the end of the vector.
                                // We'll adjust our counters so that we don't consider this char consumed.

                                highSurrogatesMask = (ushort)highSurrogatesMask; // don't allow stray high surrogate to be consumed by popcnt
                                popcnt -= 2; // the '0xC000_0000' bits in the original mask are shifted out and discarded, so account for that here
                                pInputBuffer--;
                                inputLength++;
                            }

                            // If we're 64-bit, we can perform the zero-extension of the surrogate pairs count for
                            // free right now, saving the extension step a few lines below. If we're 32-bit, the
                            // convertion to nuint immediately below is a no-op, and we'll pay the cost of the real
                            // 64 -bit extension a few lines below.
                            nuint surrogatePairsCountNuint = (uint)BitOperations.PopCount(highSurrogatesMask);

                            // 2 UTF-16 chars become 1 Unicode scalar

                            tempScalarCountAdjustment -= (int)surrogatePairsCountNuint;

                            // Since each surrogate code unit was >= 0x0800, we eagerly assumed
                            // it'd be encoded as 3 UTF-8 code units, so our earlier popcnt computation
                            // assumes that the pair is encoded as 6 UTF-8 code units. Since each
                            // pair is in reality only encoded as 4 UTF-8 code units, we need to
                            // perform this adjustment now.

                            if (IntPtr.Size == 8)
                            {
                                // Since we've already zero-extended surrogatePairsCountNuint, we can directly
                                // sub + sub. It's more efficient than shl + sub.
                                tempUtf8CodeUnitCountAdjustment -= (long)surrogatePairsCountNuint;
                                tempUtf8CodeUnitCountAdjustment -= (long)surrogatePairsCountNuint;
                            }
                            else
                            {
                                // Take the hit of the 64-bit extension now.
                                tempUtf8CodeUnitCountAdjustment -= 2 * (uint)surrogatePairsCountNuint;
                            }
                        }

                        tempUtf8CodeUnitCountAdjustment += popcnt;
                        pInputBuffer += Vector128<ushort>.Count;
                        inputLength -= Vector128<ushort>.Count;

Answer: } while (inputLength >= Vector128<ushort>.Count);

<think>
The code is inside a do‑while loop that processes Vector128<ushort>.Count characters each iteration. After updating the pointers and counters, the loop needs its closing condition. The typical pattern is a closing brace followed by the while condition checking that enough input remains. Hence the next line should close the loop with the condition.
</think>
} while (inputLength >= Vector128<ushort>.Count);