コーディング支援AI「GitHub Copilot Chat」が無償ユーザーにも開放、新しいホームも – 窓の杜
Github Copilot Free版がキタ━(゚∀゚)━! ということで、試してみる(遅いわ)
拡張機能「Github Copilot」を入れて、Ctrl+Shift+PからGenerate Thisを実行。
表示されたダイアログに生成したいコードの内容を記載する
どんなコードが良いんだろうなぁと悩むこと数秒、いくつか試してみる。
〇FizzBuzz
まぁネットにありふれてるから出るわな。
〇テストデータ作成
東京好きすぎん?と思ったら最後の方には他の都道府県も出てた。本当に存在するのかは確認していない。。。
〇Dynamics365のプラグインコード
おぉ、っぽいぽい。
以下出力されたコード全部
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity entity = (Entity)context.InputParameters["Target"];
if (context.MessageName == "Create")
{
if (entity.Contains("customer1") && entity.Contains("customer2"))
{
string customer1 = entity.GetAttributeValue<string>("customer1");
string customer2 = entity.GetAttributeValue<string>("customer2");
entity["customer_code"] = $"{customer1}-{customer2}";
}
}
else if (context.MessageName == "Update")
{
if (entity.Contains("customer_code"))
{
string customerCode = entity.GetAttributeValue<string>("customer_code");
string[] customers = customerCode.Split('-');
if (customers.Length == 2)
{
entity["customer1"] = customers[0];
entity["customer2"] = customers[1];
}
}
}
}
}