100% found this document useful (4 votes)
51 views55 pages

Buy ebook Exploring the .NET Core 3.0 Runtime: Through Code Generation and Metadata Inspection 1st Edition Roger Villela cheap price

Through

Uploaded by

anetatriceio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
51 views55 pages

Buy ebook Exploring the .NET Core 3.0 Runtime: Through Code Generation and Metadata Inspection 1st Edition Roger Villela cheap price

Through

Uploaded by

anetatriceio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Exploring the .NET Core 3.0 Runtime: Through Code


Generation and Metadata Inspection 1st Edition
Roger Villela

https://textbookfull.com/product/exploring-the-net-
core-3-0-runtime-through-code-generation-and-metadata-
inspection-1st-edition-roger-villela/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Pro .NET 5 Custom Libraries: Implementing Custom .NET Data


Types 1st Edition Roger Villela

https://textbookfull.com/product/pro-net-5-custom-libraries-
implementing-custom-net-data-types-1st-edition-roger-villela/

textboxfull.com

Introducing Mechanisms and APIs for Memory Management


Using Windows OS Native Runtime APIs 1st Edition Roger
Villela
https://textbookfull.com/product/introducing-mechanisms-and-apis-for-
memory-management-using-windows-os-native-runtime-apis-1st-edition-
roger-villela/
textboxfull.com

Stylish F#: Crafting Elegant Functional Code for .NET and


.NET Core 1st Edition Kit Eason

https://textbookfull.com/product/stylish-f-crafting-elegant-
functional-code-for-net-and-net-core-1st-edition-kit-eason/

textboxfull.com

Stylish F Crafting Elegant Functional Code for NET and NET


Core 1st Edition Kit Eason

https://textbookfull.com/product/stylish-f-crafting-elegant-
functional-code-for-net-and-net-core-1st-edition-kit-eason-2/

textboxfull.com
C 8 0 and NET Core 3 0 Modern Cross Platform Development
Build applications with C NET Core Entity Framework Core
ASP NET Core and ML NET using Visual Studio Code 4th
Edition Mark J. Price
https://textbookfull.com/product/c-8-0-and-net-core-3-0-modern-cross-
platform-development-build-applications-with-c-net-core-entity-
framework-core-asp-net-core-and-ml-net-using-visual-studio-code-4th-
edition-mark-j-price/
textboxfull.com

Pro .NET Framework with the Base Class Library:


Understanding the Virtual Execution System and the Common
Type System Roger Villela
https://textbookfull.com/product/pro-net-framework-with-the-base-
class-library-understanding-the-virtual-execution-system-and-the-
common-type-system-roger-villela/
textboxfull.com

Pro C# 7 with .NET and .NET Core Andrew Troelsen

https://textbookfull.com/product/pro-c-7-with-net-and-net-core-andrew-
troelsen/

textboxfull.com

Pro ASP NET Core Identity Under the Hood with


Authentication and Authorization in ASP NET Core 5 and 6
Applications 1st Edition Adam Freeman
https://textbookfull.com/product/pro-asp-net-core-identity-under-the-
hood-with-authentication-and-authorization-in-asp-net-
core-5-and-6-applications-1st-edition-adam-freeman/
textboxfull.com

Modern Data Access with Entity Framework Core: Database


Programming Techniques for .NET, .NET Core, UWP, and
Xamarin with C# 1st Edition Holger Schwichtenberg
https://textbookfull.com/product/modern-data-access-with-entity-
framework-core-database-programming-techniques-for-net-net-core-uwp-
and-xamarin-with-c-1st-edition-holger-schwichtenberg/
textboxfull.com
Roger Villela

Exploring the .NET Core 3.0 Runtime


Through Code Generation and Metadata Inspection
Roger Villela
Sao Paulo, Sã o Paulo, Brazil

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​978-1-4842-5112-6 . For
more detailed information, please visit www.​apress.​com/​source-code .

ISBN 978-1-4842-5112-6 e-ISBN 978-1-4842-5113-3


https://doi.org/10.1007/978-1-4842-5113-3

© Roger Villela 2019

This work is subject to copyright. All rights are reserved by the


Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other
physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.

Trademarked names, logos, and images may appear in this book. Rather
than use a trademark symbol with every occurrence of a trademarked
name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark. The use in this publication
of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of
opinion as to whether or not they are subject to proprietary rights.

While the advice and information in this book are believed to be true
and accurate at the date of publication, neither the authors nor the
editors nor the publisher can accept any legal responsibility for any
errors or omissions that may be made. The publisher makes no
warranty, express or implied, with respect to the material contained
herein.

Distributed to the book trade worldwide by Springer Science+Business


Media New York, 233 Spring Street, 6th Floor, New York, NY 10013.
Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-
[email protected], or visit www.springeronline.com. Apress Media,
LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
This book is dedicated to my mother, Marina Roel de Oliveira (†).
† From 1952, January 14, to 2017, March 17
Introduction
Software engineering is a challenge and a pleasure, and in this book,
you will learn how to program for two advanced features that are
available in the .NET Core 3.0 environment: the .NET API for the
dynamic generation of code and the .NET API for metadata inspection.
This knowledge is the starting point for designing and implementing a
library that can be used by a code generator tool and a metadata
inspector tool. This library will be able to be used on different
operating system platforms, because .NET Core 3.0 is a cross-platform
implementation of ECMA-335. All the source code is written in the C#
programming language, and the code uses only cross-platform Base
Class Library (BCL) types.
The .NET API for code generation can help you improve your
productivity and the quality of your .NET software by automating
repetitive tasks. In this book, you also will learn about the internal
aspects of the Virtual Execution System (VES), which is the virtual
machine (a virtual hardware platform) of the .NET platform that,
among other tasks, runs the intermediate code. You will learn about the
garbage collection (GC) mechanism that is responsible for automatic
memory management, one of the features of the .NET Core platform.
The .NET API for metadata inspection is another valuable .NET Core
3.0 feature, especially for internal tools that are used to validate
assemblies in certain business scenarios. For example, in a .NET
hierarchy, every reference type or value type implicitly inherits from
the System.Object root class type, and in this hierarchy of business
objects, you will probably also have a root class from which all
reference types should inherit. You can use the metadata inspection
feature to check the business implementation rules based on the
configuration files.
Acknowledgments
First, I would like to thank the team at Apress who worked with me on
this book: Smriti Srivastava (acquisitions editor), Shrikant
Vishwakarma (coordinating editor), Matthew Moodie (development
editor), Welmoed Spahr (managing director), and Carsten Thomsen
(technical reviewer). It was a pleasure and an honor to work with such
a highly professional team.
Thanks to both my parents and a special thanks to my dad, Gilberto.
Thanks to my aunts, Marinete and Maria Á guida; to my cousin, Silvana;
and to my brother Eder and my brother Marlos and his wife, Janaína, as
well as my nephew, Gabriel, and nieces, Lívia and Rafaela. I would also
like to thank my professional colleagues and friends who have worked
with me for the past decade.
Table of Contents
Chapter 1:​Exploring .​NET Core
Acronyms
About the .​NET Core Platform
Microsoft Visual Studio 2019 Support for .​NET Core
Tutorial:​Using .​NET Core SDK Previews and configurations
Configuration for Using the .​NET Core SDK Previews
Adding a Class Library (.​NET Core) Project
Choosing the Target .​NET Core SDK
Changing the Project Config File
Using a TFM on the Project Config File
Using .​NET Standard
List of TFMs
Summary
Do’s
Don’ts
Chapter 2:​About Static .​NET Assembly
Acronyms
Development Environment
The Static .​NET Assembly
Metadata System
About the .​NET Assembly Manifest
Summary
Do’s
Don’ts
Chapter 3:​Dynamic .​NET Assemblies:​Defining Dynamic .​NET
Types
About Dynamic Assemblies
Organization of RVJ.​Core .​NET Types
Purpose of .​NET Types
.​NET Type Interfaces
Builders of the System.​Reflection.​Emit Namespace
The Flags and Definition of .​NET Types
About System.​Reflection.​Emit Type Builders
Using an Assembly Type Builder
Naming the Dynamic .​NET Assembly
AssemblyBuilderA​ccess Enum Options
Defining a Dynamic .​NET Type
Defining Dynamic .​NET Field Members for a Dynamic .​NET Type
Instantiating a Dynamic .​NET Type and Assigning a Value for a
Dynamic .​NET Field
Summary
Do’s
Don’ts
Chapter 4:​Working with Dynamic .​NET Properties
About Dynamic .​NET Properties
The Getter and Setter Methods
The Other Methods
The Prefixes get_​and set_​
The specialname and rtspecialname Attributes
Implementing a Dynamic .​NET Property
Summary
Do’s
Don’ts
Chapter 5:​Working with the CodeDOM
About the CodeDOM
Code Generation Using the CodeDOM
Summary
Do’s
Don’ts
Index
About the Author and About the Technical
Reviewer

About the Author


Roger Villela
is an independent software engineer and
entrepreneur with 30 years of
experience. Currently, he writes books
and educates people about technology,
specializing in the inner works of the
following Microsoft development
platforms:
– Microsoft Windows operating system
base services
– Microsoft Universal Windows
Platform (UWP)
– Microsoft WinRT
– Microsoft .NET Framework implementation of the runtime
environment (CLR)
Roger’s work is based on Microsoft Visual Studio (Microsoft
Windows) and Intel Parallel Studio XE (Microsoft Windows), using the
following programming languages, extensions, and projections:
– C++
– Assembly (Intel IA-32/Intel 64)
– Component extensions for runtimes (C++/CLI and C++/CX)

About the Technical Reviewer


Carsten Thomsen
is primarily a back-end developer but works with smaller, front-end
bits as well. He has authored and reviewed a number of books and has
created numerous Microsoft Learning
courses, all related to software
development. He works as a
freelancer/contractor in various
countries in Europe, using Azure, Visual
Studio, Azure DevOps, and GitHub. Being
an exceptional troubleshooter who asks
the right questions, he also enjoys
architecture, research, analysis,
development, testing, and bug fixing.
Carsten is an excellent communicator
with great mentoring and team-lead
skills and excels at researching and
presenting new material.
© Roger Villela 2019
R. Villela, Exploring the .NET Core 3.0 Runtime
https://doi.org/10.1007/978-1-4842-5113-3_1

1. Exploring .NET Core


Roger Villela1

(1) Sao Paulo, Sã o Paulo, Brazil

This chapter gives you an overview of the .NET Core platform and the
features of Microsoft Visual Studio 2019 specific to the environment.

Acronyms
The following are the acronyms introduced in this chapter and used
throughout the book:
Application programming interface (API)
Base Class Library (BCL)
Common Type System (CTS)
Common Intermediate Language (CIL)
Common Language Infrastructure (CLI)
Common Language Runtime (CLR)
Common Language Specification (CLS)
Framework Class Library (FCL)
General availability (GA)
Intermediate language (IL)
Just-in-time (JIT)
Target framework moniker (TFM)
Long-term support (LTS)
Microsoft Intermediate Language (MSIL)
Release candidate (RC)
Virtual Execution System (VES)
About the .NET Core Platform
.​NET Core is a general-purpose, .NET cross-platform development
framework that provides support for Microsoft Windows, Apple macOS,
and Linux distributions. Like the .NET Framework, the .​NET Core
implementation is based on the ECMA-335 specification.
The .NET Core project is available on GitHub; it is open source and
maintained by Microsoft and the .NET community. With the .NET Core
platform, it is possible to write applications, libraries, and components
for desktop development, web development, cloud development, device
development, and IoT applications. Here are some examples of GitHub
repositories, including WPF and Windows Forms, that are now officially
.NET Core–based UI frameworks:
GitHub repository for .NET Core (
https://github.com/dotnet/core )
.NET Core is a self-contained .NET runtime and framework that
implements ECMA-335. It can be (and has been) ported to multiple
architectures and platforms. It supports a variety of installation
options and has no specific deployment requirements itself. This
repo includes several documents that explain both high-level and
low-level concepts about the .NET runtime. These documents are
particularly useful for contributors to get context that can be
difficult to acquire from just reading code.
GitHub repository for .NET Core Foundational Class Libraries, the
BCL and FCL ( https://github.com/dotnet/corefx )
The .NET platform has a standard set of class libraries. The BCL
(core set) is expected with any .NET implementation, because
without it, you would not have a functional implementation of
.NET. The FCL (complete set) is not fully required, but these two
libraries provide .NET types for many general and app-specific
types. Commercial and community libraries can be built on top of
the BCL and FCL libraries. The CoreFX repository contains both,
the BCL and the FCL.
GitHub repository for the .NET Core runtime, the CoreCLR (
https://github.com/dotnet/coreclr )
This is the runtime for .NET Core; it is composed of the garbage
collector, JIT compiler, primitive data types, and low-level classes.
The .NET Core runtime implements the ECMA-335 specification, is
a self-contained .NET runtime and framework, has been ported to
multiple architectures and platforms, and, having no specific
deployment requirements itself, supports a variety of installation
options.
GitHub repository for .NET WPF UI framework (
https://github.com/dotnet/wpf )
The WPF is now officially a .NET Core–based UI framework for the
development of applications and components for the Microsoft
Windows desktop. It runs exclusively on the Microsoft Windows
family of operating systems and relies on Microsoft DirectX
technologies. It has a vector-based graphics architecture that
enables the use of high-DPI monitors and infinity scale and uses
the Extensible Application Markup Language (XAML) to provide a
declarative model for application programming.
GitHub repository for .NET Core Windows Forms UI framework (
https://github.com/dotnet/winforms )
Windows Forms is now officially a .NET Core–based UI framework
for the development of applications and components for the
Microsoft Windows desktop. The Windows Forms UI framework
runs exclusively on the Microsoft Windows family of operating
systems and relies on Microsoft Windows GDI+ technology.
GitHub repository for ASP.NET Core (
https://github.com/aspnet/AspNetCore )
ASP.NET Core is an open source, cross-platform framework for
building web applications, cloud-based applications, IoT
applications, and back-end services for mobile applications. It can
be hosted on Windows, Mac, or Linux and can be deployed in the
cloud or on-premises.
For .NET Core 3.0, Microsoft has officially scheduled the .NET Core
3.0 RC for July 2019, the .NET Core 3.0 GA for September 2019, and the
.NET Core 3.1 LTS for November 2019.
Microsoft is also reorganizing Microsoft .NET, and by 2020, there
will be only one .NET Framework, not the .NET Framework and .NET
Core. You can learn more in the post “Introducing .NET 5” at
https://devblogs.microsoft.com/dotnet/introducing-
net-5/ .
According to an official chronogram, Microsoft has scheduled the
new .NET 5.0 (GA) for November 2020, .NET 6.0 (LTS) for November
2021, .NET 7.0 (GA) for November 2022, and .NET 8.0 (LTS) for
November 2023.
Now let’s talk about Microsoft Visual Studio 2019 support for .NET
Core.

Microsoft Visual Studio 2019 Support for .NET Core


Microsoft offers great support within the Microsoft Visual Studio IDE
for .NET Core development. The images and comments in this section
are based on features of Microsoft Visual Studio 2019 RTM
(Community, Professional, and Enterprise) version 16.1.4.
If you’re using Microsoft .NET Core 3.0 preview version (preview 6
at the time of this writing), Microsoft advocates using Microsoft Visual
Studio 2019 version 16.0 as the minimum version. Here’s a list of
minimum versions to use for Microsoft Visual Studio 2019 and
Microsoft Visual Studio 2017:
Microsoft Visual Studio 2019 version 16.0 or higher for developing
applications and components targeting .NET Core 3.0 (preview 6 at
the time of this writing)
Microsoft Visual Studio 2017 version 15.9 or higher for developing
applications and components targeting .NET Core 2.2
Microsoft Visual Studio 2017 version 15.7 or higher for developing
applications and components targeting .NET Core 2.1
Microsoft Visual Studio 2017 version 15.0 or higher for developing
applications and components targeting .NET Core 1.x
Figure 1-1 shows Microsoft Visual Studio 2019’s new start window
with choices for creating projects using project templates and opening
recent projects and solutions. You can also apply filters for
programming language, platform, and project type.
Figure 1-1 Microsoft Visual Studio 2019’s new start window for creating, opening,
and connecting to a source repository
At the time of writing, the following are examples of templates for
.NET Core in Microsoft Visual Studio 2019:
ASP.NET Core Web Application
Class Library (.NET Core)
Console App (.NET Core)
MSTest Test Project (.NET Core)
NUnit Test Project (.NET Core)
Web Driver Test for Edge (.NET Core)
Windows Forms App (.NET Core)
WPF App (.NET Core)
xUnit Test Project (.NET Core)
Figure 1-2 shows the start window with the Console App (.NET
Core) template selected. You can also see the templates called ASP.NET
Core Web Application and WPF App (.NET Core).
Figure 1-2 Microsoft Visual Studio 2019’s start window showing the list of project
templates

Tutorial: Using .NET Core SDK Previews and


configurations
In this section, I will show you how to use some templates for .NET
Core projects and how to configure Microsoft Visual Studio 2019 to use
the .NET Core preview implementations.

Configuration for Using the .NET Core SDK Previews


To use the .NET Core SDKs in a preview version, you need to change the
configuration of Microsoft Visual Studio 2019.
Select the Tools ➤ Options menu item to open the Options dialog.
Open Environment on the left and select Preview Features. Select “Use
previews of the .NET Core SDK, as shown in Figure 1-3. This allows
Microsoft Visual Studio 2019 to include the .NET Core SDK preview
versions in the list of target frameworks for the projects.
Figure 1-3 The Options dialog, showing the “Use previews of the .NET Core SDK”
setting

Adding a Class Library (.NET Core) Project


Now, with the configuration for the .NET Core SDK previews done, open
the start window. For this tutorial, choose the Class Library (.NET Core)
template and name it RVJ.Core.
For the path, I’m using a temporary folder, as shown in Figure 1-4,
because this project is just a demonstration. If you want to get the
solution and projects for this tutorial, you can find them in this folder:
<install_folder>\Projects\RVJ\2019\Platforms\CLR\C
ode\ExploringDotNETCoreRuntime30\Ch01\Tutorial\.
Figure 1-4 Specifying the name of the project and solution, as well as the location
After the project has been created, you’ll see the standard
development environment that you probably know from previous
versions for developing applications, libraries, and components for the
Microsoft .NET platform.

Choosing the Target .NET Core SDK


On the Application page of the Project Properties window, you’ll see the
“Target framework” list with all the .NET Core SDKs available, including
the preview versions, as shown in Figure 1-5.
Figure 1-5 The list of the .NET Core SDKs available, including the preview versions

Changing the Project Config File


In the Solution Explorer, double-click the project name to open the
content of the project file in the source code editor, as shown in Figure
1-6. There’s also IntelliSense support for project files, as shown in
Figure 1-7.
Figure 1-6 Content of the RVJ.Core.csproj project file

Figure 1-7 IntelliSense is available for the content of .NET Core project files

Using a TFM on the Project Config File


As shown in Figure 1-8, when specifying the target framework for .NET
Core, you can use a TFM in the project file. The TFM specifies the target
framework and, consequently, the sets of APIs available for an
application or library.

Figure 1-8 The sets of APIs used for an application or library are specified using
TFMs for the target framework

Using .NET Standard


The .NET Core or .NET Framework applications and libraries can also
target a version of .​NET Standard, which is a standardized set of APIs
that work across all .NET implementations. Using a library such as the
RVJ.Core sample project, it’s possible to target .NET Standard and gain
access to APIs that work across .NET Core and .NET Framework using
the same codebase. In Listing 1-1, I have changed the
RVJ.Core.csproj project file to use .NET Standard version 2.1.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- Target Framework Moniker (TFM) -->
<!--
<TargetFramework>netcoreapp3.0</TargetFramework>--
>
<TargetFramework>netstandard2.1</TargetFramewo
rk>

</PropertyGroup>

</Project>
Listing 1-1 Configuration File Using .NET Standard 2.1
After this update, the “Target framework” field on the Application
page of the Project Properties window is automatically updated, as
shown in Figure 1-9.

Figure 1-9 The “Target framework” field on the Application page of the Project
Properties window is automatically updated

List of TFMs
At the time of writing, the following TFMs are currently supported by
project files:
.NET Standard:
netstandard1.0
netstandard1.1
netstandard1.2
netstandard1.3
netstandard1.4
netstandard1.5
netstandard1.6
netstandard2.0
netstandard2.1
.NET Core:
netcoreapp1.0
netcoreapp1.1
netcoreapp2.0
netcoreapp2.1
netcoreapp2.2
netcoreapp3.0
.NET Framework:
net11
net20
net35
net40
net403
net45
net451
net452
net46
net461
net462
net47
net471
net472
net48
Universal Windows Platform:
uap (instead of uap10.0)
uap10.0 (instead of win10 or netcore50)
There are a number of deprecated TFMs that should be updated.
The following are the deprecated TFMs and their replacements:
The TFM netcoreapp is the replacement for the following deprecated
TFMs:
aspnet50
aspnetcore50
dnxcore50
dnx
dnx45
dnx451
dnx452
The TFM netstandard is the replacement for the following
deprecated TFMs:
dotnet
dotnet50
dotnet51
dotnet52
dotnet53
dotnet54
dotnet55
dotnet56
The TFM uap10.0 is the replacement for the following deprecated
TFMs:
netcore50
win10
The TFM netcore45 is the replacement for the following deprecated
TFMs:
win
win8
winrt
The TFM netcore451 is the replacement for the following deprecated
TFMs:
win81
If migrating or developing a .NET project that supports both the
.NET Framework and .NET Core, use the <TargetFrameworks/> tag
(plural), instead of the <TargetFramework/> tag (singular). The use
of the <TargetFrameworks/> tag is also required when using
multiple versions of the same framework (that is, the .NET Framework
or .NET Core) for the same project.
Listing 1-2 shows the RVJ.Core.csproj sample project file using
the <TargetFrameworks/> tag for supporting netcoreapp3.0 and
net48.

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- Target Framework Moniker (TFM) -->

<TargetFrameworks>netcoreapp3.0;net48</Targe
tFrameworks>

<!--
<TargetFramework>netcoreapp3.0</TargetFramework>--
>
<!--
<TargetFramework>netstandard2.1</TargetFramework>-
->
</PropertyGroup>

</Project>
Listing 1-2 Project File Supporting netcoreapp3.0 and net48 Using the
<TargetFrameworks/> Tag

When supporting various target frameworks, you need to make a


change in the source code, because not every .NET type exists in every
implementation of the target .NET library. Specifically, you need to use
the preprocessor directives for conditional inclusion of blocks of source
code, depending on the configured target frameworks. Listing 1-3
shows the RVJ.Core source code with the conditional symbols for
netcoreapp3.0 and net48. At the time of writing, this is the list with
conditional symbols representing the TFMs.
For the .NET Framework, the conditional symbols are as follows:
NETFRAMEWORK
NET20
NET35
NET40
NET45
NET451
NET452
NET46
NET461
NET462
NET47
NET471
NET472
NET48
For .NET Core, the conditional symbols are as follows:
NETCOREAPP
NETCOREAPP1_0
NETCOREAPP1_1
NETCOREAPP2_0
NETCOREAPP2_1
NETCOREAPP2_2
NETCOREAPP3_0
For .NET Standard, the conditional symbols are as follows:
netstandard
netstandard1_0
netstandard1_1
netstandard1_2
netstandard1_3
netstandard1_4
netstandard1_5
netstandard1_6
netstandard2_0
netstandard2_1

namespace RVJ.Core {
public class NETLibrary {
#if NET48

#elif NETCOREAPP3_0

#endif

}
};
Listing 1-3 RVJ.Core Source Code with Symbols for netcoreapp3.0 and net48
In Figure 1-10 and Listing 1-4, there’s an example of a .NET type
that has the functionality available from the .NET Framework 4.8
implementation but does not have the same functionality available in
the .NET Core 3 (preview 5) implementation. The Microsoft Visual
Studio 2019 IntelliSense in the source code editor shows the
information, helping developers make the right decisions when using
the .NET types.

Figure 1-10 Microsoft Visual Studio 2019 IntelliSense in the source code editor
helping developers make the decisions when using .NET types

using System.Reflection;
using System.Reflection.Emit;

namespace RVJ.Core {
public class NETLibrary {

static void SampleMethod() {


Random documents with unrelated
content Scribd suggests to you:
Answer, that I had a letter from Lord Lewis Gordon for your
Lordship, which I forwarded by Express, was very peremptor,
Lord Lewis had given no orders for making the least demand
upon your Lordships Estate before its Return, so I expected
that none concerned in him, would offer to do it before that
Time, yet notwithstanding thereof, I had the inclosed this day
from William Taylor, to which I answered that as I sent Lord
Lewis Letter to your Lordship per Express, I could neither give
answer nor advice to his Letter, but that I expected that none
concerned in Lord Lewis would have made any demand of
your Lop. Estate before I had your Answer. As likeways that
they would have defered compounding the matter untill that
Time. David Tulloch[662] is just now at Banff with about 60 or
80 men and as I am told demands no fewer Levies from that
Town as 200 men. Birkenbush was here last night, and told me
that as it is not in his power to get your Lordships Estate saved
in such a way as he would have desired has utterly refused
having any Concern in uplifting the Levies from that Bounds,
for which I have been very angry at him; but it cannot now
help. To appearance Mr. Tulloch or Abbachy will be soon here,
and unless your Lordship fall upon some shift for relief to us,
we shall suffer extremely.
[544] App. 28. C. of G., ii. 192. (From Castle Grant.)
[545] App. 29. Earl of Findlater to Mr. Grant, dated 13th
Dec.—After despatching the short letter I wrote you this
morning, which is inclosed, I received the Inclosed from the
President. All that I shall say is, that all their Proceedings will
not secure our Safety unless a Sufficient right and Trusty Party
is left in Banffshire for Lord Lewis’s small partys will stir as
soon as they are past, if there is not force enough to suppress
them. You know the State of my health makes it impossible for
me to attend Lord Loudoun and make things agreeable to him
as I would wish. I have writ to Tochineil[663] and John and
William Ogilvies Sheriffs deputes to do their duty the best they
can in all respects; but I am not without my own Fears that
Fear and trembling for after Consequences may make some if
not all of them extremely unwilling to act. Perhaps even they
may decline it. You know you have full Power in everything
that concerns me, to do what you think proper and I have full
confidence you will do whatever you think right; but least some
thing more formal should be requisite, with regard to the office
of Sheriff I hereby give you full Power to act as Sheriff Depute
of Banffshire and to employ such substitutes under you as you
shall think fitt, for which this shall be to you and them a
sufficient warrant and Commission, I always am most
affectionately and entirely yours.
P.—My son intends to go down by Forress to wait of Lord
Loudoun tomorrow; but as he continues extremely ill off the
Cold I am uncertain if he will be really able to go. I begg you
will send the Inclosed to Tochineil by some sturdy clever Man
because the bearer is feckless and too well known, and may
be searched for Letters. It contains orders for Tochineil, John
and William Ogilvies to attend my Lord Loudoun. Keep the
Presidents letter. Your wife opened the inclosed from Robert
Grant.
[546] App. 30. C. of G., ii. 189. (From Culloden.) This letter
contains a postscript saying that Lord Loudoun ‘had prevailed
with Lord Lovat to come in with him to town [Inverness] to
reside at liberty there till the present confusions are over, to
deliver up what arms he has, and to sign all proper orders to
his clan to remain quiet. Loudoun brings him on with him to-
day 11th [Dec.] 9 a clock in the morning.’
[547] Boat o’ Bridge, the ferry on the Spey near the mouth
of the Mulben burn, now superseded by a road and a railway
bridge.
[548] Sir Harry Innes of Innes (Morayshire), 5th bart. Suc.
1721; d. 1762. He was a brother-in-law of Ludovick Grant,
married to his sister Anne. Innes’s son James suc. as Duke of
Roxburghe on the death of the 4th duke in 1805.
[549] App. 31. C. of G., ii. 193. (From Elgin.) Macleod will
most cheerfully act in conjunction with Grant in everything
thought proper.
[550] Bog, the local name for the site of Gordon Castle,
built on the Bog o’ Gight (windy bog). The ferry there was
known as the Boat o’ Bog; it is now superseded by Fochabers
Bridge.
[551] App. 32. Mr. Grant to M‘Leod, dated 15th Dec.—I
have just now the Pleasure of yours by our Friend Sir Harry
Innes. I shall as soon as I get my Men conveened march to
Fochabers and endeavour to get Possession of the Boats, and
shall do all in my Power to secure the passage for the Men
under your Command. I am hopefull the Rebells wont be able
to give much disturbance.
[552] App. 33. Lord Lewis Gordon to Mr. Grant, dated
Fyvie, 16th Dec.—I was a little surprised this morning to hear
that you had marched a body of your Men to the low Country
so far as Mulben. Your Reason for such Proceedings I cant
find out, as you have not got the least disturbance from the
Prince, or any of his Friends, since his Royal Highness arrival
in Scotland. And for my part I have not given you the least
disturbance, since my coming to the North. So far from it, that I
have given positive orders to the Gentlemen employed by me
to raise the Levies, not to meddle with any of your Estate no
not so much as to raise a man from a little Place called
Delnaboe, which holds of the Duke of Gordon, to the men of
which last place, I had a natural Title. I now desire to know, if
you are to take any Concern in protecting the Estates of any
but your own. If that is the case, I must take my Measures
accordingly, and as the Consequence must be fatal you have
none to blame but yourself. I am this minute writing to Lord
John Drummond that he may march his Troops directly to this
Country to join the men I have already raised; but if you
withdraw your men, and give no further disturbance, it may
move me to alter my Resolutions with respect to you. I wrote
you a Letter from Strathdoune but was not favoured with any
Return, but must insist on an answer to this in writing or by
some Gentleman of Character. Offer my Complements to Lady
Margaret and your young Family.—I am with much Respect,
etc.
Copy Printed Declaration of Lord John Drummond,
Commander-in-Chief of his Most Christian Majesty’s Forces in
Scotland.—We, Lord John Drummond, Commander-in-Chief of
his most Christian Majesty’s Forces in Scotland, do hereby
declare, that we are come to this kingdom with written orders
to make war against the King of England, Elector of Hannover,
and all his adherents, and that the positive orders we have
from his most Christian Majesty are to attack all his ennemys
in this Kingdom, whom he has declared to be those, who will
not immediately join or assist as far as will ly in their power, the
Prince of Wales, Regent of Scotland his Ally, and whom he is
resolved with the concurrence of the King of Spain to support
in the taking possession of Scotland, England and Ireland, if
necessary at the expence of all the men and money he is
master of, to which three Kingdoms the Family of Stewart have
so just and indisputable a title. And his most Christian
Majesty’s positive orders are, that his ennemys should be
used in this Kingdom in proportion to the harm they do, or
intend to his Royal Highness’s cause. Given at Montrose, the
2nd day of December 1745 years.
J. Drummond.
Copy Printed Letter from Earl Marshall to Lord John
Drummond, dated Paris, 1st Nov.—My Lord,—As I am now
obliged to attend the Duke of York to England, with a body of
French Troops, I desire that you will be so good as to see if
possible, or send word to the people that depend on me or
have any regard for me in Aberdeenshire, or the Mearns, that
are not with the Prince, that I expect they will immediately rise
in arms, and make the best figure they can in this affair, which
cannot now fail to succeed, and that they will take from you,
my Cousin German directions, as to the manner they are to
behave on this occasion.
I am sorry that just now it is not in my power to head them
myself; but as soon as this affair will be over, I intend to go
down to my native country and they may depend of my being
always ready to do them what service will ly in my power.

Marshal.[664]
Directed to Lord John Drummond, Brigadier of the
King’s Army and Colonel of the Royal Scots at
Dunkirk.
Copy Printed Letter from Lord John Drummond to William
Moir of Loanmay, Esquire, Aberdeen 11th Dec.—Sir,—You
will be pleased to communicate the contents of this letter to
such gentlemen of your country as are well affected to the
Prince Regent, and who retain regard for the Earl Marshall,
and assure them that what may be necessary for effectuating
the ends proposed shall be heartily supplied by me, and I am,
Sir, your most humble servant,
J. Drummond.
Addressed to Willm. Moir of Loanmay, Esq.,
Deputy Governor of Aberdeen.
[553] App. 34. C. of G., ii. 199. (From Cullen.) Grant’s letter
gives him vast joy; Culcairn will be with Grant to-morrow, while
Macleod will go to Banff and thence to Turriff and Old
Meldrum.
Culcairn to Mr. Grant, dated 17th Dec.—I came here this
day with Captain William Macintoshes Company and mine,
and have written to the Laird of M‘Leod telling my coming here
and Resolution of going tomorrow to Cullen etc. and therefore
pray acquaint me how affaires are with you. I wrote also to the
Laird of M‘Leod to acquaint me how affaires are with him.—I
am, Dr Sir, yours etc.
The following note was inclosed—
All the Information that is known here about the Rebells,
who fled Out of Fochabers, is that they all marched to Huntly,
and about 6 men as computed abode in Newmilns Sunday
night and on Monday followed to Huntly. There is no word yet
from Lord Loudon.
[554] App. 35. Declaration published at Strathbogie by Mr.
Grant, dated 18th Dec.—Whereas many of his Majesty
Subjects have been compelled by Force and Threats to enlist
in the Service of the Pretender, whilst there was no Force
sufficient to protect them. If any such shall resort to me, and
deliver up their arms, I shall signify their dutiful Behaviour in
this point, to the end that it may be a motive to obtain their
pardon from his Majestys Grace and will endeavour to free all
of illegal and treasonable Levies of men and money; but such
as presumes to persist in their treasonable Practices and to
resist will be treated as Traitors.
[555] App. 36. C. of G., ii. 194. (From Inverness.)
Loudoun’s letter after applauding Grant’s zeal is very much the
same as Lord Deskford’s letter which follows.
[556] App. 37. Lord Deskfoord to Mr. Grant, dated 14th
Dec.—I am now with Lord Loudon and in a conversation with
him, I find that he is Sorry he has not Sufficient authority as yet
from the Government either to give Pay to any Clan, except
when an immediate necessity which cannot be answered by
the Troops upon the establishment requires it, nor has he any
arms to dispose of to the Friends of the Government, scarcely
having sufficient arms here for the independent companies
and his own Regiment. This being the Case and the Service in
the Countrys of Banff and Aberdeenshire being sufficiently
provided for by the 700 men already sent to that Country, it is
impossible for him to take your men into Pay, and as your
arms are certainly not extremely good, and he cannot give you
others, I believe he would be as well pleased, that your People
should go back to Strathspey; but he does not care to take it
upon him to order them back, as the thing was undertaken
without his Commands. If you carry your People home, he
wishes you gave M‘Leod Information of it because he must
regulate his motions accordingly with the independent
Companys. He says he wont fail to represent your Zeal and
that of your People, and wishes for the future nothing may be
undertaken but in concert with those who have the Direction of
the Kings affaires in this Country. Pray let us hear what you do.
Loudon who is much your Friend assures me of another Thing
which is that the first opportunity that offers of employing any
People in a way to make them make a figure he will most
certainly throw it into your hands. I hear there are more Troops
to march eastward tomorrow. When Lord Loudon sets out
himself is not certain.—I am, Dear Sir, etc.
As the Governor commands here in Lord Loudons absence
My Lord says he will chuse to leave the Grants here with him,
that he may have one Company that he may entirely depend
upon.
[557] App. 38. C. of G., ii. 201. (From Huntly.) Grant writes
he has a letter from Loudoun intimating he should not have
marched further than Keith, and he will return there next day.
Culcairn and Mackintosh want to join Macleod at Inverurie to-
morrow night.
An enclosure contains the following lines, which naturally
were not sent up to Government, and are not in the Record
Office. They are taken from The Chiefs of Grant:—

‘Lord Loudoun will not act as Cope,


Whose ribbon now is call’d a rope;
If Grant is armed to join M‘Leod
The enemy is soon subdued.’

[558] App. 39. C. of G., ii. 200. (From Banff.) Macleod very
sorry that Grant is not to join him at Inverurie, but he knows
best what Loudoun has directed.
[559] App. 40. C. of G., ii. 202. (From Castle Grant.)
[560] App. 41. C. of G., ii. 205. (From Elgin.)
[561] For a detailed account of the action at Inverurie on
23rd December, see ante, p. 140 et seq.
[562] App. 42. Mr. Grant to the Magistrates of Elgin, dated
29th Dec., in answer to their Letter following.—I received your
Letter of yesterdays date signed by you and the Magistrates of
Elgin, informing me that Macleod and his men were then
marching from your Town towards Inverness and that you are
now exposed to the same oppression with the other Burghs to
the East. As you had Intelligence that there are 500 men ready
at Strathbogie to come over, who have sworn heavy
vengeance against you. How far it may be in my Power to give
them a check, and to prevent the oppression they threaten you
with, I dare not positively say; but I assure you, I have all the
Inclinations in the world to be of as much Service to my
Friends and neighbours during these troublesome Times as I
possibly can. Upon the 10th of this month I was informed that
the Party under Abbachys Command was levying the Cess
and raising men in a most oppressive manner in Banffshire,
and that they were to detach a large Party to your Town, and
were threatning to use the same acts of violence against you.
As at that Time I knew nothing of the Relief that was acoming
to you from Inverness. I conveened upon the 12th the most of
the Gentlemen of the Country and about 500 of the men, and
marched directly to Mulben with an Intention to cover your
Town and Country, and to assist my Friends and neighbours in
the County of Banff. All this I did without any advice or Concert
with those entrusted at Inverness, only the very day I marched
from this, I wrote and acquainted them of my Intention; but as
they imagined they had sent Force sufficient to clear all betwixt
them and Aberdeen, I found it was not expected that I should
proceed further than Keith or my own Estate of Mulben;
however as I was resolved to chase the Rebells out of
Banffshire, if in my Power I proceeded to Strathbogg where I
remained two nights, and then finding that I was not desired or
encouraged to go further, I returned home, leaving a party of
60 men, with officers in Mulben to prevent any small partys of
the Rebells either from visiting you or oppressing that
neighbourhood. My Party continued there till all the M‘Leods
had passed in their way to Elgin; but then the officers there
thought it was not proper for so small a body to remain longer,
when Such numbers of the Rebells were so near them. My
present opinion is that you may all be easy, unless you hear
that a much greater body come from Aberdeen to join that at
Strathbogie for these at Strathbogie will never venture to cross
Spey, when I am above them and Lord Loudon is so near
them. Altho the MacLeods have marched to Inverness, I am
persuaded Lord Loudon will send another body sufficient to
give a check to those at Strathbogie. In the situation I am at
present in I am uncertain whether I am to be attacked from
Perth or by those at Aberdeen and Strathbogie for my late
March. I dare not promise to march with any body of Men but
in Concert and with Lord Loudons Directions. And at the same
Time I have demanded to be assisted with arms, and
encouraged to keep my Men in the proper way. There is no
body can wish the Peace and happiness of my Friends in the
Town of Elgin than I do. And I shall always be ready to use my
best Endeavours towards preserving the Tranquility you at
present enjoy.—I am, etc.
The Magistrates of Elgins Letter to Mr. Grant, dated
December 28th, 1745.—The Laird of M‘Leod and his Men are
this moment marching from this Place towards Inverness, so
that we are left exposed to the like Ravage and oppression
which other Burghs and Counties to the East of us labour
under. And unless we be immediately favoured with your
Protection, we and many others of the principal Inhabitants
must remove with our best effects to some Place of Safety
without loss of Time. By Intelligence we have from the other
side of Spey there are 500 at Strathbogie ready to come over
and who have threatned a heavy vengeance upon us, so that
we have all the Reason in the World to guard against the Blow
in some shape or other. We therefore begg you may give us a
positive and Speedy Answer. And we are respectfully, Honble
Sir, Your most humble Servants.
[563] App. 43. Sir Harry Innes to Mr. Grant, dated 28th Dec.
—The desertion among all the Companys has been so great
that M‘Leod is resolved to march to Forress, and for ought I
know to Inverness. This will lay this Town and Country open to
the Insults of the Rebells. Therefore the Magistrates have writ
you and have desired me to do the same, desiring you may
march Such a body of your Men here as will secure the Peace
of the Country and Town; but as you are best Judge of this.—I
am, Dr Sir, etc.
P.S.—We had yesterday the accounts of the Highland
Armys being totally routed and dispersed betwixt Manchester
and Preston betwixt the 13th and 14th. The Prince as he is
called flying in great haste with about 100 horse. The Duke of
Perth amongst the Prisoners. If M‘Leod marches I must with
him or go to you, but I think I shall go to Inverness for I am not
liked at present by many.
Sir Harry Innes to Mr. Grant, dated 28th Dec., probably
from Innes House.—I wrote you this forenoon from Elgin,
which I suppose would or will be delivered to you by one of the
Council of Elgin. As M‘Leod was then resolved upon Marching
here, they were determined to apply to you for some Relief
and Support for their Town and Country in General. I have and
must do M‘Leod Justice. He is far from loading you with any
share of their late unlucky disaster, and would willingly act in
Concert with you for the Common well, but to his great
Surprise when he came here, he found that his men who had
deserted in place of going to Inverness had mostly past from
Findorn to the Ross side. So he does not know when or where
they may meet. This has hindered him from writing to you to
desire you to bring your men to Elgin in order to act with his.
Altho he had desired this from no other authority, or any
Reasons, but your doing the best for the common Cause, but
this unlucky passing of his men at Findorn has prevented his
writing as he told the Provost of Elgin he was to do. For these
Reasons I run you this Express that you may think how to act.
I go to Lord Loudon and the President tomorrow, and will
return to M‘Leod Monday forenoon.—My Complements, etc.
P.—The President writ me that Lord Deskfoord is gone for
London in the Hound and that they sailed the 25th.
[564] App. 44. C. of G., ii. 208. (From Inverness.)
[565] App. 45. Mr. Grant to Lord Loudon, dated the 9th
Jany 1745-6.—Inclosed your Lordship has a letter I received
this day from John Grant Chamberlain of Urquhart. The
subject contained in it gives me the greatest uneasiness. I
thought I had taken such measures as to prevent any of the
Gentlemen or Tenants of that country from so much as
thinking to favour the Rebells far less to join them. I have sent
the Bearer James Grant my Chamberlain of Strathspey, who
has several Relations in that Country to concur with John
Grant my Chamberlain of Urquhart in every Measure that can
prevent these unhappy People from pursuing their Intentions
of joining the Rebells. And I have ordered him to obey any
further Orders or Instructions your Lordship shall give him for
that purpose, and I am hopefull I’ll get the better of that mad
villain Currymony who is misleading that poor unhappy
People.
That I may not weary your Lordship, I’ll leave to him to tell
you all that he knows relating to that country. I have just now
received the Inclosed from Lord Strechin by Mr. Sime Minister
of Longmay: My Lord Strichen did all in his Power to save my
Friend Lieutenant Grant from being taken Prisoner, even to the
hazard of his own Life. I would gladly march to relieve him as
my Lord Strichen suggests in his Letter, but I take it for granted
that that Thing is impossible, for I could not march to that
Country with any Body of men but the Rebells must have
notice of it, and would send my Friend to Aberdeen and so
forward to Glames, where the rest of the Prisoners are. I am
hopeful the Kinghorn Boat on board of which my Friend came
to Fraserburgh is by this time arrived at Inverness, but least it
should not, I send your Lordship with the Bearer the two last
Newspapers from Edinr, which came by Lieutenant Grant who
luckily delivered them with my Letters to Lord Strichen, before
he was made Prisoner. And I must refer it to the Bearer to
inform your Lorp. of the manner of Mr. Grant’s landing and
being taken Prisoner. Mr. Syme who brought me Lord
Strichens letter informs that Mr. Grant told that part of the
Duke of Cumberland’s horse arrived at Edinburgh Wednesday
last. That the Duke of Cumberland arrived at Edinburgh on
Thursday last with a great body of horse, and the foot were
following. I think it my duty to take notice to your Lop. that the
Rebells are exerting themselves in every corner of the North to
increase their army. I therefore think it absolutely necessary
that all the Friends of the Government should use their
outmost efforts to disconcert and disperse them. I had a
meeting yesterday with all the Gentlemen of this Country, and I
can assure your Lop. we wait only your orders and Directions,
and there is nothing in our Power, but we will do upon this
important occasion for the Service of our King and Country. I
wish it was possible to assist us with some arms, and money
to be sure also would be necessary; but give me Leave to
assure your Lordship that the last farthing I or any of my
Friends have, or what our Credite can procure us, shall be
employed in supporting of our men upon any Expedition your
Lordship shall direct us to undertake for this glorious Cause
we are engaged in. I wish to God your Lordship and the Lord
President would think of some measure of conveening the
whole body of the Kings Friends in the north together, and I
would gladly hope we would form such a body, as would in a
great measure disconcert and strike a damp upon the army of
the Rebells in the South, and effectually put a stop to any
further Junctions they may expect benorth Stirling and at the
same Time surely we might prevent their being masters of so
much of the North Coast, and also hinder many of the Kings
Subjects from being oppressed by the exorbitant sums of
money the Rebells are presently levying from them.
Complements etc.
[566] App. 46. Lord Loudon to Mr. Grant, dated 16 Jany.
1745-6.—I have had the Honour of two Letters from you since
I had an opportunity of writing to you. I think your scheme of
relieving the low Country is a very good one; but in the present
situation until I have a Return of the Letters I have sent for
Instructions, and a little more certainty of the motions of the
Rebells, I dare not give them any opportunity of Slipping by the
short road over the hills into this Country and of course into
possession of the Fort. Whilst I am in the low Country, as soon
as Instructions arrive, I shall be sure to acquaint you, and
consult with you the most effectual way of doing real Service
to our Master and our Country. I begg my Complements etc.
[567] The Prince arrived at Blair Castle 6th February, and
left on the 9th.
[568] App. 47. C. of G., ii. 222. (From Inverness.) Giving
news of the abandonment of the siege of Stirling Castle by the
Jacobites and their retreat to the north. The desertion among
them has been very great, and it will take time to re-collect
their people before they can hurt us.
[569] App. 48. Intelligence sent to Lord Loudon by Mr.
Grant, 9th February 1746.—Last Thursday Mr. Grant sent by a
Ministers son not having had time to write, being busied in his
own Preparations, Intelligence of the Rebells motions, and
what was said by some of their leaders to be their Intention.
Saturday morning he wrote M‘Leod the substance of it with
the orders then brought to Badenoch, which as M‘Leod would
forward was unnecessary for Mr. Grant to do. Since the above
many confirmations of it have arrived but nothing new all this
day.
The inclosed is a copy of their Resolutions taken at their
Meeting in Badenoch, where Cluny was present and approved
of them.
Many of the M‘phersons came home before Cluny and
many of them expressed Resolutions not to be further
concerned; but how far they will be steady is uncertain.
It is said by pretty good authority, that the Glengerry men
after the Interment of Angus MacDonald openly and in a body
left the army, and many of the Camerons followed their
example. It is certain most of Keppoch’s men were at home
some time ago, but people are sent to use their outmost
Endeavours to bring all the above back, and influence what
more they can, for which purpose it is said they will remain at
least two days at Badenoch.
Their Prince was said to be at Cluny last night, but the men
remaining with him, and coming through the hills to be only in
the Country this night.
A deserter from those coming by the Coast, and who only
left them in Angus, says Duke Cumberland was entering
Stirling, as last of their army was going out, Confirms the great
desertion since the battle, and asserts it continues dayly, also
that there is no division coming by Braemar.
The above Deserters and others and Letters say that
Clanhatton, Farquharsons, French, Pitsligo, Angus, Mearns
and Aberdeenshire People came by the Coast for whom Billets
were ordered last Wednesday at Aberdeen, and that some
M‘Donalds, M‘Kenzies, Frasers, M‘Leods, Camerons,
Stewarts, M‘Phersons, Athole and Drummond men are coming
by the Hills.
Some Clatters say they wont disturb Strathspey, and others
that it is their formed Plan to march through and disarm it, and
join the rest in Murray. The Truth is not yet known. There are
some Rumours from the South that part of the Duke’s Army
are following briskly by the Coast, and that upon the Rebells
leaving Stirling, two Regiments were ordered to embark for
Inverness. Mr. Grant and all his Friends have been alert as
desired. Many spyes are employed and what is material shall
be communicated.
The Bearer will explain Mr. Grants numbers and present
distribution of them, with the various Instructions given for the
different occurences that may happen. In the general it may be
depended upon, that Mr. Grant will act zealously with his
whole Power in every shape that shall be judged best, suitable
to the hearty Professions he hath all along made, and upon a
closer scrutiny finds he could bring furth 5 or 600 more good
and trusty men if he had arms, than he can in the present
condition. If there are arms to be given the Bearer will concert
their Conveyance.
Sunday 8 at night. This moment fresh Intelligence arrived
from Rothemurkus as follows. It confirms most of what is
above.
They are ignorant in Badenoch of the present root of the
army, and conceal their Losses as much as possible, but
acknowledge they lost considerably before Stirling, and
obliged to leave behind them seven heavy cannon of their
own, and part of their Ammunition and Baggage, with all the
Cannon and Ammunition taken from the King’s army.
That they have brought north all their Prisoners. The Duke
was advanced as far as Perth. Their Prince is to be at Ruthven
tomorrow where his Fieldpieces and five, and some say 9
battering Cannon is arrived. Tho they conceal their designs
with great secrecy the Prisoner officers conjecture their design
is against Inverness. All the men of Strathern are gone home
and to meet the Army in its way to Inverness, which is to go
through Strathspey, and the Division coming by the Coast to
march through Murray. They call these in Badenoch seven
Regiments, made up of the people above mentioned.
That many the writer conversed with declared they were
sick of the present Business, and wish for a sufficient Force to
protect them at home.
One man says he heard their Prince declare he would
quarter next Tuesday in the house of Rothemurkus.
Some means are employed to endeavour to increase the
desertion and to create some dissention. If they prove
effectual the Conclusion will be quicker and easier.
[570] App. 49. C. of G., ii. 225. (From Castle Grant.) A long
letter of various items of intelligence.
[571] App. 50. C. of G., ii. 224. (From Inverness.) Though a
supply of arms has come it is impossible to send them and
men must come for them. He will be glad to consult and co-
operate with Grant. He has brought back troops from Forres
and needs money: will Grant send him the cess he has
collected.
App. 51. C. of G., ii. 223. (From Culloden.) The Aberdeen
rebels much discouraged, for the most part separated, and will
not easily be brought together again. The Jacobites’ intention
is to capture Inverness and force all the neighbourhood into
their service. Glengarry’s and Keppoch’s people and the
Camerons are almost all gone home, but leaders are sent to
fetch them out. All this will give time to the friends of
government.
[572] App. 52. C. of G., ii. 232. (From Castle Grant.) A long
letter of details of intelligence of the movements of the
Jacobite army.
[573] App. 53. Further Intelligence, dated 15th Feb. 1746,
Saturday 7 o’clock at night.—Two persons confirm that Letters
from Lord Loudon, etc., were stopt at Ruthven. One of them
says the Bearer was hanged this morning. Both agree the
Bridges on the road to Athole are broke doun, That the Castle
of Ruthven was burnt last night, and stables this morning. The
Prince to be at Inverlaidnan this night, some of his People in
Strathern,[665] the last at Avemore. The Macphersons to
march to-morrow all for Inverness. Best Judges call them
about 5000. The Campbells were at Blair. The Duke certainly
at Perth the 12th. The Hessians certainly landed at Leith.
Several Expresses for this are stopt. You know better than we
do what is doing in Murray.
[574] Near Carrbridge.
[575] App. 54. Lord Loudon to Mr. Grant, dated Inverness,
15th Feb.—I have been honoured with a Letter from you last
night, and another this morning, and I have seen yours to the
Governor, all with the Intelligence which you have got for
which I am very much obliged to you, and as we have had
notice some time I hope if they do come, we shall be able to
give them such a Reception as they will not like. I expect to be
reinforced with 900 or 1000 men in two days, and every day to
grow stronger. I have thought seriously on every method of
sending you arms; but do not see as we are threatned with an
attack, that I can answer sending such a detachment from
hence. A march that must take up 4 days, as well bring the
arms safe to you. Consider the Clan hattonn[666] are all come
home. The Frasers and the Gentlemen of Badenoch are
appointed to intercept them, and if we have any Business it
must be over before they return. As to the number you
mention, you know how small the number is, I have to give,
and how many demands are made on me, and by people who
are none of them near so well provided as you are. If you can
send down 300 men, I shall endeavour to provide them as well
as I can that is the outmost I can do. You are very good as you
be advanced to send us constantly what accounts you get, but
by all I can learn your accounts magnify their numbers greatly.
I beg you will make my Compliment to all ffriends.—I am with
real Esteem and Sincerity, Dr. Sir, yours etc.
[576] This date not quite right. The ‘Rout of Moy’ took place
on the 17th. Loudoun evacuated Inverness on the 18th, and
the Jacobite army reached the town the same day. The castle
(Fort George), garrisoned partly by Grant’s company and
commanded by his uncle, surrendered to the Prince on
February 20th. (Scots Mag., viii. p. 92.)
[577] Sir Everard Fawkener, secretary to the Duke of
Cumberland; b. 1684; originally a London mercer and silk
merchant; the friend and host of Voltaire in England 1726-29;
abandoned commerce for diplomacy; knighted and sent as
ambassador to Constantinople 1735; became secretary to the
Duke of Cumberland, and served with him in the Flanders
campaign; for his services was made joint postmaster-general
1745; accompanied the Duke throughout his campaign in
Scotland 1746; d. 1758.
[578] The Duke of Cumberland arrived at Aberdeen on
February 27th or 28th.
[579] Not the modern Castle Forbes on the Don, in Keig
parish, but the old Castle Forbes at Druminnor, in the parish of
Auchindoir and Kearn.
[580] Cumberland crossed the Spey on April 12th.
[581] Fort Augustus surrendered to the Jacobites, March
5th.
[582] Alexander, the father, had died, a prisoner, before
29th July. He died a natural death, but in Glenurquhart it was
believed that he was burned to death in a barrel of tar. (Wm.
Mackay, Urquhart and Glenmoriston, p. 288.)
[583] Not dated, but must have been written before 29th
July, i.e. prior to Sheugly’s death.
[584] Sir Dudley Ryder (1691-1756) was Attorney-General
1737-54; prosecuted the Jacobite prisoners of 1746; appointed
Lord Chief-Justice, 1754; cr. Baron Ryder of Harrowby 1756,
and died the same year.
[585] Hon. William Murray (1705-92), fourth son of David,
5th Viscount Stormont. He was Solicitor-General 1742-54, and
the active prosecutor of Lord Lovat; Attorney-General 1754-56;
Lord Chief-Justice 1756-88; created Baron Mansfield 1756,
and Earl of Mansfield 1776. His father and eldest brother were
denounced as rebels, fined and imprisoned for their conduct in
1715. His brother James (c. 1690-1770) attached himself to
the court of the Chevalier de St. George; in 1718 he was
plenipotentiary for negotiating the marriage of James. In 1721
he was created (Jacobite) Earl of Dunbar, and he was
Secretary of State at the court in Rome, 1727 to 1747; he was
dismissed in the latter year at the desire of Prince Charles,
who deemed him responsible for the Duke of York’s entering
the Church; he retired to Avignon, where he died s.p. in 1770.
Murray’s sisters entertained Prince Charles in the house of
their brother, Lord Stormont, at Perth from the 4th to the 10th
April 1745.
[586] Solicitor to the Treasury.
[587] This report is printed, post, p. 400.
[588] Alexander Grossett, a captain in Price’s Regiment
(14th, now P. of W. O. West Yorkshire). An engraving, dated
14th Jan. 1747, entitled ‘Rebel Gratitude,’ depicts the death of
Lord Robert Ker and Captain Grossett at Culloden. About the
latter the following legend is engraved on the print: ‘Captain
Grosett, Engineer and Aid de Camp to the General.’ The rebel
‘shot Captain Grosett dead with his own pistol which happened
accidentally to fall from him as he was on Horseback, under
pretence of restoring the same to the Captain.’ Grossett had
been aide-de-camp to General Handasyde; he was serving on
General Bland’s staff at Culloden, according to family tradition.
[589] Sir John Shaw of Greenock, 3rd bart.; he was a
cousin of Grossett’s. I have failed to find his name in any
record of officers connected with the customs or excise at this
time. His father, whom he succeeded in 1702, had been ‘one
of H.M. principal tacksmen for the Customs and Excise,’ a pre-
Union appointment, and it is possible that the son succeeded
to his father’s office or to some of its perquisites. Sir John was
M.P. for Renfrewshire 1708-10; for Clackmannanshire 1722-
27; and again for Renfrewshire 1727-34. He married Margaret,
d. of Sir Hew Dalrymple of North Berwick 1700, and died 1752.
[590] Letter i. p. 379.
[591] Brigadier-General Thomas Fowke was the officer left
by Cope in command of the cavalry stationed at Stirling and
Edinburgh when he went on his march to the Highlands.
Fowke fled with the cavalry on the approach of the Jacobite
army, and joined Cope at Dunbar. He was present, second in
command, at Prestonpans. His conduct, along with that of
Cope and Colonel Peregrine Lascelles, was investigated by a
military court of inquiry, presided over by Field-Marshal Wade
in 1746. All were acquitted.
[592] I have failed to find this narrative, but it matters little,
as all that Grossett had to say was probably given in his
evidence at the trial of Lord Provost Stewart, an account of
which was printed in Edinburgh, 1747. It is accessible in public
libraries.
[593] See ante, p. 127.
[594] This refers to the capture of Charles Spalding of
Whitefield, Strathardle in Atholl, a captain in the Atholl brigade.
He was sent from Moffat on 7th November by William,
(Jacobite) Duke of Atholl, to Perthshire with despatches, and
carried a large number of private letters, which are preserved
in the Record Office. He was made prisoner near Kilsyth.
There is no mention of Grossett’s presence in the journals of
the day, the credit of the capture being given to Brown, the
factor of Campbell of Shawfield. (Chron. Atholl and
Tullibardine, iii. 86; Scots Mag., vii. 540.) Spalding was tried for
his life at Carlisle the following October and acquitted.
[595] The Lord Justice-Clerk had retired to Berwick when
the Jacobite army occupied Edinburgh. That army left
Edinburgh for good on 1st November, but the Justice-Clerk
and the officers of State did not return until the 13th.
[596] Lieut.-Gen. Roger Handasyde superseded Lieut.-
Gen. Guest as Commander-in-Chief in Scotland on his arrival
in Edinburgh on 14th November, and held that office until
December 5th, when he returned to England. Guest again
acted as Commander-in-Chief until relieved by Lieut.-General
Hawley, who arrived in Edinburgh on 6th January 1746.
The two infantry regiments that accompanied Handasyde
were Price’s (14th) and Ligonier’s (48th). They remained at
Edinburgh until December, but after the landing at Montrose of
Lord John Drummond with the French Auxiliaries (22nd
November), it was felt necessary to guard the passage of the
Forth with a stronger force, and the Edinburgh garrison was
sent to Stirling, Price’s on 6th December and Ligonier’s on the
9th, where they were joined by the Glasgow and the Paisley
militia. The cavalry were also sent to the neighbourhood of
Stirling, and Edinburgh was left with no defence but some
volunteers and afterwards by an Edinburgh regiment enlisted
for three months’ service, of which Lord Home was
commandant.
[597] Letters ii.-iv. pp. 379-382.
[598] Letter v. p. 383.
[599] Letter viii. p. 385.
[600] Letter ix. p. 386.
[601] Letter x. p. 387.
[602] The Glasgow regiment was then five hundred strong.
It was commanded by the Earl of Home, who was also colonel
of the Edinburgh regiment. There were about a hundred and
sixty men of the Paisley regiment, of which the Earl of
Glencairn was colonel. (Scots Mag., viii. 30.)
[603] Grossett’s account gives the erroneous impression
that the infantry was moved to Edinburgh on account of its
desertion by the cavalry. According to the Caledonian Mercury
and the Scots Mag., the cavalry and the main body of the
regular infantry came in together by forced marches from
Stirling on the morning of the 24th, ‘men and horses extremely
fatigued.’ The west country militia arrived later, by ship from
Bo’ness, the intention originally being to send them on to one
of the East Lothian or Berwickshire ports (see Lord Justice-
Clerk’s letter, xvii. p. 390 post). It was decided, however, not to
abandon Edinburgh, so the infantry was kept in the town, but
‘all the dragoons were marched eastward’; the text here
locates Haddington as their destination.
[604] Letters xii.-xviii. pp. 388, 391.
[605] Letter xiii. p. 388.
[606] The Milford, on 28th November, captured off
Montrose the Louis XV., one of Lord John Drummond’s
transports; eighteen officers and one hundred and sixty men
were made prisoners, and a large quantity of arms and military
stores were taken. The prisoners were confined in Edinburgh
Castle until 26th December, when they were sent to Berwick.
[607] Letter xix. p. 391.
[608] Henry C. Hawley; b. c. 1679, d. 1757. Served at
Almanza, where he was taken prisoner; Sheriffmuir, where he
was wounded; Dettingen and Fontenoy; C.-in-C. at Falkirk;
commanded the cavalry at Culloden. Execrated by the
Jacobites, and detested by his own soldiers, who dubbed him
for his cruelty the Lord Chief-Justice and hangman. He arrived
in Edinburgh on January 6th, 1746.
[609] In the ‘Narrative’ this sentence begins ‘Mr. Grossett
having received certain intelligence which he communicated to
Lord Justice Clarke that the rebells....’
[610] The ‘Narrative’ says ‘one hundred.’ This agrees with
Maxwell of Kirkconnell ‘not above a hundred,’ but the number
was continually increasing.
[611] Lieut.-colonel of Blakeney’s regiment (27th, now the
Royal Inniskilling Fusiliers).
[612] Letter xx. p. 392.
[613] Letters xxi., xxii. pp. 392, 393.
[614] William Blakeney, an Irishman, born in Co. Limerick
1672; brigadier-general 1741, major-general 1744, and
appointed lieut.-governor of Stirling Castle in that year. The
office was a sinecure in time of peace. When Cope left
Edinburgh for his highland march, Blakeney posted down to
Scotland and took command at Stirling Castle on 27th August.
When summoned to surrender the Castle to Prince Charles in
January, before and again after the battle of Falkirk, he replied
that he had always been looked upon as a man of honour and
the rebels should find he would die so. His successful defence
of Stirling was rewarded by promotion to lieut.-general and the
command of Minorca, which he held for ten years. His defence
of Minorca in 1756 against an overwhelming French force won
the admiration of Europe. For seventy days this old man of
eighty-four held out and never went to bed. On capitulation the
garrison was allowed to go free. Blakeney received an Irish
peerage for his defence of Minorca about the time that Admiral
Byng was executed for its abandonment.
[615] John Huske, 1692-1761, colonel of the 23rd (Royal
Welsh Fusiliers); was second in command at Falkirk, and
commanded the second line at Culloden. Major-general 1743;
general 1756. He was second in command to Blakeney at
Minorca in 1756.
Huske’s division on their march consisted of four regiments
of infantry of the line, and the Glasgow regiment, with
Ligonier’s (late Gardiner’s) and Hamilton’s dragoons (now 13th
and 14th Hussars).
[616] This is very misleading. Lord George Murray’s
scheme was to wait till the Government troops came up, and
tempt them over the bridge: when half had crossed he
intended to turn and cut them off. Lord Elcho had kept the
enemy in sight all the time, and records that the Jacobites
retired ‘in such order that the dragoons never offered to attack
them’; moreover, before the highlanders ‘had passed the
bridge the dragoons, who were in front of the regulars, drew
up close by the bridge and very abusive language passed
betwixt both sides.’
Even the picturesque touch of the substituted dinner must
go. Lord George particularly mentions both in a private letter to
his wife and in his historical letter to Hamilton of Bangour that
they had dined at Linlithgow, and the journals of the day state
that the affair occurred about 4 o’clock. Maxwell of Kirkconnell
considers that if the dragoons had been very enterprising they
might have cut off Lord George’s rear. (Elcho, Affairs of
Scotland, p. 370; Jac. Mem., p. 79; Chron. Ath. and Tullib., iii.
141; Kirkconnell’s Narrative, p. 98.)
[617] This is meant to be an account of the battle of Falkirk.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like