• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Create C# nested files in Visual Studio

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,483
Баллы
155
Introduction


Microsoft Visual Studio supports

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, which are usually appsettings.json. Other file types are supported by creating a file named .filenesting.json in the root of a C# project.

Example


In the Models folder, a Person class is a partial class separated into three files.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



To nest the three files created in the root folder of the project a file named nesting.json as shown below.


{
"help": "

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

",
"root": true,
"dependentFileProviders": {
"add": {
"fileToFile": {
"add": {
"Person.Notification.cs": [
"Person.cs"
],
"Person.Sets.cs": [
"Person.cs"
]
}
}
}
}
}




Note the organization for each node: a class file with the base file name, a descriptor, and an extension, followed by the base file name. The results are shown below.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Using Copilot prompt files to create .filenesting.json


By creating a

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

Copilot can create a nesting file.

For this example partial classes are targeted under the Models folder.


  • Under the root folder of the Visual Studio solution, add a file named NestedPartialClasses.prompt.md under the folder .github\prompts (see example in provided source code)


  • Add the following instructions
  1. If there is a Models folder find all partial classes in it.
  2. Collect each partial class files
  3. Create in the root folder of the current project a file named .filenesting.json
  4. In this file, create a JSON structure that nests all the partial class files under their main class file. The main class file will have a single period in the file name.
  • Open Copilot Chat window.
    • Select Agent mode
    • Select the project
    • Select the prompt file
    • Select press enter

Copilot reads the prompt file instructions and executes. Once finished, accept the new file if it is correct, which it should be. Examine that the class is now nested under Solution Explorer.

Chat window targeting the project PromptFilesExampleApp1.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



If the partial classes are in a different folder, adjust the instructions in the prompt file.

Source code



Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



  • Prompt file: Solution root folder .github\prompts\NestedPartialClasses.prompt.md
  • Sample project: PromptFilesExamplesApp1

✔ Note the following in the project file for permitting the use of the field keyword.


<LangVersion>preview</LangVersion>



Источник:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу