Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx

Marco Parenzan
Marco ParenzanSenior Solutions Architect @ beanTech, Microsoft MVP
Static abstract members nelle interfacce di C# 11 e
dintorni di .NET 7
Sponsors
With the support of:
About me
• Senion Solution Architect @ beanTech
• 1nn0va Community Lead (Pordenone)
• Microsoft Azure MVP
• Linkedin: https://www.linkedin.com/in/marcoparenzan/
• Slideshare: https://www.slideshare.net/marco.parenzan
• GitHub: https://github.com/marcoparenzan
Let’s begin with Azure IoT
Azure IoT Central and IoT PnP
• When you work with IoT Central, you work with IoT PnP
• IoT PnPDigital Twin Definition Language
• InterfaceComponentCapability
• Capability=Telemetry // Property // Command
• When you define a Telemetry, it has
• Semantic
• Unit
• Type
• All described in JSON
• You can do code generation in front of it!
Demo
Generate types from DTDL
Meanwhile in .net space...
C# 1: Value Types and Reference Types
• Reference Type (allocated in heap – referenced in .... Stack...object, polymorphic)
• Value Type (allocated in stack – non polimorphic)
• Struct and Class for custom typesguided by a domain design
• Int, float, double, boolnot guided by a domain
«missing type»=scalars!
• Scalar=Primitive=Struct(ural)=sealed[cannot derive]
• You cannot qualify a scalar
• All class goodies (type checking) are (almost) avoided
• Lot of mess:
• Method signs
• Overload collisions
• Custom Types can introduce more meaning
• How?
• Like triggers in SQL, .NET has structs (missing in action)
Value Types in .NET
• ...or more simpler, structs in C#
• Remember: the formal definition says «allocated into the stack, not into the heap»
• Be more precise
• Reference typea variable, or a parameter, containes a reference to an entity into the heap
• Value type a variable, or a parameter, containes directly the entity
• Value typecopy semantic
• Reference typereference (obviously) semantics
• Value types are fast
C# 3: Extension methods
• Adding methods «externally injected» into objects
• Defined in static methods in static classes, with first argument decorated by «this» keyword
C# 8: default interface methods
• Add support for virtual extension methods - methods in interfaces with concrete implementations. A
class or struct that implements such an interface is required to have a single most
specific implementation for the interface method, either implemented by the class or struct, or
inherited from its base classes or interfaces. Virtual extension methods enable an API author to add
methods to an interface in future versions without breaking source or binary compatibility with
existing implementations of that interface.
C#11: Static abstract members in interfaces
• An interface is allowed to specify abstract static members that implementing classes and structs are
then required to provide an explicit or implicit implementation of. The members can be accessed off
of type parameters that are constrained by the interface.
Parsing Interfaces
Interface name Description
IParsable<TSelf> Exposes support for T.Parse(string, IFormatProvider) and T.TryParse(string,
IFormatProvider, out TSelf).
ISpanParsable<TSelf> Exposes support for T.Parse(ReadOnlySpan<char>,
IFormatProvider) and T.TryParse(ReadOnlySpan<char>, IFormatProvider, out
TSelf).
IFormattable
1
Exposes support for value.ToString(string, IFormatProvider).
ISpanFormattable
1
Exposes support for value.TryFormat(Span<char>, out int,
ReadOnlySpan<char>, IFormatProvider).
C# 11: Generic Math
• .NET 7 introduces new math-related generic interfaces to the base class library. The availability of
these interfaces means you can constrain a type parameter of a generic type or method to be
"number-like". In addition, C# 11 and later lets you define static virtual interface members. Because
operators must be declared as static, this new C# feature lets operators be declared in the new
interfaces for number-like types.
• Together, these innovations allow you to perform mathematical operations generically—that is,
without having to know the exact type you're working with. For example, if you wanted to write a
method that adds two numbers, previously you had to add an overload of the method for each type
(for example, static int Add(int first, int second) and static float Add(float first, float second)).
Numeric Interfaces
Interface name Description
IBinaryFloatingPointIeee754<TSelf> Exposes APIs common to binary floating-point types
1
that implement the IEEE 754 standard.
IBinaryInteger<TSelf> Exposes APIs common to binary integers
2
.
IBinaryNumber<TSelf> Exposes APIs common to binary numbers.
IFloatingPoint<TSelf> Exposes APIs common to floating-point types.
IFloatingPointIeee754<TSelf> Exposes APIs common to floating-point types that implement the IEEE 754 standard.
INumber<TSelf> Exposes APIs common to comparable number types (effectively the "real" number domain).
INumberBase<TSelf> Exposes APIs common to all number types (effectively the "complex" number domain).
ISignedNumber<TSelf> Exposes APIs common to all signed number types (such as the concept of NegativeOne).
IUnsignedNumber<TSelf> Exposes APIs common to all unsigned number types.
IAdditiveIdentity<TSelf,TResult> Exposes the concept of (x + T.AdditiveIdentity) == x.
IMinMaxValue<TSelf> Exposes the concept of T.MinValue and T.MaxValue.
IMultiplicativeIdentity<TSelf,TResult> Exposes the concept of (x * T.MultiplicativeIdentity) == x.
Operator Interfaces
Interface name Defined operators
IAdditionOperators<TSelf,TOther,TResult> x + y
IBitwiseOperators<TSelf,TOther,TResult> x & y, x | y, x ^ y, and ~x
IComparisonOperators<TSelf,TOther,TResult> x < y, x > y, x <= y, and x >= y
IDecrementOperators<TSelf> --x and x--
IDivisionOperators<TSelf,TOther,TResult> x / y
IEqualityOperators<TSelf,TOther,TResult> x == y and x != y
IIncrementOperators<TSelf> ++x and x++
IModulusOperators<TSelf,TOther,TResult> x % y
IMultiplyOperators<TSelf,TOther,TResult> x * y
IShiftOperators<TSelf,TOther,TResult> x << y and x >> y
ISubtractionOperators<TSelf,TOther,TResult> x - y
IUnaryNegationOperators<TSelf,TResult> -x
IUnaryPlusOperators<TSelf,TResult> +x
Function Parsing Interfaces
nterface name Description
IExponentialFunctions<TSelf> Exposes exponential functions supporting e^x, e^x -
1, 2^x, 2^x - 1, 10^x, and 10^x - 1.
IHyperbolicFunctions<TSelf> Exposes hyperbolic functions
supporting acosh(x), asinh(x), atanh(x), cosh(x), sinh(x),
and tanh(x).
ILogarithmicFunctions<TSelf> Exposes logarithmic functions supporting ln(x), ln(x +
1), log2(x), log2(x + 1), log10(x), and log10(x + 1).
IPowerFunctions<TSelf> Exposes power functions supporting x^y.
IRootFunctions<TSelf> Exposes root functions supporting cbrt(x) and sqrt(x).
ITrigonometricFunctions<TSelf> Exposes trigonometric functions
supporting acos(x), asin(x), atan(x), cos(x), sin(x),
and tan(x).
Demo
Let’s see the future with .NET 7
The missing «type» in strongly typed
languages...
Demo
Let’s see how fast are values types
Math with value types
• Another «missing in action»: implicit operator and operator overloading
• Do you remember that you can overload aritmetic operators to use your value types?
• And that you can cast from scalars to structural types (also reference types)?
• Do you know that all of these can become a great math?
Demo
Math with value types
Let’s remember physics
• Volt+Volt=Volt (you can add or subtract homogeneus values)
• Volt*Ampere=Ampere*Volt=Watt (multiplication is commutative)
• Watt/Ampere != Ampere/Watt (division is not commutative)
• ...and remember the plain good old ToString method!
Innovation in JSON Parsing
• Some new features
• Contract customization gives you more control over how types are serialized and deserialized. For more
information, see Customize a JSON contract.
• Polymorphic serialization for user-defined type hierarchies. For more information, see Serialize properties of
derived classes.
• Support for required members, which are properties that must be present in the JSON payload for
deserialization to succeed. For more information, see Required properties.
Demo
Let’s write some physics
Not let’s enter into the scripting
world
«Scripting» in .NET
• Physics and math is about customizing a job (because you have to «express» some laws)
• You have to express calculations
• A couple of choices:
• CSharp Scripting (Roslyn)
• ANTLR
Demo
C# scripting
Using ANTLR
Where Math and science and code met 30yr ago
• Mathematica! From Stephen Wolfram!
• Now we have it also in .NET
• Notebooks
• Kernels
Demo
Write a kernel for your lang
Conclusion
Conclusion
• Math can be a lot of fun
• .NET can be a lot of fun in the science area
1 de 34

Recomendados

Developer’s viewpoint on swift programming language por
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageAzilen Technologies Pvt. Ltd.
2.3K vistas25 diapositivas
C++ Basics por
C++ BasicsC++ Basics
C++ BasicsHimanshu Sharma
563 vistas46 diapositivas
An Overview Of Python With Functional Programming por
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
656 vistas12 diapositivas
Iterator - a powerful but underappreciated design pattern por
Iterator - a powerful but underappreciated design patternIterator - a powerful but underappreciated design pattern
Iterator - a powerful but underappreciated design patternNitin Bhide
4K vistas36 diapositivas
Math with .NET for you and Azure por
Math with .NET for you and AzureMath with .NET for you and Azure
Math with .NET for you and AzureMarco Parenzan
59 vistas29 diapositivas
Aspdot por
AspdotAspdot
AspdotNishad Nizarudeen
17 vistas94 diapositivas

Más contenido relacionado

Similar a Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx

Standardizing on a single N-dimensional array API for Python por
Standardizing on a single N-dimensional array API for PythonStandardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for PythonRalf Gommers
119 vistas14 diapositivas
java Basic Programming Needs por
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming NeedsRaja Sekhar
3.4K vistas52 diapositivas
Typescript: Beginner to Advanced por
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to AdvancedTalentica Software
54 vistas19 diapositivas
C# por
C#C#
C#Sudhriti Gupta
101 vistas68 diapositivas
Structured Languages por
Structured LanguagesStructured Languages
Structured LanguagesMufaddal Nullwala
216 vistas53 diapositivas
C++ por
C++C++
C++Sabyasachi Moitra
347 vistas166 diapositivas

Similar a Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx(20)

Standardizing on a single N-dimensional array API for Python por Ralf Gommers
Standardizing on a single N-dimensional array API for PythonStandardizing on a single N-dimensional array API for Python
Standardizing on a single N-dimensional array API for Python
Ralf Gommers119 vistas
java Basic Programming Needs por Raja Sekhar
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
Raja Sekhar3.4K vistas
Python for katana por kedar nath
Python for katanaPython for katana
Python for katana
kedar nath11.5K vistas
CSharp for Unity Day 3 por Duong Thanh
CSharp for Unity Day 3CSharp for Unity Day 3
CSharp for Unity Day 3
Duong Thanh21 vistas
2.Getting Started with C#.Net-(C#) por Shoaib Ghachi
2.Getting Started with C#.Net-(C#)2.Getting Started with C#.Net-(C#)
2.Getting Started with C#.Net-(C#)
Shoaib Ghachi22 vistas
Functional and Algebraic Domain Modeling por Debasish Ghosh
Functional and Algebraic Domain ModelingFunctional and Algebraic Domain Modeling
Functional and Algebraic Domain Modeling
Debasish Ghosh2.7K vistas
Reflection Slides by Zubair Dar por zubairdar6
Reflection Slides by Zubair DarReflection Slides by Zubair Dar
Reflection Slides by Zubair Dar
zubairdar6110 vistas

Más de Marco Parenzan

Azure IoT Central per lo SCADA engineer por
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineerMarco Parenzan
7 vistas60 diapositivas
Azure Hybrid @ Home por
Azure Hybrid @ HomeAzure Hybrid @ Home
Azure Hybrid @ HomeMarco Parenzan
10 vistas50 diapositivas
Azure Synapse Analytics for your IoT Solutions por
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT SolutionsMarco Parenzan
33 vistas21 diapositivas
Power BI Streaming Data Flow e Azure IoT Central por
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central Marco Parenzan
29 vistas61 diapositivas
Power BI Streaming Data Flow e Azure IoT Central por
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralMarco Parenzan
8 vistas62 diapositivas
Power BI Streaming Data Flow e Azure IoT Central por
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT CentralMarco Parenzan
105 vistas52 diapositivas

Más de Marco Parenzan(20)

Azure IoT Central per lo SCADA engineer por Marco Parenzan
Azure IoT Central per lo SCADA engineerAzure IoT Central per lo SCADA engineer
Azure IoT Central per lo SCADA engineer
Marco Parenzan7 vistas
Azure Synapse Analytics for your IoT Solutions por Marco Parenzan
Azure Synapse Analytics for your IoT SolutionsAzure Synapse Analytics for your IoT Solutions
Azure Synapse Analytics for your IoT Solutions
Marco Parenzan33 vistas
Power BI Streaming Data Flow e Azure IoT Central por Marco Parenzan
Power BI Streaming Data Flow e Azure IoT Central Power BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan29 vistas
Power BI Streaming Data Flow e Azure IoT Central por Marco Parenzan
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan8 vistas
Power BI Streaming Data Flow e Azure IoT Central por Marco Parenzan
Power BI Streaming Data Flow e Azure IoT CentralPower BI Streaming Data Flow e Azure IoT Central
Power BI Streaming Data Flow e Azure IoT Central
Marco Parenzan105 vistas
Developing Actors in Azure with .net por Marco Parenzan
Developing Actors in Azure with .netDeveloping Actors in Azure with .net
Developing Actors in Azure with .net
Marco Parenzan80 vistas
Power BI data flow and Azure IoT Central por Marco Parenzan
Power BI data flow and Azure IoT CentralPower BI data flow and Azure IoT Central
Power BI data flow and Azure IoT Central
Marco Parenzan106 vistas
.net for fun: write a Christmas videogame por Marco Parenzan
.net for fun: write a Christmas videogame.net for fun: write a Christmas videogame
.net for fun: write a Christmas videogame
Marco Parenzan108 vistas
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn... por Marco Parenzan
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Building IoT infrastructure on edge with .net, Raspberry PI and ESP32 to conn...
Marco Parenzan361 vistas
Anomaly Detection with Azure and .NET por Marco Parenzan
Anomaly Detection with Azure and .NETAnomaly Detection with Azure and .NET
Anomaly Detection with Azure and .NET
Marco Parenzan203 vistas
Deploy Microsoft Azure Data Solutions por Marco Parenzan
Deploy Microsoft Azure Data SolutionsDeploy Microsoft Azure Data Solutions
Deploy Microsoft Azure Data Solutions
Marco Parenzan159 vistas
Deep Dive Time Series Anomaly Detection in Azure with dotnet por Marco Parenzan
Deep Dive Time Series Anomaly Detection in Azure with dotnetDeep Dive Time Series Anomaly Detection in Azure with dotnet
Deep Dive Time Series Anomaly Detection in Azure with dotnet
Marco Parenzan134 vistas
Anomaly Detection with Azure and .net por Marco Parenzan
Anomaly Detection with Azure and .netAnomaly Detection with Azure and .net
Anomaly Detection with Azure and .net
Marco Parenzan116 vistas
Code Generation for Azure with .net por Marco Parenzan
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
Marco Parenzan86 vistas
Running Kafka and Spark on Raspberry PI with Azure and some .net magic por Marco Parenzan
Running Kafka and Spark on Raspberry PI with Azure and some .net magicRunning Kafka and Spark on Raspberry PI with Azure and some .net magic
Running Kafka and Spark on Raspberry PI with Azure and some .net magic
Marco Parenzan170 vistas
Time Series Anomaly Detection with Azure and .NETT por Marco Parenzan
Time Series Anomaly Detection with Azure and .NETTTime Series Anomaly Detection with Azure and .NETT
Time Series Anomaly Detection with Azure and .NETT
Marco Parenzan138 vistas
Code Generation for Azure with .net por Marco Parenzan
Code Generation for Azure with .netCode Generation for Azure with .net
Code Generation for Azure with .net
Marco Parenzan80 vistas
Deep dive time series anomaly detection with different Azure Data Services por Marco Parenzan
Deep dive time series anomaly detection with different Azure Data ServicesDeep dive time series anomaly detection with different Azure Data Services
Deep dive time series anomaly detection with different Azure Data Services
Marco Parenzan181 vistas

Último

EV Charging App Case por
EV Charging App Case EV Charging App Case
EV Charging App Case iCoderz Solutions
9 vistas1 diapositiva
nintendo_64.pptx por
nintendo_64.pptxnintendo_64.pptx
nintendo_64.pptxpaiga02016
6 vistas7 diapositivas
Quality Engineer: A Day in the Life por
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the LifeJohn Valentino
7 vistas18 diapositivas
aATP - New Correlation Confirmation Feature.pptx por
aATP - New Correlation Confirmation Feature.pptxaATP - New Correlation Confirmation Feature.pptx
aATP - New Correlation Confirmation Feature.pptxEsatEsenek1
205 vistas6 diapositivas
Dapr Unleashed: Accelerating Microservice Development por
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice DevelopmentMiroslav Janeski
15 vistas29 diapositivas
Top-5-production-devconMunich-2023-v2.pptx por
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptxTier1 app
8 vistas42 diapositivas

Último(20)

Quality Engineer: A Day in the Life por John Valentino
Quality Engineer: A Day in the LifeQuality Engineer: A Day in the Life
Quality Engineer: A Day in the Life
John Valentino7 vistas
aATP - New Correlation Confirmation Feature.pptx por EsatEsenek1
aATP - New Correlation Confirmation Feature.pptxaATP - New Correlation Confirmation Feature.pptx
aATP - New Correlation Confirmation Feature.pptx
EsatEsenek1205 vistas
Dapr Unleashed: Accelerating Microservice Development por Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski15 vistas
Top-5-production-devconMunich-2023-v2.pptx por Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app8 vistas
Transport Management System - Shipment & Container Tracking por Freightoscope
Transport Management System - Shipment & Container TrackingTransport Management System - Shipment & Container Tracking
Transport Management System - Shipment & Container Tracking
Freightoscope 5 vistas
tecnologia18.docx por nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 vistas
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile... por Stefan Wolpers
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
Stefan Wolpers42 vistas
predicting-m3-devopsconMunich-2023.pptx por Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 vistas
Understanding HTML terminology por artembondar5
Understanding HTML terminologyUnderstanding HTML terminology
Understanding HTML terminology
artembondar57 vistas
FOSSLight Community Day 2023-11-30 por Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan7 vistas
Supercharging your Python Development Environment with VS Code and Dev Contai... por Dawn Wages
Supercharging your Python Development Environment with VS Code and Dev Contai...Supercharging your Python Development Environment with VS Code and Dev Contai...
Supercharging your Python Development Environment with VS Code and Dev Contai...
Dawn Wages5 vistas
Bootstrapping vs Venture Capital.pptx por Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic15 vistas
Top-5-production-devconMunich-2023.pptx por Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app9 vistas

Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx

  • 1. Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7
  • 3. About me • Senion Solution Architect @ beanTech • 1nn0va Community Lead (Pordenone) • Microsoft Azure MVP • Linkedin: https://www.linkedin.com/in/marcoparenzan/ • Slideshare: https://www.slideshare.net/marco.parenzan • GitHub: https://github.com/marcoparenzan
  • 4. Let’s begin with Azure IoT
  • 5. Azure IoT Central and IoT PnP • When you work with IoT Central, you work with IoT PnP • IoT PnPDigital Twin Definition Language • InterfaceComponentCapability • Capability=Telemetry // Property // Command • When you define a Telemetry, it has • Semantic • Unit • Type • All described in JSON • You can do code generation in front of it!
  • 7. Meanwhile in .net space...
  • 8. C# 1: Value Types and Reference Types • Reference Type (allocated in heap – referenced in .... Stack...object, polymorphic) • Value Type (allocated in stack – non polimorphic) • Struct and Class for custom typesguided by a domain design • Int, float, double, boolnot guided by a domain
  • 9. «missing type»=scalars! • Scalar=Primitive=Struct(ural)=sealed[cannot derive] • You cannot qualify a scalar • All class goodies (type checking) are (almost) avoided • Lot of mess: • Method signs • Overload collisions • Custom Types can introduce more meaning • How? • Like triggers in SQL, .NET has structs (missing in action)
  • 10. Value Types in .NET • ...or more simpler, structs in C# • Remember: the formal definition says «allocated into the stack, not into the heap» • Be more precise • Reference typea variable, or a parameter, containes a reference to an entity into the heap • Value type a variable, or a parameter, containes directly the entity • Value typecopy semantic • Reference typereference (obviously) semantics • Value types are fast
  • 11. C# 3: Extension methods • Adding methods «externally injected» into objects • Defined in static methods in static classes, with first argument decorated by «this» keyword
  • 12. C# 8: default interface methods • Add support for virtual extension methods - methods in interfaces with concrete implementations. A class or struct that implements such an interface is required to have a single most specific implementation for the interface method, either implemented by the class or struct, or inherited from its base classes or interfaces. Virtual extension methods enable an API author to add methods to an interface in future versions without breaking source or binary compatibility with existing implementations of that interface.
  • 13. C#11: Static abstract members in interfaces • An interface is allowed to specify abstract static members that implementing classes and structs are then required to provide an explicit or implicit implementation of. The members can be accessed off of type parameters that are constrained by the interface.
  • 14. Parsing Interfaces Interface name Description IParsable<TSelf> Exposes support for T.Parse(string, IFormatProvider) and T.TryParse(string, IFormatProvider, out TSelf). ISpanParsable<TSelf> Exposes support for T.Parse(ReadOnlySpan<char>, IFormatProvider) and T.TryParse(ReadOnlySpan<char>, IFormatProvider, out TSelf). IFormattable 1 Exposes support for value.ToString(string, IFormatProvider). ISpanFormattable 1 Exposes support for value.TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider).
  • 15. C# 11: Generic Math • .NET 7 introduces new math-related generic interfaces to the base class library. The availability of these interfaces means you can constrain a type parameter of a generic type or method to be "number-like". In addition, C# 11 and later lets you define static virtual interface members. Because operators must be declared as static, this new C# feature lets operators be declared in the new interfaces for number-like types. • Together, these innovations allow you to perform mathematical operations generically—that is, without having to know the exact type you're working with. For example, if you wanted to write a method that adds two numbers, previously you had to add an overload of the method for each type (for example, static int Add(int first, int second) and static float Add(float first, float second)).
  • 16. Numeric Interfaces Interface name Description IBinaryFloatingPointIeee754<TSelf> Exposes APIs common to binary floating-point types 1 that implement the IEEE 754 standard. IBinaryInteger<TSelf> Exposes APIs common to binary integers 2 . IBinaryNumber<TSelf> Exposes APIs common to binary numbers. IFloatingPoint<TSelf> Exposes APIs common to floating-point types. IFloatingPointIeee754<TSelf> Exposes APIs common to floating-point types that implement the IEEE 754 standard. INumber<TSelf> Exposes APIs common to comparable number types (effectively the "real" number domain). INumberBase<TSelf> Exposes APIs common to all number types (effectively the "complex" number domain). ISignedNumber<TSelf> Exposes APIs common to all signed number types (such as the concept of NegativeOne). IUnsignedNumber<TSelf> Exposes APIs common to all unsigned number types. IAdditiveIdentity<TSelf,TResult> Exposes the concept of (x + T.AdditiveIdentity) == x. IMinMaxValue<TSelf> Exposes the concept of T.MinValue and T.MaxValue. IMultiplicativeIdentity<TSelf,TResult> Exposes the concept of (x * T.MultiplicativeIdentity) == x.
  • 17. Operator Interfaces Interface name Defined operators IAdditionOperators<TSelf,TOther,TResult> x + y IBitwiseOperators<TSelf,TOther,TResult> x & y, x | y, x ^ y, and ~x IComparisonOperators<TSelf,TOther,TResult> x < y, x > y, x <= y, and x >= y IDecrementOperators<TSelf> --x and x-- IDivisionOperators<TSelf,TOther,TResult> x / y IEqualityOperators<TSelf,TOther,TResult> x == y and x != y IIncrementOperators<TSelf> ++x and x++ IModulusOperators<TSelf,TOther,TResult> x % y IMultiplyOperators<TSelf,TOther,TResult> x * y IShiftOperators<TSelf,TOther,TResult> x << y and x >> y ISubtractionOperators<TSelf,TOther,TResult> x - y IUnaryNegationOperators<TSelf,TResult> -x IUnaryPlusOperators<TSelf,TResult> +x
  • 18. Function Parsing Interfaces nterface name Description IExponentialFunctions<TSelf> Exposes exponential functions supporting e^x, e^x - 1, 2^x, 2^x - 1, 10^x, and 10^x - 1. IHyperbolicFunctions<TSelf> Exposes hyperbolic functions supporting acosh(x), asinh(x), atanh(x), cosh(x), sinh(x), and tanh(x). ILogarithmicFunctions<TSelf> Exposes logarithmic functions supporting ln(x), ln(x + 1), log2(x), log2(x + 1), log10(x), and log10(x + 1). IPowerFunctions<TSelf> Exposes power functions supporting x^y. IRootFunctions<TSelf> Exposes root functions supporting cbrt(x) and sqrt(x). ITrigonometricFunctions<TSelf> Exposes trigonometric functions supporting acos(x), asin(x), atan(x), cos(x), sin(x), and tan(x).
  • 19. Demo Let’s see the future with .NET 7
  • 20. The missing «type» in strongly typed languages...
  • 21. Demo Let’s see how fast are values types
  • 22. Math with value types • Another «missing in action»: implicit operator and operator overloading • Do you remember that you can overload aritmetic operators to use your value types? • And that you can cast from scalars to structural types (also reference types)? • Do you know that all of these can become a great math?
  • 24. Let’s remember physics • Volt+Volt=Volt (you can add or subtract homogeneus values) • Volt*Ampere=Ampere*Volt=Watt (multiplication is commutative) • Watt/Ampere != Ampere/Watt (division is not commutative) • ...and remember the plain good old ToString method!
  • 25. Innovation in JSON Parsing • Some new features • Contract customization gives you more control over how types are serialized and deserialized. For more information, see Customize a JSON contract. • Polymorphic serialization for user-defined type hierarchies. For more information, see Serialize properties of derived classes. • Support for required members, which are properties that must be present in the JSON payload for deserialization to succeed. For more information, see Required properties.
  • 27. Not let’s enter into the scripting world
  • 28. «Scripting» in .NET • Physics and math is about customizing a job (because you have to «express» some laws) • You have to express calculations • A couple of choices: • CSharp Scripting (Roslyn) • ANTLR
  • 31. Where Math and science and code met 30yr ago • Mathematica! From Stephen Wolfram! • Now we have it also in .NET • Notebooks • Kernels
  • 32. Demo Write a kernel for your lang
  • 34. Conclusion • Math can be a lot of fun • .NET can be a lot of fun in the science area