Category Archives: .NET

Announcing WinUI 3 Preview 2

At our monthly community call this morning we announced that a new preview of WinUI 3 is ready for you all to try out – WinUI 3 Preview 2! If you’re too excited to read ahead, check out the release notes here. WinUI 3 Preview 2 was a quality and stability-driven release. It builds directly […]

情報源: Announcing WinUI 3 Preview 2 – Windows Developer Blog

MEMO.

A deep-dive into WinUI 3 in desktop apps – Windows Developer Blog

XAML Islands was our first solution to enable developers to use UWP XAML inside their desktop (Win32) apps. Within a couple of months after the release of XAML Islands, behavioral insights and customer interviews raised some signals about how developers were using it. We discovered that a significant number of apps were using XAML for […]

情報源: A deep-dive into WinUI 3 in desktop apps – Windows Developer Blog

MEMO.

EPPlusがVer.5からLGPLでは無くなり商用は有償に

情報源: Excel spreadsheet library for .NET Framework/Core – EPPlus Software

xlsxファイルを操作するためのライブラリであるEPPlusがVer.5からLGPLでは無く、商用有償ライセンスと非商用無償ライセンスの二本立てになっていました。

C#: Code DomainでRoslynコンパイラを使用する

CodeDomで新しいコンパイラを使用したい!

GitHub – aspnet/RoslynCodeDomProvider: Roslyn CodeDOM provider

NuGet packages · dotnet/roslyn Wiki · GitHub(RoslynのバージョンとC#バージョンとの対応)

C# コンパイラを使用してプログラムによってコードをコンパイルする方法

上のサンプルをRoslyn CodeDom providerを使用するように変更した。

using System;
using System.Drawing;
using System.Windows.Forms;
using System.CodeDom.Compiler;
using System.Diagnostics;

namespace CodeDomainSample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            //Roslynを使用したCodeDomainProviderを使用する。
            CodeDomProvider codeProvider = new Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider();
            string Output = "Out.exe";
            Button ButtonObject = (Button)sender;

            textBox2.Text = "";
            System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
            //Make sure we generate an EXE, not a DLL
            parameters.GenerateExecutable = true;
            parameters.OutputAssembly = Output;
            parameters.CompilerOptions = "-langversion:7.3"; // C#のバージョンを指定する。
            CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, textBox1.Text);

            if (results.Errors.Count > 0)
            {
                textBox2.ForeColor = Color.Red;
                foreach (CompilerError CompErr in results.Errors)
                {
                    textBox2.Text = textBox2.Text +
                                "Line number " + CompErr.Line +
                                ", Error Number: " + CompErr.ErrorNumber +
                                ", '" + CompErr.ErrorText + ";" +
                                Environment.NewLine + Environment.NewLine;
                }
            }
            else
            {
                //Successful Compile
                textBox2.ForeColor = Color.Blue;
                textBox2.Text = "Success!";
                //If we clicked run then launch our EXE
                if (ButtonObject.Text == "Run") Process.Start(Output);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button1_Click(sender, e);
        }
    }

}

Nullable Reference Types: Contexts and Attributes – A Look at New Language Features in C# 8 – .NET Tools Blog.NET Tools Blog

Our C# 8 language features series is coming to an end. Before we jump into nullable contexts and nullable attributes, here is a quick (updated) recap of our roadmap: Indices, Ranges, and Null-coalescing Assignments Switch Expressions and Pattern-Based Usings Recursive … Continue reading →

情報源: Nullable Reference Types: Contexts and Attributes – A Look at New Language Features in C# 8 – .NET Tools Blog.NET Tools Blog

メモ。

Nullable Reference TypesはC#8.0で追加されました。これは将来のC#でのNull全面不許可への第一歩です。Nullable Reference TypesはNull全面不許可における例外を設けるために作られたものです。なので、古いクラスライブラリなどどうしようも無い部分はあるのですが、C#erは極力Nullを避けるコーディング習慣を身につけるように努力した方が良いと思います。

build 2020 – The Journey to One .NET

Join us for the Microsoft Build 48-hour, digital event to expand your skillset, find technical solutions, and innovate for the challenges of tomorrow.

情報源: MyBuild – The Journey to One .NET

集中力無くて、見切れなかったので、あとで見るメモ。