윈도우 앱개발을 향하여

블로그 이미지
윈도우 10 스토어에 앱을 개발해 올리는 것을 목표로 하고 있습니다. 비전공자가 독학으로 시도하는 일이어서 얼마나 걸릴지 모르겠지만... 아무튼 목표는 그렇습니다!!
by 코딩하는 경제학도
  • Total hit
  • Today hit
  • Yesterday hit

'Programming'에 해당되는 글 45건

  1. 2017.12.08
    (XAML)Panels and the Layout System
  2. 2017.12.07
    (XAML)Control Basics and Interaction with them
  3. 2017.12.07
    (XAML)Basic elements
  4. 2017.12.03
    .Net ecosystem
  5. 2017.03.02
    1장 C#과 .NET Framework 소개

Copyright

이 모든 내용은 Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 4번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 강의 원작자분께 게시허가도 받았습니다.





Panels (<-- FrameworkElement)

Panels allow us to arrange a group of child elements in simple to very complex layouts.


Responsible for laying out its children

The type of Panel defines how they are arranged

Has a Children property of type UIElementCollection which contains a collection of UIElements


Commonly used Panels : Canvas, StackPanel, Grid, RelativePanel



Canvas  

Used to explicitly position children elements by coordinates relative to the Canvas area.

But the absolute positioning means it's not so good for scaling.

Canvas doesn't have concept of docking controls next to each other => 겹쳐진다.

Therefore the ZIndex exist.



StackPanel

Used to arrange children into a single line, horizontally or vertically



Grid

Defines a flexible grid area consisting of rows and columns

RowDefinition, ColumnDefinition can has absolute size, star size, and Auto

ColumnSpan, RowSpan makes a control span across row and column boundaries 



RelativePanel (생략)



A Step Back to the FrameworkElement (<-- UIElement <-- DependencyObject)

FrameworkElement...

potentially participates in layout and should have a display area in the app UI

Adds Height, Width, Alignment and Margin properties

Supports DataContext

(http://empisterian.tistory.com/9)



Width and Height


HorizontalAlignment / VerticalAlignment

Defines how the element is horizontally / vertically aligned within a parent element's allocated layout space

Valid values are Left, Right, Center, Stretch


Margin



Describes the distance between an element and its child or peers

OUTSIDE of the element, and Margin is of type Thickness (left, top, bottom, right)





Padding

Padding is a bit of a special case. This property is not defined on FrameworkElement, it's only exposed on a few classes, primarily as a convenience where it makes sense. Block, Border, Control, and TextBlock etc


Unlike Margin, this actually enlarges the size of an element by the provided Thickness

INSIDE of the element, and Padding is of type Thickness (left, top, bottom, right)


(setting padding makes the element larger this time the arrows show the applied padding values)




An Important Concept : The Visual Tree


The visual tree는 object tree의 특수한 형태다(An object tree is a conceptualization of how objects that are created and exist at runtime are related to each other). The visual tree is a filter on the object tree, rendering implication을 포함한 object만이 visual tree에 포함된다. Every element type that has a rendering implication is part of the visual tree, and an element does not show up on screen until it's in a rendered visual tree. 

The visual tree can be seen as a scene  graph, containing all the rendering information needed to compose the output to the display device. 

Visual tree determines the rendering order. The order of traversal starts with the root visual, which is the top-most node in the visual tree.


ex <StackPanel>

 <Button>

<TextBlock Text="Hi there!"/>    ==visual tree==>   StackPanel => Button => ContentPresenter => TextBlock

 </Button>

</StackPanel>


ContentPresenter is a parent of TextBlock (not a Button), ContenPresenter takes part in the visual layout cycle, so part of the visual tree.

(ControlTemplate (inside of Button.Template) for a Button containing the ContentPresenter)



The Layout System 

Ensures elements are sized, positioned and drawn, recursively.

The visual tree determines the rendering order, and layout system is the process of measuring and arranging the members of a layout panel's children collection(Panel에 children이 많을수록 많은 계산이 필요하다. 게다가 Panel has a specific behavior. Canvas는 상대적으로 쉽지만(but), take for example a grid, which sets into place in the grid according to Grid.Row Grid.RowSpan, Grid.Column, and Grid.ColumnSpan attached properties. The size of one of the children is one of the things that can determine the size of the parent and the position of the next child.)


1. Each child UIElement is measured using core properties(like clip, visibility). (First part of Measure Pass a constraint size)

2. Sizing properties are defined on FrameworkElement like Width, Height, and Margin are evaluated. (Second part of Measure Pass)

Typically this property is described as sizing characteristics of the underlying UIElement and they can thus change the space necessary to display the element. The ultimate goal of this pass is for the child to determine its desired size.)

3. Panel-specific logic is applied (such as stacking orientation for StackPanel)

4. Content arranged after all children are measured. (Arrange Pass)

This can be different from desired size as additional margins may affect the finally-rendered size of the element. The arrange size is passed back to the parent panel, which them generates the final size of the child.

5. Children drawn to screen

6. Process possibly invoked again (go to 1)


More detail in XAML Layout in Depth


Summary (생략)


출처

이 모든 내용은 Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 4번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 최종 Summary는 생략하겠습니다. Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.

'Programming > XAML' 카테고리의 다른 글

(XAML)Using Resources and Styling Controls  (0) 2017.12.12
(XAML)Working with ItemsControls  (0) 2017.12.11
(XAML)Data Binding Essentials  (0) 2017.12.10
(XAML)Control Basics and Interaction with them  (0) 2017.12.07
(XAML)Basic elements  (0) 2017.12.07
AND

Copyright

이 모든 내용은 Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 세번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 강의 원작자분께 게시허가도 받았습니다.




Control

Behavior : what it does

ControlTemplate : how it looks


ControlTemplate = template property of Control

ControlTemplate consists of basic element like Shapes, or consists of other controls who have templates of their own, etc


Some Classes and Controls are in the primitive namespace. These primitives often don't make sense on their own. Primitive can be both controls that are uses as part of a control, for example a thumb for a slider, but primitive namespace also contains base classes that provide common behavior for a set of controls(ex ButtonBase primitive, this provides the basic behavior for button controls, but it doesn't make sense on its own). 


중요한점은 template과 behavior가 분리되어있어서 behavior를 건드리지 않고 template(외견)만 바꿀 수 있다는 점이다.



 On ContentControl and Relations

Content

ContentControl : single item (like button)

Any type of object that can be placed in a ContentControl or a class that derives from ContentControl can be placed in a control that has any of the other three content models


HeaderedContentControl : header + single item (like group box)


ItemsControl : collection of items


HeaderedItemsControl : header + collection of items (like menu item)


위 네개의 클래스들은 대부분의 control들의 base class처럼 행동하고, classes that use these content models can contain the same types of content and treat content in the same way. ContentControl에 들어갈 수 있는 모든 타입의 object들과 ContentControl을 상속한 클래스는 can be placed in a control that has any of the other three content models. 또한 각 content model class들은 content property of type object를 정의하거나 경우에 따라 header property를 정의함으로써 content또는 header에 object type 어떤것이든 지정할 수 있게 한다.


ContentControl은 control을 상속하고, control represents the base class for user interface elements that use ControlTemplate to define their appearance.


On the control class control(에서) 우리는 시각적인 외양을 template로 지정할 수 있고,

On ContentControl or any of the other three content model-enabling classes(에서) 우리는 content를 content property에 지정할 수 있다.

예를 들어 Button(Final Class)은 ButtonBase를 상속하며, ButtonBase는 모든 button type들의 behavior를 제공한다. 그리고 ButtonBase는 ContentControl을 상속한다.


그리고 to ensure content is shown in the template we need to add a ContentPresenter to the ControlTemplate.


Demo : 버튼 Template 수정하기.

Object and Timeline에서 Button 우클릭 -> Edit Template -> Edit a copy (in this document)

Style contains Property Setter for a property with name Template of type ControlTemplate.

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type Button}">

<Grid>

<Ellipse Fill="{TemplateBinding Background}" />    //버튼을 타원으로, 색을 Button에 지정된 Background로 바인딩

      <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />   //버튼의 content를 보이게한다.

</Grid>

</ControlTemplate>...



Interacting With Controls : Routed Events

XAML works with routed events. <See Programming Windows 6th 85~94 page>


A routed event is...

A type of event that can invoke handlers on multiple listeners in an element tree, rather than just on the object that raised the event.

A CLR event that is backed by an instance of the RoutedEvent class and is processed by the event system.


Routed event가 필요한 까닭은 Button을 예로 들면, Button의 content에 많은 elements를 배치할 수 있고, button template에도 많은 elements를 포함시킬 수 있기 때문에 사용자가 button을 클릭했을때 정확히 무엇이 클릭되었는지 장담할 수 없다. 만약 버튼 내에 Image가 배치되어있고 사용자가 그 이미지를 클릭했다면 그 event를 버튼에서 처리해야 한다. As a routed event can invoke handlers on multiple listeners in the element tree, it allows that. In reality a routed event route can travel in different directions. When a UIElement is constructed, they choose the routing strategy for each of their routed events and this is never changed.


A routed event follows a....

- Direct routing strategy (only the source element itself is given the opportunity to invoke handlers in a response)

- Bubbling routing strategy (event handlers on the events are invoked to routed events, then routes to successive parent elements until reaching the element tree root. Most routed events use the bubbling routing strategy)

- tunneling routing strategy (initially event handlers at the element tree root are invoked to a routed event, then travels a route true successive child elements along the route towards the node elements, that is the routed event source, i.e., the element that raised the routed event)


 - Simplified example of tunneling and bubling


1. Click an image in a button (== MouseDown event on the image)


2. But what happens first is that the PreviewMouseDown event is fired, starting at the root, the page typically.


3. Tunnels from Page root to image


4. MouseDown event is raised on that image, then starts bubbling up


5. Button handles that event and throws its own event(Button.Click)

If there's no handler attached to the button that acts on the event, the event will bubble up even further.



RoutedEventArgs exposes a few interesting properties.

OriginalSource : can always see where the event originated

Source : can get the current source object

Handled : By setting it to true, mark the event as handled to ensure that other event handlers that listen for it are no longer executed.

(ex MouseDown event handler was executed before Button_Click, if MouseDown RoutedEventArgs Handled property set to true Button_Click event do not fired)



Summary (생략)


출처

Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 세번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 최종 Summary는 생략하겠습니다. Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.

 

'Programming > XAML' 카테고리의 다른 글

(XAML)Using Resources and Styling Controls  (0) 2017.12.12
(XAML)Working with ItemsControls  (0) 2017.12.11
(XAML)Data Binding Essentials  (0) 2017.12.10
(XAML)Panels and the Layout System  (0) 2017.12.08
(XAML)Basic elements  (0) 2017.12.07
AND

Copyright

이 모든 내용은 Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 2번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 강의 원작자분께 게시허가도 받았습니다.


Content

1. Basic Elements, Shapes, Brushes, and Masks

2. Control Basics and Interacting with them

3. Panels and the Layout System

4. Data Binding Essentials

5. Working with ItemsControls

6. Using Resources and Styling Controls

7. Debugging and Analyzing XAML

8. Choosing the Right Tool for the Job



Important classes

1. DependencyObject

Object that participate in the dependency property system (link)


2. UIElement

Base class for objects that can have a visual appearance

Supports basic manipulation, basic appearance, basic layout

Can respond to user input, can raise routed events, supports some aspects of animation system.


3. FrameworkElement

FrameworkElement potentially participates in layout and should have a display area in the app UI

Adds Height, Width, Alignment and Margin properties

Supports DataContext



Visualize : Shape (<-- FlameworkElement)


대부분의 XAML 컨트롤들은 다른 basic element들로 만들어진다. 

A Shape provides a visual representation and is thus the base of many other XAML elements.

A Shape is a type of UIElement that enables to draw a shape to the screen.


Shape property

Stroke : describes how the shape's outline is painted

StrokeThickness : describes the thickness of the shape's outline

Fill : describes how the interior of the shape is painted


common shapes : Rectangle, Ellipse, Line, Path, Polygon, Polyline


Format -> Combine (more then two objects)


https://msdn.microsoft.com/en-us/library/cc294504.aspx


Using the combine option shapes turned into a path.


















A Special Kind of Shape : The Path

...because of Path, a type (superclass) of Shape, enables complex shapes, described using Geometry objects.


To use a Path

Create a Geometry (LineGeometry, RectangleGeometry, EllipseGeometry, PathGeometry etc)

Use it as the Path's Data property


ex    <Path StrokeThickness="5" Stroke="Blue">

            <Path.Data>

                <LineGeometry StartPoint="10, 20" EndPoint="10, 100"/>

            </Path.Data>

        </Path>


  <Path StrokeThickness="5" Stroke="Blue">

            <Path.Data>

                <PathGeometry>                                                    //PathGeometry

                    <PathFigureCollection>

                        <PathFigure StartPoint="10,10">      //PathFigure StartPoint

                            <LineSegment Point="10, 200"/> //Can add Segments(ArcSegment, BezierSegment, PolyBezierSegment etc)

                            <ArcSegment Size="50,50" RotationAngle="90" Point="200, 100"/>

                        </PathFigure>

                    </PathFigureCollection>

                </PathGeometry>

            </Path.Data>

        </Path>


Shape versus Geometry

While both shape and geometry describe two dimensional shapes, geometry does not take part in the layout system(doesn't know where it is in the visual tree, doesn't know what color it should choose etc).

A Geometry object is more versatile & lightweight, but it's less readily usable.

Shape can render itself and a geometry object can't



How to Paint (A Shape) : The Various Brushes (<-- DependencyObject)

Without brushes, we would simply see noting our screen. A brush paints an area with its output.

WHERE it paints : the area of its output

(ex A brush can be assigned as fill color of rectangle or foreground color of some text)

WHAT it paints : the type of output

(ex A brush can paint in a solid color, but it might as well  paint over an area with a gradient or something else)


Brush types : SolidColorBrush, LinearGradientBrush, RadialGradientBrush, ImageBrush, VideoBrush


ex <ImageBrush ImageSource="...." Viewport-"0,0,50,50", ViewportUnits-"Absolute" TileMode="Tile" />



On Images and Media

While XAML is vector-based, sometimes Bitmap is needed - the Image tag takes care of this.

Image (<-- FrameworkElement)

Important Image property : source, Stretch(Fill, Uniform, UniformToFill, None)


Other types of media, like audio and video, are supported as well. Use the MedioElement tag to implement these.

MediaElement (<-- FrameworkElement)

Important MediaElement property : source



One Step Beyond : Masks

Sometimes, we want to make an element (partially) transparent, or clip a part of the element.


UIElement.OpacityMask

Used to make portions of a UIElement (partially) transparent

Maps its content to the UIElement it's related to by looking at the alpha channel

Brush




UIElement.Clip 

Everything outside of the clipping mask is invisible

Geometry

ex  <Image Source="..." Stretch="None">

            <Image.Clip>

                <RectangleGeometry Rect="0,0,25,50"/>

            </Image.Clip>

        </Image>



Summary

DependencyObject, UIElement, and FrameworkElement are often-used base classes.

 - DependencyObject is an object that participates in a dependency property system.

 - UIElement is the base class for objects that can have visual appearance, suppots basic manipulation, basic appearance, basic layout, and can respond to user input, can raise routed events, and support some aspects of the animation system.

 - FrameworkElements, which potentially participates in layout and should have a display area in the UI. It supports properties like height, width, alignment, and margin, and it also supports the DataContext property.


Shapes are UIElements that allow us to draw a shape to the screen. They provide a visual representation and are thus the base of many other XAML elements.


Brushes allow us to paint an area of a UIElement. WHERE (output area), WHAT (output type)


Masks : Opacity, Clip



출처 

Pluralsight에 Kevin Dockx가 올린 'XAML Jumpstart : Getting Started With XAML' 이라는 강의의 2번째 챕터를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/xaml-jumpstart/table-of-contents). 제가 정리한 것보다 더 많은 내용과 Demo를 포함하고 있으며 Microsoft 지원을 통해 한달간 무료로 Pluralsight의 강의를 들으실 수도 있습니다.

AND

Copyright

이 모든 내용은 pluralsight에 있는 Barry Luijbregts가 올린 The .NET Ecosystem: The Big Picture이라는 강의를 듣고 정리한 것입니다(https://app.pluralsight.com/library/courses/dotnet-ecosystem-big-picture/table-of-contents). Barry Luijbregts 원작자께 블로그 게시 허가도 받았습니다.



.Net development platform

includes Runtimes, .Net APIs, Compilers, languages and runtime component




1. Runtimes

런타임들(.NET Framework, .NET Core, Mono)은 모두 application과 library를 만들기위한 frameworks를 포함한다.


1-1 .NET Framework (프레임워크라고 되어있으나 실상은 런타임이고 플랫폼이다.)



Workloads (application type)

 - Console application

 - Windows communication Foundation (old web service communication)

 - Windows Workflow Foundation (Automate business processes)

 - Windows Presentation Foundation (Windows desktop application with potentially complex UIs)

 - Windows Forms ((Windows desktop application with simple UIs)

 - ASP.NET (Web applications)

     - (ASP.NET) Forms, MVC, Web API applications

 - Azure (WebJobs, Cloud Services)

some of them uses specific Windows APIs



.NET Framework provides a lot of functionality through its Class Library

(Classes, interfaces and value types... like string and collections)

.NET Framework Class Library is sometimes called as the Base Class Library. It contains specific functionality for windows platform, like classes to interact with the file system.




CLR = a thing that is part of the common infrastructure of the languages and build tools that all runtimes have.

 - Run code(Compilation mechanism like JIT compilation)

 - Garbage Collection(runtime helper mechanism)

 - C#, VB.NET, F# codes are run and managed by CLR

(CLR also manages communication between managed code and unmanaged code, like when calls API in the windows platform)


특징 : Windows centric (윈도우 전용 API들을 사용하기 때문)

.NET Framework only runs on the Windows platform(Windows Client version like Windows10, Windows Server versions like Windows server 2016)


.NET Framework의 1,2,4 버전을 컴퓨터에 각자 설치가능하고 1버전을 사용하는 application이나 4버전을 사용하는 application이 있을 수 있다. 그러나 4.7 버전을 설치하면 기존의 4.5버전은 사라진다. (즉 메이저 버전을 단위로 끊어진다. == not true side by side) 

- Major version = new CLR (ex) 3.5 -> 4

- Minor version = new library   (ex) 4.5.2 -> 4.6

- Revision = bug fixes (ex) 4.6 -> 4.6.2


.NET Framework는 C:\Windows\Microsoft.NET\Framework에 설치되어있다.




1-2 .NET Core (runtime)

open source(https://github.com/dotnet/core)


Workloads (application type)

 - Console application

 - ASP.NETCore

     - MVC, API

 - UWP (Universal Windows Platform)


.Net Core Class Library contains Classes like collections, file I/O, XML, and async. It's a subset of .NET Framework library to be more streamlined and lightweight. Basis of application to be small as it can be and additional component can be pulled in through Nuget


CoreCLR = part of the common infrastructure, It is different with .NET Framework CLR, CoreCLR is more lightweight and geared towards running code cross-platform and cross-architecture(it runs on x84, x64 and ARM CPU).

 - Assembly loading, Garbage Collection, C#, F#, VB.NET


App Host = usually .NET.exe (allow .NET Core to run on multiple platforms)

This launches .NET Core apps by hosting the CLR and libraries.


Windows Client, Windows Server, Windows IOT (like Raspberry Pi)

Linux (all sort of Linux distributions like Red Hat, Ubuntu, Tizen)

FreeBSD (UNIX like OS)

Mac OS X


.NET Core를 설치하면 선택한 버전의 application host(dotnet.exe)와 CoreCLR, library를 사용할 수 있게 된다. Application들은 원하는 버전의 .NET Core를 사용가능하며 심지어 .NET Core를 기기에 설치하지 않고 application이 자체적으로 필요한 .NET Core를 가지고 있을 수도 있다(self contained application). 보통 컴퓨터에는 C:\Program Files\dotnet에 설치되어있고, shared폴더에 버전들이 있다(각 버전들은 App Host인 dotnet.exe와 class library를 구성하는 많은 API들을 포함하고있다).


.NET Core 프로젝트를 생성해 프로그램을 만든뒤 솔루션을 우클릭하여 publish할 수 있다. dotnet.exe로 실행가능한 프로그램이 된다. self-contained application을 만들기 위해서는 csproj파일에 RuntimeIdentifier를 지정해주어야한다(ex win10-x64;osx.10.12-x64   윈도우10과 맥에서 실행가능하다. 세팅을 통해 윈10과 맥 버전을 따로 다른 폴더에 지정해 publish한다). 그리고 publish하면 library와 dll 그리고 실행가능한 exe까지 함께 만들어진다.




1-3 Mono (runtime) for Xamrin

Mono runtime은 .NET Framework CLR의 cross-platform을 지원한다. open source (http://github.com/mono/mono)

이 글에서는 Mono for Xamrin만 소개한다.



Workloads (type of application)

 - Apple IOS application

 - Apple Mac OS X application

 - Android applications

 - etc


All application workloads packages their application as self-contained application.


Xamarin Class Library is a subset of .NET Framework Class Library


Mono Runtime은 .NET Framework와 거의 동일한 common infrastructure를 가진다(Garbage Collector, JIT). 그러나 Mono Runtime은 C#만 작동하며 AOT(ahead of time compiler)을 추가로 지원한다.    



특징 : Cross platform (This is used to build and run native mobile application across mobile platforms.)

Specific API for IOS, Android, Xamarin.Mac






- 3개의 Runtime 비교




2. .Net Standard Library (purpose == share code between runtimes)

Set of .NET APIs formal specifications that describes APIs and what they do, Not a physical thing to download or install.

Evolution of Portable Class Library(PCL), .NET Standard replace PCL

(ps. PCL은 프로젝트간에 코드를 공유할 수 있는 다른 방법을 제공한다.)

 

All three runtimes implements .Net Standard Library

.Net Standard Library is a specification of .Net APIs that have implementations for each runtime.

때문에 다른 runtime에서 만들어진 코드가 다른 runtime에서도 실행가능하다.

(실전 : .NET Standard Library project를 생성해서 다른 runtime project에서 사용가능하다.)


Specific Runtime versions implements specific versions of .NET Standard, thereby implementing a specific set of APIs. 

(ex. .NET Framework 4.5 implements .NET Standard <= 1.1)


.NET Standard versioning

.NET Standard의 각 버전은 이전 버전의 API들을 포함한다.

( => higher version contains more API, lower version are supported by more platforms, so target the lowest version as possible)

(버전별 API검색 : http://docs.microsoft.com/en-us/dotnet/api)

(VS marketplace에 있는 .NET Portability Analyzer로 현재 프로젝트가 어떤 .NET Standard version과 매칭하는지 확인할 수 있다.)

There is no breaking changes between versions.

Once shipped, versions are frozen



+ Shared project template in VS == just links between files and projects, act as file-sharing mechanism between project 

do not result in assemblies when it built, do not provide APIs

(in compiler's view there is no shared project, shared project is contained inside of other project which referencing it. VS specific functionality)


3. Common Infrastructure


Build Tools (compiler like Roslyn, CLR, CoreCLR...)

Languages (C#, F#, VB.NET...)

Runtime Components (Garbage Collection, JIT...)


 - The .Net Framework Toolchain

(The purpose of the toolchain is to turn code into a running application)


MSBuild(build engine provided by MS. sln, .csproj, vbproj...) is a linking pin. MSBuild는 C#, VB.NET code는 Roslyn(.NET Compiler Platform)을, F# code에게는 F# Compiler를 호출한다. 결과는 exe, dll같은 IL이다. Intermediate Language(IL)은 CLR과 같은 runtime에 의해 해석된다.


Common Language Runtime(CLR)은 JIT(just-in-time) compiler를 가지고 있으며, 이 컴파일러로 IL을 해당 OS가 이해할 수 있는 native code로 컴파일한다.

CLR also acts as a host for running the application. Native code lives in memory and is managed by the CLR. It has tools for that like the garbage collector.


이 모든 과정을 개발자가 직접 할 수도 있으나 대부분의 경우 이런 일들은 VS와 같은 도구(MSBuild를 실행하는)가 해결한다.



- The .NET Core Toolchain

MSBuild는 .NET Core에서도 사용되며 IL이 나오기까지의 과정은 .NET Framework와 동일하다.


Core Common Language Runtime(CoreCLR)이 IL을 사용한다. CoreCLR은 .NET Framework CLR과 다르다. 가장 큰 차이점은 CoreCLR은 multiple platform(Mac OS나 Linux 등)에서 실행가능하다는 점이다. CoreCLR도 JIT compiler를 포함하고 있으며 IL을 Window, Mac OS, Linux등의 OS가 사용가능한 Native code로 컴파일한다. 이것은 ASP.NET Core나 콘솔 application의 경우이고 UWP는 조금 다른 경로로 Native code를 생성한다.


UWP app is compiled ahead of time with an ahead-of-time compiler(AOT compiler). 이런 방식을 .NET Native라 부른다.

AOT compiler compiles IL code into native code, but it produce this code as a deployable package instead of compiling the code on demand at runtime. This provide performance benefit.


Just like in the .NET Framework native code is run by the CoreCLR which provide capability like garbage collection.


그러나 .NET Framework CLR과 달리 CoreCLR과 Native Code는 application host process에 의해 load되고 kicked off된다. This process(dotnet.exe) hosts the CoreCLR and makes it run native code. 



- The Mono for Xamrin Toolchain

MSBuild가 조정자로써 동일하게 사용되나 앞전 2개와 달리 C#으로 작성된 프로젝트와 코드만 지원한다. (.sln, csproj)


C# code for Android compiled to IL by Xamarin Compiler. Then Mono Runtime's JIT compiler compiles it to Native code(specific for that android device on demand at runtime). 또한 Mono Runtime은 garbage collection과 같은 runtime service를 제공한다.


C# code for iOS의 경우 Xamarin Compiler가 모든 코드를 C# compiler나 AOT compiler를 이용해 native code로 precompile한다. This is special process that produces a package specifically for iOS containing its native code, which is ARM assembly language. iOS understand this and can run it.





- Summary of Toolchain





4. What to use When? (생략)


Copyright

이 모든 내용은 pluralsight에 있는 Barry Luijbregts라는 분이 올린 The .NET Ecosystem: The Big Picture이라는 강의를 듣고 정리한 것입니다. (https://app.pluralsight.com/library/courses/dotnet-ecosystem-big-picture/table-of-contents)(https://www.azurebarry.com/dot-net-ecosystem-explained) 강의에선 더 자세한 설명과 Demo를 포함하고 있으며, 마지막 What to use When?에 대한 내용 정리는 생략하겠습니다. Pluralsight에서 확인하세요. Microsoft 계정으로 한달간 무료로 Pluralsight의 수많은 강의를 시청하실 수도 있습니다.

AND

    C#은 객체 지향 패러다임(object-orientation paradigm)을 풍부하게 구현하는 형식에 안전한 범용 객체 지향 프로그래밍 언어이다. 객체 지향 패러다임에는 캡슐화(encapsulation), 상속(inheritance), 다형성(polymorphism)이 포함된다. 캡슐화는 객체(object) 주변에 경계선을 만들어 객체의 외부(공개) 행동과 내부(비공개) 구현 세부사항을 분리하는 것을 뜻한다.


- 통합된 형식 체계

C# 프로그램의 근본적인 구축 요소는 소위 형식(type)이다. 형식은 자료와 함수들을 하나의 단위로 캡슐화한 것으로 C#은 하나의 통합된 형식 체계(unified type system)을 갖추고 있다. 이 체계에서 모든 형식은 궁극적으로 하나의 공통 기반 형식을 공유한다. (== 모든 형식은 동일한 기본 기능 집합을 가지고 있다.)


- 클래스와 인터페이스

C#은 클래스 말고도 여러 종류의 형식이 있다. 그 중 하나가 인터페이스이다. 인터페이스는 다중 상속이 필요한 경우 유용하다.


- 속성, 메서드. 이벤트

C#에서 메서드(method)는 속성(property)과 이벤트(event)를 비롯한 여러 함수 멤버(function member) 중 하나일 뿐이다. 속성은 객체의 상태 일부를 캡슐화하는 함수 멤버이고 이벤트는 객체의 상태가 변했을 때 수행할 동작을 단순화해주는 함수 멤버이다.



    C#은 객체 지향 뿐 아니라 함수형 프로그래밍에서도 영향을 받았다.

- 함수를 값으로 취급할 수 있다.

대리자(delegate)를 이용하면 함수를 값으로서 다른 함수에 전달하거나 돌려받을 수 있다.


- 순수형 패턴을 지원한다.

함수형 프로그래밍의 핵심은 값이 변하는 변수보다는 선억신(declarative) 패턴을 사용하는 것이다. C#에는 람다 표현식(lambda, 익명 함수를 즉석에서 작성)과 질의 표현식(query expression, 목록(list) 또는 반응식(reactive) 프로그래밍을 수행), 불변이 형식(immutable, 읽기 전용 형식) 등과 같은 기능을 지원한다.


    C#은 정적 형식 적용(static typing)을 지원함으로써 형식에 안전한(type-safe) 언어이다(강한 형식 적용 언어, 형식에 매우 엄격, 컴파일 타임과 런타임에서의 형식 안전성 강제). 강한 형식 적용은 C# 코드를 sandbox(보안의 모든 측면을 호스트가 제어하는 환경) 안에서 실행하는 능력에도 중요하다.

(dynamic 키워드로 일부 코드 형식을 동적으로 결정하는 것도 가능하다.)


    C#은 런타임에 의존해서 메모리를 자동으로 관리함다. CLR(Common Language Runtime, 공용 언어 런타임)에는 프로그래머가 작성한 프로그램의 일부로서 실행되는 쓰레기 수거기(garbage collector)가 있다. 이 수거기는 더 이상 참조되지 않는 객체들의 메모리를 재확보한다. (객체의 메모리 해제 의무 없어짐, 포인터 관련 문제 사라짐) (성능을 위해 포인터를 사용한다면 unsafe 블럭에서만 가능하다.)


- C#과 CLR의 관계

C#은 자동 메모리 관리와 예외 처리 같은 다양한 기능을 갖춘 런타임에 의존한다. C#의 설계는 해당 실행시점 기능들을 제공하는 마소 CLR설계와 밀접하게 대응한다(기술적으로는 C#과 CLR은 독립적이지만). 게다가 C#의 형식 시스템은 CLR의 형식 체계와 밀접하게 대응된다.


- CLR과 .NET Framework

.NET Framework는 CLR과 아주 다양한 라이브러리들의 집합으로 구성되어 있다. CLR은 관리되는 코드(managed code)를 실행하기 위한 런타임이다. C#은 여러 관리되는 언어 중 하나인데, 관리되는 언어로 작성한 소스 코드를 컴파일하면 관리되는 코드가 생성된다. 관리되는 코드를 실행 파일 또는 라이브러리 형태로 만들고 그것을 형식정보(메타자료)와 함께 하나의 패키지로 묶은 것을 어셈블리라고 부른다.


관리되는 코드는 중간 언어(intermediate language, IL)로 표현된다. 어셈블리를 적재할 때 CLR은 어셈블리에 담긴 IL코드를 해당 컴퓨터 고유의 기계어 코드로 변환한다. 이러한 변환을 담당하는 것이 CLR의 JIT(just-in-time)컴파일러이다.






AND

ARTICLE CATEGORY

분류 전체보기 (56)
Programming (45)
MSDN (4)
개발노트 (2)
reference (5)

RECENT ARTICLE

RECENT COMMENT

CALENDAR

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

ARCHIVE