GitHub Copilot Tips for .NET Developers | .NET Conf 2023

dotnet
16 Nov 202328:46

TLDRIn this .NET Conf 2023 session, Mark Downey, a product manager from the Visual Studio debugging and diagnostics team, discusses GitHub Copilot Chat and its potential to enhance .NET development productivity. He emphasizes the importance of using the tool responsibly, with multiple layers of safety and content moderation to prevent harmful outputs. The session includes a live demo where Downey uses GitHub Copilot to refactor code for a blogging engine, troubleshoot CSS issues, and address a serialization problem in an activityPub controller. The conversational aspect of GitHub Copilot is highlighted as it assists in understanding and resolving complex issues. Downey also demonstrates how to generate unit tests for the new code, stressing the necessity of testing and validating any code generated by the tool before integrating it into a project. The presentation concludes with the assertion that GitHub Copilot can significantly boost developer productivity when used effectively.

Takeaways

  • 📝 **GitHub Copilot Integration**: Mark Downey discusses integrating GitHub Copilot with .NET development in Visual Studio to enhance productivity.
  • 🛡️ **Responsibility and Safety**: Emphasizes the importance of using AI responsibly with multiple layers of mitigation to ensure safety and content appropriateness.
  • 🤖 **AI Model and Content Safety**: Highlights the OpenAI model's role and the surrounding content safety system to prevent harmful outputs.
  • 🧩 **User Experience Layer**: Focuses on the experience within Visual Studio or Visual Studio Code, using meta prompts and grounding for accurate results.
  • 🔍 **Contextual Assistance**: Demonstrates how GitHub Copilot provides context-aware assistance, such as explaining regular expressions within code.
  • 💻 **Code Generation and Testing**: Showcases generating and testing code with GitHub Copilot, including creating tests for new methods.
  • 🖼️ **CSS and HTML Improvements**: Illustrates using GitHub Copilot to address CSS and HTML issues, like adjusting image display in a blog engine.
  • 🔗 **Fediverse Integration**: Discusses the implementation of the ActivityPub standard for integrating a blogging engine with the fediverse.
  • 🛠️ **Debugging and Exception Handling**: Details the process of using GitHub Copilot for debugging, including understanding and resolving serialization issues.
  • 📈 **Productivity and Legacy Code**: Suggests that GitHub Copilot can help .NET developers become more productive and manage legacy code more effectively.
  • 🔗 **Extension and License Requirements**: Notes that to use GitHub Copilot features, a specific license (individual or business) is required and provides links for extension installation.

Q & A

  • What is the main topic of the talk given by Mark Downey?

    -The main topic of the talk is about GitHub Copilot Chat and how it can be used to accelerate .NET development in Visual Studio.

  • What are the mitigation layers mentioned by Mark Downey?

    -The mitigation layers mentioned are the platform itself with the open AI model, a content safety system, and the user experience layer within Visual Studio or Visual Studio Code.

  • How does GitHub Copilot Chat help with understanding code?

    -GitHub Copilot Chat helps with understanding code by providing explanations in natural language when asked about specific parts of the code, such as regular expressions or method functionality.

  • What is the issue that Mark Downey has been trying to address in his Dos blog project for two years?

    -The issue is related to selecting a hero image from the blog post. Currently, the blog automatically selects the first image as the hero image, and Mark wants to improve this by allowing the selection of multiple images and explicitly marking one as the hero image.

  • How does GitHub Copilot Chat assist with writing or rewriting methods using regular expressions?

    -GitHub Copilot Chat can assist by generating regular expressions based on natural language descriptions provided by the user. It grounds the context in the current code and generates a regex that fits the described purpose.

  • What is the importance of testing the code generated by GitHub Copilot Chat?

    -Testing the code is crucial to ensure that it fits the purpose and works correctly. It allows developers to make the code their own by validating it under various circumstances and making necessary adjustments.

  • How does Mark Downey use GitHub Copilot Chat to address CSS issues?

    -Mark Downey uses GitHub Copilot Chat to ask for CSS code that fulfills specific design requirements, like inserting an image with a maximum width and height within a div that floats to the right.

  • What is the significance of the 'activityPub' standard in the context of Dos blog?

    -The 'activityPub' standard allows for interoperability between different social networking servers, enabling Dos blog to become an active member of the fediverse, where blog posts and comments can be part of a larger communication network.

  • How does the speaker approach debugging and resolving exceptions in the code?

    -The speaker uses a conversational approach with GitHub Copilot Chat, discussing the exception, providing additional information as prompted, and testing hypotheses until the issue is resolved.

  • What is the role of unit testing in the development process described by Mark Downey?

    -Unit testing plays a vital role in validating the functionality of the code. It helps to ensure that the code works as intended and under various scenarios, including both positive and negative test cases.

  • What are the prerequisites for using the features of GitHub Copilot Chat as mentioned by Mark Downey?

    -To use the features of GitHub Copilot Chat, one needs to have a Copilot for Individuals license or a Copilot for Business license.

Outlines

00:00

😀 Introduction to GitHub Copilot Chat for Accelerated .NET Development

Mark Downey, a product manager on the Visual Studio debugging and Diagnostics team, introduces the audience to GitHub Copilot Chat. He discusses its potential to enhance productivity in .NET development and outlines the responsible approach taken by incorporating various mitigation layers to ensure content safety and appropriate use. The platform's core is based on the Open AI model, which is surrounded by a content safety system and user experience layer within Visual Studio. The goal is to provide accurate and relevant information to developers, accelerating the development process.

05:02

🔍 Exploring GitHub Copilot Chat's In-Context Assistance for Code Understanding

The speaker demonstrates how to use GitHub Copilot Chat for in-context assistance with code. He uses the 'ALT/slash' keyboard shortcut to bring up the chat and asks about a regular expression within a method. Copilot provides a breakdown of the regex and offers to explain the entire method. The speaker then reframes his question to find a 'hero image' in blog content using a regex, receiving a proposed solution. He emphasizes the importance of developers verifying the code's correctness, as Copilot's suggestions are based on probability and non-determinism.

10:03

📷 Enhancing Blog Image Display with CSS and Debugging Techniques

The speaker addresses an issue with the display of a 'hero image' on his blog, which is currently set to the first image found in a blog post. He proposes a solution to mark images with a class attribute to designate them as 'hero images'. The speaker then discusses the importance of testing and validating code. He also highlights a CSS issue with the image display, asking Copilot for help to insert an image with specific dimensions within a blog summary. The speaker iterates on the solution, testing it, and adjusting the CSS to ensure the image displays correctly.

15:05

🔗 Incorporating Dos Blog into the Fediverse with ActivityPub

The speaker talks about integrating Dos Blog with the fediverse, a loosely federated network of servers that communicate through the ActivityPub standard. He outlines the implementation of an ActivityPub controller and the need to ensure that its endpoints meet the standard. The speaker uses the Test Explorer in Visual Studio to run tests on the new components and encounters a serialization exception. He initiates a conversation with Copilot to diagnose the problem, which leads to the discovery that an empty string was being passed, causing the issue.

20:07

🛠️ Debugging and Conversational Problem-Solving with GitHub Copilot

The speaker continues to debug the serialization issue with the help of GitHub Copilot. Through a conversational approach, Copilot suggests that the problem might be due to an empty string being passed to a JSON method. The speaker verifies this by checking the value before serialization and confirms it is indeed an empty string. Copilot then suggests checking the definition of the method to better understand the issue. After providing the definition, Copilot hypothesizes that the problem might be due to the stream not being reset, which the speaker tests and confirms resolves the issue, successfully passing the test.

25:09

📚 Conclusion and Accessing GitHub Copilot Chat for .NET Developers

The speaker concludes the presentation by summarizing the benefits of using GitHub Copilot Chat for .NET developers. He mentions that the features discussed are available in preview and provides links for installing the extensions in Visual Studio. The prerequisites for using these extensions include having a GitHub Copilot for Individuals or Business license. The speaker encourages developers to take advantage of these tools to improve productivity, understand legacy code, and resolve issues more effectively.

Mindmap

Keywords

💡GitHub Copilot

GitHub Copilot is an AI-powered development tool that assists developers by generating code, suggesting fixes, and offering insights based on the context of the code being written. In the video, it is used to accelerate .NET development within Visual Studio, showcasing how it can increase productivity by providing code suggestions and explanations for complex regular expressions.

💡.NET Development

.NET development refers to the process of creating software applications using the .NET framework, which is a software development platform developed by Microsoft. The video emphasizes how GitHub Copilot can enhance productivity in .NET development workflows by automating certain coding tasks and providing developers with relevant code snippets.

💡Visual Studio

Visual Studio is an integrated development environment (IDE) from Microsoft that is widely used for .NET development. It provides tools for developers to create, debug, and deploy software. In the context of the video, Visual Studio is the platform where the presenter interacts with GitHub Copilot to demonstrate its capabilities in aiding the development process.

💡Productivity

Productivity in the context of the video refers to the efficiency and effectiveness with which developers can create and maintain software. The video discusses how GitHub Copilot can enhance developer productivity by automating repetitive tasks, providing code suggestions, and helping to solve complex coding problems more quickly.

💡Regular Expressions

Regular expressions are a powerful tool used in programming for matching patterns in strings. They are complex and can be difficult for developers to write from scratch. In the video, the presenter uses GitHub Copilot to understand and generate regular expressions for selecting specific images in a blog post, demonstrating how it can simplify this challenging aspect of programming.

💡Content Safety System

A content safety system is a set of protocols or mechanisms designed to ensure that the content generated or processed by a software tool is appropriate and free from harmful material. In the video, it is mentioned as one of the layers of safety that GitHub Copilot employs to prevent the generation of content that could be harmful, such as content related to hate or racism.

💡User Experience Layer

The user experience layer refers to the interface and interactions that a user has with a software application, in this case, Visual Studio or Visual Studio Code. The video discusses how GitHub Copilot integrates with this layer to provide a seamless and context-aware experience for developers, ensuring that the assistance provided is relevant to the task at hand.

💡Meta Prompts

Meta prompts are guiding questions or statements that help shape the output of an AI tool like GitHub Copilot. They are used to provide context and guide the AI to generate more accurate and relevant responses. In the video, the presenter uses meta prompts to ground the AI's responses in the specific application and task being worked on.

💡Fediverse

The Fediverse refers to a network of interconnected servers that can communicate with each other using the ActivityPub protocol, allowing for decentralized social networking. In the video, the presenter discusses integrating their blogging engine with the Fediverse to enable cross-server communication and interaction.

💡ActivityPub

ActivityPub is an open standard protocol for decentralized social networking, enabling different platforms to interoperate and communicate. It is mentioned in the video as the standard that the presenter is implementing in their blogging engine to become part of the Fediverse, allowing for a more interconnected and distributed social experience.

💡Debugging

Debugging is the process of identifying and resolving defects or problems in a software program. It is a crucial part of the software development process. The video demonstrates the use of debugging tools within Visual Studio to test and validate the code generated with the help of GitHub Copilot, ensuring that it functions correctly.

Highlights

Mark Downey, a product manager on the Visual Studio debugging and Diagnostics team, discusses GitHub Copilot Chat and its potential to accelerate .NET development.

GitHub Copilot Chat aims to increase developer productivity through integrated AI assistance within Visual Studio.

The platform includes multiple mitigation layers to ensure content safety and responsible AI usage.

The OpenAI model is central to the platform, with a focus on ensuring good data input and output.

A content safety system is in place to filter data and prevent the delivery of harmful content.

The user experience layer within Visual Studio Code is key to providing accurate and relevant results.

Meta prompts and grounding ensure that the AI delivers results pertinent to the current task at hand.

Mark demonstrates using GitHub Copilot Chat to understand and rewrite a method for selecting a hero image in a blog post.

The AI provides a regular expression to find the source string of an image with a 'hero image' class attribute.

Developers are encouraged to test and validate AI-generated code to ensure it fits their specific needs.

Mark addresses a CSS issue by asking GitHub Copilot Chat for assistance in creating a styled image element.

The conversational aspect of GitHub Copilot Chat allows for an ongoing dialogue to troubleshoot and resolve coding issues.

GitHub Copilot Chat assists in debugging by providing hypotheses and requesting additional information to isolate problems.

Mark successfully resolves a serialization issue in testing with the help of GitHub Copilot Chat's suggestions.

The integration of GitHub Copilot Chat in Visual Studio is available for preview to individuals and businesses with the appropriate license.

The extension promises to be a compelling tool for .NET developers, aiding in code understanding, updating legacy code, and exception handling.

Mark emphasizes the importance of making AI-generated code one's own through thorough testing and validation.