Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .openpublishing.redirection.json
Original file line number Diff line number Diff line change
Expand Up @@ -11226,6 +11226,11 @@
"source_path": "docs/standard/application-essentials.md",
"redirect_url": "/dotnet/standard/index"
},
{
"source_path": "docs/standard/analyzers/framework-analyzer.md",
"redirect_url": "/dotnet/framework/code-analyzers",
"redirect_document_id": true
},
{
"source_path": "docs/standard/assembly-format.md",
"redirect_url": "/dotnet/standard/assembly/file-format",
Expand Down Expand Up @@ -11455,6 +11460,30 @@
"source_path": "docs/standard/concepts.md",
"redirect_url": "/dotnet/standard/"
},
{
"source_path": "docs/standard/cross-platform/app-resources-for-libraries-that-target-multiple-platforms.md",
"redirect_url": "/dotnet/framework/cross-platform/app-resources-for-libraries-that-target-multiple-platforms"
},
{
"source_path": "docs/standard/cross-platform/cross-platform-development-with-the-portable-class-library.md",
"redirect_url": "/dotnet/framework/cross-platform/portable-class-library"
},
{
"source_path": "docs/standard/cross-platform/index.md",
"redirect_url": "/dotnet/framework/cross-platform/index"
},
{
"source_path": "docs/standard/cross-platform/passing-a-uri-to-the-windows-runtime.md",
"redirect_url": "/dotnet/framework/cross-platform/passing-a-uri-to-the-windows-runtime"
},
{
"source_path": "docs/standard/cross-platform/support-for-windows-store-apps-and-windows-runtime.md",
"redirect_url": "/dotnet/framework/cross-platform/support-for-windows-store-apps-and-windows-runtime"
},
{
"source_path": "docs/standard/cross-platform/using-portable-class-library-with-model-view-view-model.md",
"redirect_url": "/dotnet/framework/cross-platform/using-portable-class-library-with-model-view-view-model"
},
{
"source_path": "docs/standard/cross-platform/windowsruntimestreamextensions-asrandomaccessstream-method.md",
"redirect_url": "/dotnet/api/System.IO.WindowsRuntimeStreamExtensions.AsRandomAccessStream"
Expand All @@ -11471,6 +11500,11 @@
"source_path": "docs/standard/design-guidelines/dispose-pattern.md",
"redirect_url": "/dotnet/standard/garbage-collection/implementing-dispose"
},
{
"source_path": "docs/standard/events/how-to-consume-events-in-a-web-forms-application.md",
"redirect_url": "/aspnet/web-forms/overview/how-to-consume-events",
"redirect_document_id": true
},
{
"source_path": "docs/standard/exceptions.md",
"redirect_url": "/dotnet/standard/exceptions/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ f1_keywords:
- "whereconstraint_CSharpKeyword"
- "classconstraint_CSharpKeyword"
- "structconstraint_CSharpKeyword"
- "enumconstraint_CSharpKeyword"
helpviewer_keywords:
- "where (generic type constraint) [C#]"
---
Expand Down
67 changes: 67 additions & 0 deletions docs/framework/code-analyzers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
title: Code analyzers for .NET Framework
titleSuffix: ""
description: Learn how to use the analyzers in the .NET Framework Analyzers package to find and address issues in your code.
author: billwagner
ms.author: wiwagn
ms.date: 10/23/2020
---
# Code analysis

You can use code analyzers to find potential issues in your .NET Framework application code. The analyzers find potential issues and suggest fixes for them.

Roslyn-based code analyzers run interactively in Visual Studio as you write your code
or as part of a CI build. You should add the analyzers to your project as
early as possible in the development cycle. The sooner you find any potential issues
in your code, the easier they are to fix. The analyzers flag issues in existing code and
warn about new issues as you continue development.

## Install and configure analyzers

The .NET Framework Analyzer is delivered in the [Microsoft.NetFramework.Analyzers](https://www.nuget.org/packages/Microsoft.NetFramework.Analyzers/) NuGet package. This package provides analyzers that are specific to .NET Framework APIs, which includes security analyzers. The package is included with the [Microsoft.CodeAnalysis.FxCopAnalyzers package](https://www.nuget.org/packages/Microsoft.CodeAnalysis.FxCopAnalyzers), so if you install that package, there's no need to install the .NET Framework analyzers separately.

Install the NuGet package on every project where you want the analyzers to run. Only one developer needs to add them
to the project. The analyzer package is a project dependency and will run on every developer's machine once it has the updated solution.

To install the package, right-click on the project, and select "Manage Dependencies". From the NuGet explorer, search for "Microsoft.NetFramework.Analyzers". Install the latest stable version in all projects in your solution.

## Use the analyzers

Once the NuGet package is installed, build your solution. The analyzer will
report any issues it locates in your codebase. The issues are reported as
warnings in the Visual Studio Error List window, as shown in the following image:

![Issues reported by .NET Framework analyzers.](./media/framework-analyzers-2.png)

As you write code, you see squiggles underneath any potential issue in your code.
Hover over any issue to get more information and see suggestions
for any possible fix, as shown in the following image:

![Interactive report of issues found by code analyzers.](./media/framework-analyzers-1.png)

For more information, see [Code analysis in Visual Studio](/visualstudio/code-quality/roslyn-analyzers-overview).

## Types of rules

The analyzers examine the code in your solution and surface warnings with a `CA` prefix. For a list of all possible warnings, see [Code quality rules](../fundamentals/code-analysis/quality-rules/index.md). Only some of these warnings apply to .NET Framework APIS, including:

- [CA1058: Types should not extend certain base types](../fundamentals/code-analysis/quality-rules/ca1058.md)

- [CA2153: Do not catch corrupted state exceptions](../fundamentals/code-analysis/quality-rules/ca2153.md)

- [CA2229: Implement serialization constructors](../fundamentals/code-analysis/quality-rules/ca2229.md)

- [CA2235: Mark all non-serializable fields](../fundamentals/code-analysis/quality-rules/ca2235.md)

- [CA2237: Mark ISerializable types with serializable](../fundamentals/code-analysis/quality-rules/ca2237.md)

- [CA3075: Insecure DTD processing in XML](../fundamentals/code-analysis/quality-rules/ca3075.md)

- [CA5350: Do not use weak cryptographic algorithms](../fundamentals/code-analysis/quality-rules/ca5350.md)

- [CA5351 Do not use broken cryptographic algorithms](../fundamentals/code-analysis/quality-rules/ca5351.md)

## See also

- [Code analysis in Visual Studio](/visualstudio/code-quality/roslyn-analyzers-overview)
- [Code analysis in the .NET SDK](../fundamentals/code-analysis/overview.md)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "App Resources for Libraries That Target Multiple Platforms"
ms.date: "07/18/2018"
ms.technology: dotnet-standard
dev_langs:
- "csharp"
- "vb"
Expand All @@ -14,7 +13,7 @@ helpviewer_keywords:
ms.assetid: 72c76f0b-7255-4576-9261-3587f949669c
---
# App Resources for Libraries That Target Multiple Platforms
You can use the .NET Framework [Portable Class Library](cross-platform-development-with-the-portable-class-library.md) project type to ensure that resources in your class libraries can be accessed from multiple platforms. This project type is available in Visual Studio 2012 and targets the portable subset of the .NET Framework class library. Using a Portable Class Library ensures that your library can be accessed from desktop apps, Silverlight apps, Windows Phone apps, and Windows 8.x Store apps.
You can use the .NET Framework [Portable Class Library](portable-class-library.md) project type to ensure that resources in your class libraries can be accessed from multiple platforms. This project type is available in Visual Studio 2012 and targets the portable subset of the .NET Framework class library. Using a Portable Class Library ensures that your library can be accessed from desktop apps, Silverlight apps, Windows Phone apps, and Windows 8.x Store apps.

[!INCLUDE[standard](../../../includes/pcl-to-standard.md)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "Developing for Multiple Platforms with .NET Framework"
ms.date: 10/21/2020
ms.technology: dotnet-standard
ms.assetid: b153baaa-130c-4169-860b-e580591de91e
---
# Develop for multiple platforms with .NET Framework
Expand All @@ -19,7 +18,7 @@ To develop for multiple platforms, you can share source code or binaries, and yo
|If you want to...|Use...|
|-----------------------|------------|
|Share source code between Windows Phone 8.1 and Windows 8.1 apps|**Shared projects** (Universal Apps template in Visual Studio 2013, Update 2).<br /><br /> - Currently no Visual Basic support.<br />- You can separate platform-specific code by using #`if` statements.<br /><br /> For details, see:<br /><br /> - [Start coding](/windows/uwp/get-started/create-uwp-apps)<br />- [Using Visual Studio to build Universal XAML Apps](https://devblogs.microsoft.com/visualstudio/using-visual-studio-to-build-universal-xaml-apps/) (blog post)<br />- [Using Visual Studio to Build XAML Converged Apps](https://channel9.msdn.com/Events/Build/2014/3-591) (video)|
|Share binaries between apps that target different platforms|**Portable Class Library projects** for code that is platform-agnostic.<br /><br /> - This approach is typically used for code that implements business logic.<br />- You can use Visual Basic or C#.<br />- API support varies by platform.<br />- Portable Class Library projects that target Windows 8.1 and Windows Phone 8.1 support Windows Runtime APIs and XAML. These features aren't available in older versions of the Portable Class Library.<br />- If needed, you can abstract out platform-specific code by using interfaces or abstract classes.<br /><br /> For details, see:<br /><br /> - [Portable Class Library](cross-platform-development-with-the-portable-class-library.md)<br />- [How to Make Portable Class Libraries Work for You](/archive/blogs/dsplaisted/how-to-make-portable-class-libraries-work-for-you) (blog post)<br />- [Using Portable Class Library with MVVM](using-portable-class-library-with-model-view-view-model.md) <br />- [App Resources for Libraries That Target Multiple Platforms](app-resources-for-libraries-that-target-multiple-platforms.md) <br />- [.NET Portability Analyzer](https://marketplace.visualstudio.com/items?itemName=ConnieYau.NETPortabilityAnalyzer) (Visual Studio extension)|
|Share binaries between apps that target different platforms|**Portable Class Library projects** for code that is platform-agnostic.<br /><br /> - This approach is typically used for code that implements business logic.<br />- You can use Visual Basic or C#.<br />- API support varies by platform.<br />- Portable Class Library projects that target Windows 8.1 and Windows Phone 8.1 support Windows Runtime APIs and XAML. These features aren't available in older versions of the Portable Class Library.<br />- If needed, you can abstract out platform-specific code by using interfaces or abstract classes.<br /><br /> For details, see:<br /><br /> - [Portable Class Library](portable-class-library.md)<br />- [How to Make Portable Class Libraries Work for You](/archive/blogs/dsplaisted/how-to-make-portable-class-libraries-work-for-you) (blog post)<br />- [Using Portable Class Library with MVVM](using-portable-class-library-with-model-view-view-model.md) <br />- [App Resources for Libraries That Target Multiple Platforms](app-resources-for-libraries-that-target-multiple-platforms.md) <br />- [.NET Portability Analyzer](https://marketplace.visualstudio.com/items?itemName=ConnieYau.NETPortabilityAnalyzer) (Visual Studio extension)|
|Share source code between apps for platforms other than Windows 8.1 and Windows Phone 8.1|**Add as link** feature.<br /><br /> - This approach is suitable for app logic that's common to both apps but not portable, for some reason. You can use this feature for C# or Visual Basic code.<br /> For example, Windows Phone 8 and Windows 8 share Windows Runtime APIs, but Portable Class Libraries do not support Windows Runtime for those platforms. You can use `Add as link` to share common Windows Runtime code between a Windows Phone 8 app and a Windows Store app that targets Windows 8.<br /><br /> For details, see:<br /><br /> - [Share code with Add as Link](/previous-versions/windows/apps/jj714082(v=vs.105))<br />- [How to: Add Existing Items to a Project](/previous-versions/visualstudio/visual-studio-2010/9f4t9t92(v=vs.100))|
|Write Windows Store apps using the .NET Framework or call Windows Runtime APIs from .NET Framework code|**Windows Runtime APIs** from your .NET Framework C# or Visual Basic code, and use the .NET Framework to create Windows Store apps. You should be aware of API differences between the two platforms. However, there are classes to help you work with those differences.<br /><br /> For details, see:<br /><br /> - [.NET Framework Support for Windows Store Apps and Windows Runtime](support-for-windows-store-apps-and-windows-runtime.md) <br />- [Passing a URI to the Windows Runtime](passing-a-uri-to-the-windows-runtime.md) <br />- <xref:System.IO.WindowsRuntimeStreamExtensions><br />- <xref:System.WindowsRuntimeSystemExtensions>|
|Build .NET Framework apps for non-Microsoft platforms|**Portable Class Library reference assemblies** in the .NET Framework, and a Visual Studio extension or third-party tool such as Xamarin.<br /><br /> For details, see:<br /><br /> - [Portable Class Library now available on all platforms.](https://devblogs.microsoft.com/dotnet/portable-class-library-pcl-now-available-on-all-platforms/) (blog post)<br />- [Xamarin documentation](/xamarin)|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "Passing a URI to the Windows Runtime"
ms.date: "03/30/2017"
ms.technology: dotnet-standard
dev_langs:
- "csharp"
- "vb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: "Cross-Platform Development with the Portable Class Library"
description: Build cross-platform apps and libraries for Microsoft platforms quickly and easily using the Portable Class Library project type in .NET.
ms.date: 09/17/2018
ms.technology: dotnet-standard
helpviewer_keywords:
- "Portable Class Library [.NET Framework]"
- "targeting multiple platforms"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: ".NET Framework Support for Windows Store Apps and Windows Runtime"
title: ".NET Framework Support for Microsoft Store Apps and Windows Runtime"
ms.date: "03/30/2017"
ms.technology: dotnet-standard
helpviewer_keywords:
- "Windows Store apps, .NET Framework support for"
- "Windows Runtime, .NET Framework support for"
Expand All @@ -10,17 +9,17 @@ helpviewer_keywords:
- ".NET Framework, and Windows Runtime"
ms.assetid: 6fa7d044-ae12-4c54-b8ee-50915607a565
---
# .NET Framework Support for Windows Store Apps and Windows Runtime
# .NET Framework Support for Microsoft Store Apps and Windows Runtime

The .NET Framework 4.5 supports a number of software development scenarios with the Windows Runtime. These scenarios fall into three categories:

- Developing Windows 8.x Store apps with XAML controls, as described in [Roadmap for Windows Store apps using C# or Visual Basic](/previous-versions/windows/apps/br229583(v=win.10)), [How tos (XAML)](/previous-versions/windows/apps/br229566(v=win.10)), and [.NET for Windows Store apps overview](/previous-versions/windows/apps/br230302(v=vs.140)).

- Developing class libraries to use in the Windows 8.x Store apps that you create with the .NET Framework.

- Developing Windows Runtime Components, packaged in .WinMD files, which can be used by any programming language that supports the Windows Runtime. For example, see [Creating Windows Runtime Components in C# and Visual Basic](/windows/uwp/winrt-components/creating-windows-runtime-components-in-csharp-and-visual-basic).
- Developing Windows Runtime Components, packaged in .WinMD files, that can be used by any programming language that supports the Windows Runtime. For example, see [Creating Windows Runtime Components in C# and Visual Basic](/windows/uwp/winrt-components/creating-windows-runtime-components-in-csharp-and-visual-basic).

This topic outlines the support that the .NET Framework provides for all three categories, and describes the scenarios for Windows Runtime Components. The first section includes basic information about the relationship between the .NET Framework and the Windows Runtime, and explains some oddities you might encounter in the Help system and the IDE. The [second section](#WindowsRuntimeComponents) discusses scenarios for developing Windows Runtime Components.
This article outlines the support that the .NET Framework provides for all three categories, and describes the scenarios for Windows Runtime Components. The first section includes basic information about the relationship between the .NET Framework and the Windows Runtime, and explains some oddities you might encounter in the Help system and the IDE. The [second section](#WindowsRuntimeComponents) discusses scenarios for developing Windows Runtime Components.

## The Basics

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: "Using Portable Class Library with Model-View-View Model"
ms.date: "07/18/2018"
ms.technology: dotnet-standard
dev_langs:
- "csharp"
- "vb"
Expand All @@ -11,7 +10,7 @@ helpviewer_keywords:
ms.assetid: 41a0b9f8-15a2-431a-bc35-e310b2953b03
---
# Using Portable Class Library with Model-View-View Model
You can use the .NET Framework [Portable Class Library](cross-platform-development-with-the-portable-class-library.md) to implement the Model-View-View Model (MVVM) pattern and share assemblies across multiple platforms.
You can use the .NET Framework [Portable Class Library](portable-class-library.md) to implement the Model-View-View Model (MVVM) pattern and share assemblies across multiple platforms.

[!INCLUDE[standard](../../../includes/pcl-to-standard.md)]

Expand Down Expand Up @@ -85,4 +84,4 @@ You can use the .NET Framework [Portable Class Library](cross-platform-developme

## See also

- [Portable Class Library](cross-platform-development-with-the-portable-class-library.md)
- [Portable Class Library](portable-class-library.md)
20 changes: 8 additions & 12 deletions docs/framework/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -725,24 +725,20 @@ items:
href: misc/using-libraries-from-partially-trusted-code.md
- name: Using the Assert Method
href: misc/using-the-assert-method.md
- name: Create console apps
href: ../standard/building-console-apps.md
- name: Consume events in a Web Forms app
href: ../standard/events/how-to-consume-events-in-a-web-forms-application.md
- name: .NET Framework code analyzer
href: ../standard/analyzers/framework-analyzer.md
- name: Code analysis
href: code-analyzers.md
- name: Develop for multiple platforms
items:
- name: Overview
href: ../standard/cross-platform/index.md
href: cross-platform/index.md
displayName: cross platform
- name: Portable Class Library
href: ../standard/cross-platform/cross-platform-development-with-the-portable-class-library.md
href: cross-platform/portable-class-library.md
- name: Use Portable Class Library with MVVM
href: ../standard/cross-platform/using-portable-class-library-with-model-view-view-model.md
href: cross-platform/using-portable-class-library-with-model-view-view-model.md
- name: App resources for libraries that target multiple platforms
href: ../standard/cross-platform/app-resources-for-libraries-that-target-multiple-platforms.md
href: cross-platform/app-resources-for-libraries-that-target-multiple-platforms.md
- name: .NET Framework support for Microsoft Store apps and Windows Runtime
href: ../standard/cross-platform/support-for-windows-store-apps-and-windows-runtime.md
href: cross-platform/support-for-windows-store-apps-and-windows-runtime.md
- name: Pass a URI to the Windows Runtime
href: ../standard/cross-platform/passing-a-uri-to-the-windows-runtime.md
href: cross-platform/passing-a-uri-to-the-windows-runtime.md
Loading